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,10 +4,10 @@
#include <exception>
#include <fmt/format.h>
#include <opencv2/core/core.hpp>
#include <wpi/SmallString.h>
#include <wpi/jni_util.h>
#include <wpi/raw_ostream.h>
#include "cscore_cpp.h"
#include "cscore_cv.h"
@@ -197,7 +197,8 @@ static void ReportError(JNIEnv* env, CS_Status status) {
if (status == CS_OK) {
return;
}
wpi::SmallString<64> msg;
std::string_view msg;
std::string msgBuf;
switch (status) {
case CS_PROPERTY_WRITE_FAILED:
msg = "property write failed";
@@ -230,8 +231,8 @@ static void ReportError(JNIEnv* env, CS_Status status) {
msg = "telemetry not enabled";
break;
default: {
wpi::raw_svector_ostream oss{msg};
oss << "unknown error code=" << status;
msgBuf = fmt::format("unknown error code={}", status);
msg = msgBuf;
break;
}
}
@@ -577,7 +578,7 @@ Java_edu_wpi_first_cscore_CameraServerJNI_createHttpCameraMulti
// TODO
return 0;
}
vec.push_back(JStringRef{env, elem}.str());
vec.emplace_back(JStringRef{env, elem}.str());
}
CS_Status status = 0;
auto val =
@@ -1172,7 +1173,7 @@ Java_edu_wpi_first_cscore_CameraServerJNI_setHttpCameraUrls
// TODO
return;
}
vec.push_back(JStringRef{env, elem}.str());
vec.emplace_back(JStringRef{env, elem}.str());
}
CS_Status status = 0;
cs::SetHttpCameraUrls(source, vec, &status);
@@ -1353,7 +1354,7 @@ Java_edu_wpi_first_cscore_CameraServerJNI_setSourceEnumPropertyChoices
// TODO
return;
}
vec.push_back(JStringRef{env, elem}.str());
vec.emplace_back(JStringRef{env, elem}.str());
}
CS_Status status = 0;
cs::SetSourceEnumPropertyChoices(source, property, vec, &status);