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

@@ -2,6 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <cstdio>
#include <thread>
#include <cameraserver/CameraServer.h>
@@ -9,7 +10,6 @@
#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <wpi/raw_ostream.h>
/**
* This is a demo program showing the use of OpenCV to do vision processing. The
@@ -18,7 +18,7 @@
* processing.
*/
class Robot : public frc::TimedRobot {
#if defined(__linux__)
#if defined(__linux__) || defined(_WIN32)
private:
static void VisionThread() {
@@ -60,12 +60,12 @@ class Robot : public frc::TimedRobot {
void RobotInit() override {
// We need to run our vision program in a separate thread. If not, our robot
// program will not run.
#if defined(__linux__)
#if defined(__linux__) || defined(_WIN32)
std::thread visionThread(VisionThread);
visionThread.detach();
#else
wpi::errs() << "Vision only available on Linux.\n";
wpi::errs().flush();
std::fputs("Vision only available on Linux or Windows.\n", stderr);
std::fflush(stderr);
#endif
}
};

View File

@@ -2,9 +2,10 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <cstdio>
#include <cameraserver/CameraServer.h>
#include <frc/TimedRobot.h>
#include <wpi/raw_ostream.h>
/**
* Uses the CameraServer class to automatically capture video from a USB webcam
@@ -15,11 +16,11 @@
class Robot : public frc::TimedRobot {
public:
void RobotInit() override {
#if defined(__linux__)
#if defined(__linux__) || defined(_WIN32)
frc::CameraServer::GetInstance()->StartAutomaticCapture();
#else
wpi::errs() << "Vision only available on Linux.\n";
wpi::errs().flush();
std::fputs("Vision only available on Linux or Windows.\n", stderr);
std::fflush(stderr);
#endif
}
};