Use std::string_view and fmtlib across all libraries (#3402)

- Twine, StringRef, Format, and NativeFormatting have been removed
- Logging now uses fmtlib style formatting
- Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or
std::puts()/std::fputs() (for unformatted strings).
- A wpi/fmt/raw_ostream.h header has been added to enable
fmt::print() with wpi::raw_ostream
This commit is contained in:
Peter Johnson
2021-06-06 16:13:58 -07:00
committed by GitHub
parent 4f1cecb8e7
commit b2c3b2dd8e
441 changed files with 5061 additions and 9749 deletions

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/StringRef.h>
#include <string_view>
namespace frc {
@@ -25,7 +25,7 @@ class LayoutType {
* Gets the string type of the layout as defined by that layout in
* Shuffleboard.
*/
wpi::StringRef GetLayoutName() const;
std::string_view GetLayoutName() const;
private:
const char* m_layoutName;

View File

@@ -6,11 +6,11 @@
#include <memory>
#include <string>
#include <string_view>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/SmallVector.h>
#include <wpi/StringRef.h>
#include "frc/shuffleboard/ShuffleboardEventImportance.h"
@@ -23,10 +23,10 @@ class RecordingController final {
void StartRecording();
void StopRecording();
void SetRecordingFileNameFormat(wpi::StringRef format);
void SetRecordingFileNameFormat(std::string_view format);
void ClearRecordingFileNameFormat();
void AddEventMarker(wpi::StringRef name, wpi::StringRef description,
void AddEventMarker(std::string_view name, std::string_view description,
ShuffleboardEventImportance importance);
private:

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/StringRef.h>
#include <string_view>
#include "frc/shuffleboard/RecordingController.h"
#include "frc/shuffleboard/ShuffleboardEventImportance.h"
@@ -77,7 +77,7 @@ class Shuffleboard final {
* @param title the title of the tab
* @return the tab with the given title
*/
static ShuffleboardTab& GetTab(wpi::StringRef title);
static ShuffleboardTab& GetTab(std::string_view title);
/**
* Selects the tab in the dashboard with the given index in the range
@@ -93,7 +93,7 @@ class Shuffleboard final {
*
* @param title the title of the tab to select
*/
static void SelectTab(wpi::StringRef title);
static void SelectTab(std::string_view title);
/**
* Enables user control of widgets containing actuators: speed controllers,
@@ -141,7 +141,7 @@ class Shuffleboard final {
*
* @param format the format for the
*/
static void SetRecordingFileNameFormat(wpi::StringRef format);
static void SetRecordingFileNameFormat(std::string_view format);
/**
* Clears the custom name format for recording files. New recordings will use
@@ -163,7 +163,8 @@ class Shuffleboard final {
* @param description a description of the event
* @param importance the importance of the event
*/
static void AddEventMarker(wpi::StringRef name, wpi::StringRef description,
static void AddEventMarker(std::string_view name,
std::string_view description,
ShuffleboardEventImportance importance);
/**
@@ -177,7 +178,7 @@ class Shuffleboard final {
* @param name the name of the event
* @param importance the importance of the event
*/
static void AddEventMarker(wpi::StringRef name,
static void AddEventMarker(std::string_view name,
ShuffleboardEventImportance importance);
private:

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/StringRef.h>
#include <string_view>
namespace frc {
@@ -14,7 +14,7 @@ namespace frc {
enum ShuffleboardEventImportance { kTrivial, kLow, kNormal, kHigh, kCritical };
inline wpi::StringRef ShuffleboardEventImportanceName(
inline std::string_view ShuffleboardEventImportanceName(
ShuffleboardEventImportance importance) {
switch (importance) {
case kTrivial:

View File

@@ -5,6 +5,7 @@
#pragma once
#include <memory>
#include <string_view>
#include "frc/shuffleboard/ShuffleboardRoot.h"
#include "frc/shuffleboard/ShuffleboardTab.h"
@@ -19,7 +20,7 @@ class ShuffleboardInstance final : public ShuffleboardRoot {
ShuffleboardInstance(ShuffleboardInstance&&) = default;
ShuffleboardInstance& operator=(ShuffleboardInstance&&) = default;
frc::ShuffleboardTab& GetTab(wpi::StringRef title) override;
frc::ShuffleboardTab& GetTab(std::string_view title) override;
void Update() override;
@@ -29,7 +30,7 @@ class ShuffleboardInstance final : public ShuffleboardRoot {
void SelectTab(int index) override;
void SelectTab(wpi::StringRef) override;
void SelectTab(std::string_view) override;
private:
struct Impl;

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/StringRef.h>
#include <string_view>
namespace frc {
@@ -25,7 +25,7 @@ class ShuffleboardRoot {
* @param title the title of the tab
* @return the tab with the given title
*/
virtual ShuffleboardTab& GetTab(wpi::StringRef title) = 0;
virtual ShuffleboardTab& GetTab(std::string_view title) = 0;
/**
* Updates all tabs.
@@ -57,7 +57,7 @@ class ShuffleboardRoot {
*
* @param title the title of the tab to select
*/
virtual void SelectTab(wpi::StringRef title) = 0;
virtual void SelectTab(std::string_view title) = 0;
};
} // namespace frc

View File

@@ -5,9 +5,9 @@
#pragma once
#include <memory>
#include <string_view>
#include <networktables/NetworkTable.h>
#include <wpi/StringRef.h>
#include "frc/shuffleboard/ShuffleboardContainer.h"
@@ -24,7 +24,7 @@ class ShuffleboardRoot;
*/
class ShuffleboardTab final : public ShuffleboardContainer {
public:
ShuffleboardTab(ShuffleboardRoot& root, wpi::StringRef title);
ShuffleboardTab(ShuffleboardRoot& root, std::string_view title);
ShuffleboardRoot& GetRoot();

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/StringRef.h>
#include <string_view>
namespace frc {
@@ -25,7 +25,7 @@ class WidgetType {
* Gets the string type of the widget as defined by that widget in
* Shuffleboard.
*/
wpi::StringRef GetWidgetName() const;
std::string_view GetWidgetName() const;
private:
const char* m_widgetName;