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

@@ -6,9 +6,12 @@
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <memory>
#include <string_view>
#include <utility>
#include <fmt/format.h>
#include <frc/geometry/Pose2d.h>
#include <frc/geometry/Rotation2d.h>
#include <frc/geometry/Transform2d.h>
@@ -21,7 +24,6 @@
#include <portable-file-dialogs.h>
#include <units/angle.h>
#include <units/length.h>
#include <wpi/raw_ostream.h>
#include <wpigui.h>
#include "glass/Context.h"
@@ -125,10 +127,10 @@ void BackgroundInfo::LoadImage() {
}
bool BackgroundInfo::LoadImageImpl(const char* fn) {
wpi::outs() << "GUI: loading background image '" << fn << "'\n";
fmt::print("GUI: loading background image '{}'\n", fn);
auto texture = gui::Texture::CreateFromFile(fn);
if (!texture) {
wpi::errs() << "GUI: could not read background image\n";
std::puts("GUI: could not read background image");
return false;
}
m_texture = std::move(texture);
@@ -182,7 +184,7 @@ void glass::DisplayMechanism2DSettings(Mechanism2DModel* model) {
void FrameData::DrawObject(ImDrawList* drawList, MechanismObjectModel& objModel,
const frc::Pose2d& pose) const {
const char* type = objModel.GetType();
if (wpi::StringRef{type} == "line") {
if (std::string_view{type} == "line") {
auto startPose =
pose + frc::Transform2d{frc::Translation2d{}, objModel.GetAngle()};
auto endPose =