diff --git a/hal/include/HAL/cpp/Log.h b/hal/include/HAL/cpp/Log.h index 4ddbd4fe24..528cda3891 100644 --- a/hal/include/HAL/cpp/Log.h +++ b/hal/include/HAL/cpp/Log.h @@ -10,9 +10,11 @@ #include #include #include -#include #include +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" + inline std::string NowTime(); enum TLogLevel { @@ -31,7 +33,7 @@ class Log { public: Log(); virtual ~Log(); - std::ostringstream& Get(TLogLevel level = logINFO); + llvm::raw_ostream& Get(TLogLevel level = logINFO); public: static TLogLevel& ReportingLevel(); @@ -39,7 +41,8 @@ class Log { static TLogLevel FromString(const std::string& level); protected: - std::ostringstream os; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss{buf}; private: Log(const Log&); @@ -48,16 +51,16 @@ class Log { inline Log::Log() {} -inline std::ostringstream& Log::Get(TLogLevel level) { - os << "- " << NowTime(); - os << " " << ToString(level) << ": "; - os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t'); - return os; +inline llvm::raw_ostream& Log::Get(TLogLevel level) { + oss << "- " << NowTime(); + oss << " " << ToString(level) << ": "; + oss << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t'); + return oss; } inline Log::~Log() { - os << std::endl; - std::cerr << os.str(); + oss << "\n"; + std::cerr << oss.str(); } inline TLogLevel& Log::ReportingLevel() { @@ -96,16 +99,29 @@ typedef Log FILELog; Log().Get(level) inline std::string NowTime() { - std::stringstream ss; - ss << std::setfill('0') << std::setw(2); + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss(buf); using namespace std::chrono; auto now = system_clock::now().time_since_epoch(); - ss << duration_cast(now).count() % 24 << ":" - << duration_cast(now).count() % 60 << ":" - << duration_cast(now).count() % 60 << "." - << duration_cast(now).count() % 1000; + // Hours + auto count = duration_cast(now).count() % 24; + if (count < 10) oss << "0"; + oss << count << ":"; - return ss.str(); + // Minutes + count = duration_cast(now).count() % 60; + if (count < 10) oss << "0"; + oss << count << ":"; + + // Seconds + count = duration_cast(now).count() % 60; + if (count < 10) oss << "0"; + oss << count << "."; + + // Milliseconds + oss << duration_cast(now).count() % 1000; + + return oss.str(); } diff --git a/wpilibc/athena/include/MotorSafety.h b/wpilibc/athena/include/MotorSafety.h index 27c938cd9d..d78c310209 100644 --- a/wpilibc/athena/include/MotorSafety.h +++ b/wpilibc/athena/include/MotorSafety.h @@ -9,7 +9,7 @@ #define DEFAULT_SAFETY_EXPIRATION 0.1 -#include +#include "llvm/raw_ostream.h" namespace frc { @@ -21,7 +21,7 @@ class MotorSafety { virtual void StopMotor() = 0; virtual void SetSafetyEnabled(bool enabled) = 0; virtual bool IsSafetyEnabled() const = 0; - virtual void GetDescription(std::ostringstream& desc) const = 0; + virtual void GetDescription(llvm::raw_ostream& desc) const = 0; }; } // namespace frc diff --git a/wpilibc/athena/include/Relay.h b/wpilibc/athena/include/Relay.h index eac39673f8..019c61cc27 100644 --- a/wpilibc/athena/include/Relay.h +++ b/wpilibc/athena/include/Relay.h @@ -14,6 +14,7 @@ #include "LiveWindow/LiveWindowSendable.h" #include "MotorSafety.h" #include "SensorBase.h" +#include "llvm/raw_ostream.h" #include "tables/ITable.h" #include "tables/ITableListener.h" @@ -53,7 +54,7 @@ class Relay : public MotorSafety, void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(std::ostringstream& desc) const override; + void GetDescription(llvm::raw_ostream& desc) const override; void ValueChanged(ITable* source, llvm::StringRef key, std::shared_ptr value, bool isNew) override; diff --git a/wpilibc/athena/include/RobotDrive.h b/wpilibc/athena/include/RobotDrive.h index 219ef9e1e2..0c5fddab0a 100644 --- a/wpilibc/athena/include/RobotDrive.h +++ b/wpilibc/athena/include/RobotDrive.h @@ -8,11 +8,11 @@ #pragma once #include -#include #include "ErrorBase.h" #include "MotorSafety.h" #include "MotorSafetyHelper.h" +#include "llvm/raw_ostream.h" namespace frc { @@ -94,7 +94,7 @@ class RobotDrive : public MotorSafety, public ErrorBase { void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(std::ostringstream& desc) const override; + void GetDescription(llvm::raw_ostream& desc) const override; protected: void InitRobotDrive(); diff --git a/wpilibc/athena/include/SafePWM.h b/wpilibc/athena/include/SafePWM.h index 16a64c1045..b9c92af6d3 100644 --- a/wpilibc/athena/include/SafePWM.h +++ b/wpilibc/athena/include/SafePWM.h @@ -8,11 +8,11 @@ #pragma once #include -#include #include "MotorSafety.h" #include "MotorSafetyHelper.h" #include "PWM.h" +#include "llvm/raw_ostream.h" namespace frc { @@ -34,7 +34,7 @@ class SafePWM : public PWM, public MotorSafety { void StopMotor(); bool IsSafetyEnabled() const; void SetSafetyEnabled(bool enabled); - void GetDescription(std::ostringstream& desc) const; + void GetDescription(llvm::raw_ostream& desc) const; virtual void SetSpeed(double speed); diff --git a/wpilibc/athena/src/AnalogInput.cpp b/wpilibc/athena/src/AnalogInput.cpp index d370c3a7f1..2e59eaa01c 100644 --- a/wpilibc/athena/src/AnalogInput.cpp +++ b/wpilibc/athena/src/AnalogInput.cpp @@ -8,14 +8,14 @@ #include "AnalogInput.h" #include "HAL/AnalogInput.h" -#include - #include "HAL/AnalogAccumulator.h" #include "HAL/HAL.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "Timer.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -30,7 +30,8 @@ const int AnalogInput::kAccumulatorChannels[] = {0, 1}; * on-board 4-7 are on the MXP port. */ AnalogInput::AnalogInput(int channel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); buf << "Analog Input " << channel; if (!SensorBase::CheckAnalogInputChannel(channel)) { diff --git a/wpilibc/athena/src/AnalogOutput.cpp b/wpilibc/athena/src/AnalogOutput.cpp index 3905ae12aa..7cbf9e2c97 100644 --- a/wpilibc/athena/src/AnalogOutput.cpp +++ b/wpilibc/athena/src/AnalogOutput.cpp @@ -8,12 +8,13 @@ #include "AnalogOutput.h" #include -#include #include "HAL/HAL.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -25,8 +26,9 @@ using namespace frc; * @param channel The channel number on the roboRIO to represent. */ AnalogOutput::AnalogOutput(int channel) { - std::stringstream buf; - buf << "analog input " << channel; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); + buf << "analog output " << channel; if (!SensorBase::CheckAnalogOutputChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str()); diff --git a/wpilibc/athena/src/DigitalInput.cpp b/wpilibc/athena/src/DigitalInput.cpp index 2eeefbb7f4..13447c8838 100644 --- a/wpilibc/athena/src/DigitalInput.cpp +++ b/wpilibc/athena/src/DigitalInput.cpp @@ -8,13 +8,14 @@ #include "DigitalInput.h" #include -#include #include "HAL/DIO.h" #include "HAL/HAL.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -26,7 +27,8 @@ using namespace frc; * @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port */ DigitalInput::DigitalInput(int channel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); if (!CheckDigitalChannel(channel)) { buf << "Digital Channel " << channel; diff --git a/wpilibc/athena/src/DigitalOutput.cpp b/wpilibc/athena/src/DigitalOutput.cpp index 381df60c7f..a9e3942fec 100644 --- a/wpilibc/athena/src/DigitalOutput.cpp +++ b/wpilibc/athena/src/DigitalOutput.cpp @@ -8,12 +8,13 @@ #include "DigitalOutput.h" #include -#include #include "HAL/DIO.h" #include "HAL/HAL.h" #include "HAL/Ports.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -26,7 +27,8 @@ using namespace frc; * port */ DigitalOutput::DigitalOutput(int channel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); m_pwmGenerator = HAL_kInvalidHandle; if (!CheckDigitalChannel(channel)) { diff --git a/wpilibc/athena/src/DoubleSolenoid.cpp b/wpilibc/athena/src/DoubleSolenoid.cpp index 1954adaf68..a2f92d4274 100644 --- a/wpilibc/athena/src/DoubleSolenoid.cpp +++ b/wpilibc/athena/src/DoubleSolenoid.cpp @@ -7,13 +7,13 @@ #include "DoubleSolenoid.h" -#include - #include "HAL/HAL.h" #include "HAL/Ports.h" #include "HAL/Solenoid.h" #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -41,7 +41,8 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel, : SolenoidBase(moduleNumber), m_forwardChannel(forwardChannel), m_reverseChannel(reverseChannel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); if (!CheckSolenoidModule(m_moduleNumber)) { buf << "Solenoid Module " << m_moduleNumber; wpi_setWPIErrorWithContext(ModuleIndexOutOfRange, buf.str()); diff --git a/wpilibc/athena/src/MotorSafetyHelper.cpp b/wpilibc/athena/src/MotorSafetyHelper.cpp index c42be31695..31f13ffd6e 100644 --- a/wpilibc/athena/src/MotorSafetyHelper.cpp +++ b/wpilibc/athena/src/MotorSafetyHelper.cpp @@ -7,12 +7,12 @@ #include "MotorSafetyHelper.h" -#include - #include "DriverStation.h" #include "MotorSafety.h" #include "Timer.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -95,10 +95,11 @@ void MotorSafetyHelper::Check() { std::lock_guard sync(m_syncMutex); if (m_stopTime < Timer::GetFPGATimestamp()) { - std::ostringstream desc; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream desc(buf); m_safeObject->GetDescription(desc); desc << "... Output not updated often enough."; - wpi_setWPIErrorWithContext(Timeout, desc.str().c_str()); + wpi_setWPIErrorWithContext(Timeout, desc.str()); m_safeObject->StopMotor(); } } diff --git a/wpilibc/athena/src/PWM.cpp b/wpilibc/athena/src/PWM.cpp index 4883e16e1f..85d16d01c1 100644 --- a/wpilibc/athena/src/PWM.cpp +++ b/wpilibc/athena/src/PWM.cpp @@ -8,12 +8,12 @@ #include "HAL/PWM.h" #include "PWM.h" -#include - #include "HAL/HAL.h" #include "HAL/Ports.h" #include "Utility.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -28,7 +28,8 @@ using namespace frc; * MXP port */ PWM::PWM(int channel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); if (!CheckPWMChannel(channel)) { buf << "PWM Channel " << channel; diff --git a/wpilibc/athena/src/PowerDistributionPanel.cpp b/wpilibc/athena/src/PowerDistributionPanel.cpp index 6fc33dfc67..8f778b9b51 100644 --- a/wpilibc/athena/src/PowerDistributionPanel.cpp +++ b/wpilibc/athena/src/PowerDistributionPanel.cpp @@ -7,13 +7,13 @@ #include "PowerDistributionPanel.h" -#include - #include "HAL/HAL.h" #include "HAL/PDP.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -76,7 +76,8 @@ double PowerDistributionPanel::GetCurrent(int channel) const { int32_t status = 0; if (!CheckPDPChannel(channel)) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); buf << "PDP Channel " << channel; wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str()); } diff --git a/wpilibc/athena/src/Relay.cpp b/wpilibc/athena/src/Relay.cpp index 8e3a7b0f5e..78e0d9372a 100644 --- a/wpilibc/athena/src/Relay.cpp +++ b/wpilibc/athena/src/Relay.cpp @@ -8,13 +8,12 @@ #include "HAL/Relay.h" #include "Relay.h" -#include - #include "HAL/HAL.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "MotorSafetyHelper.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" using namespace frc; @@ -29,7 +28,8 @@ using namespace frc; */ Relay::Relay(int channel, Relay::Direction direction) : m_channel(channel), m_direction(direction) { - std::stringstream buf; + llvm::SmallString<128> str; + llvm::raw_svector_ostream buf(str); if (!SensorBase::CheckRelayChannel(m_channel)) { buf << "Relay Channel " << m_channel; wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str()); @@ -268,7 +268,7 @@ bool Relay::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void Relay::GetDescription(std::ostringstream& desc) const { +void Relay::GetDescription(llvm::raw_ostream& desc) const { desc << "Relay " << GetChannel(); } diff --git a/wpilibc/athena/src/RobotDrive.cpp b/wpilibc/athena/src/RobotDrive.cpp index e5c06d1238..25143efc6c 100644 --- a/wpilibc/athena/src/RobotDrive.cpp +++ b/wpilibc/athena/src/RobotDrive.cpp @@ -718,7 +718,7 @@ void RobotDrive::SetSafetyEnabled(bool enabled) { m_safetyHelper->SetSafetyEnabled(enabled); } -void RobotDrive::GetDescription(std::ostringstream& desc) const { +void RobotDrive::GetDescription(llvm::raw_ostream& desc) const { desc << "RobotDrive"; } diff --git a/wpilibc/athena/src/SafePWM.cpp b/wpilibc/athena/src/SafePWM.cpp index cd62192852..e98833f88f 100644 --- a/wpilibc/athena/src/SafePWM.cpp +++ b/wpilibc/athena/src/SafePWM.cpp @@ -74,7 +74,7 @@ bool SafePWM::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void SafePWM::GetDescription(std::ostringstream& desc) const { +void SafePWM::GetDescription(llvm::raw_ostream& desc) const { desc << "PWM " << GetChannel(); } diff --git a/wpilibc/athena/src/Solenoid.cpp b/wpilibc/athena/src/Solenoid.cpp index d70c3c36d7..9dfdc333a0 100644 --- a/wpilibc/athena/src/Solenoid.cpp +++ b/wpilibc/athena/src/Solenoid.cpp @@ -8,12 +8,12 @@ #include "HAL/Solenoid.h" #include "Solenoid.h" -#include - #include "HAL/HAL.h" #include "HAL/Ports.h" #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -33,7 +33,8 @@ Solenoid::Solenoid(int channel) */ Solenoid::Solenoid(int moduleNumber, int channel) : SolenoidBase(moduleNumber), m_channel(channel) { - std::stringstream buf; + llvm::SmallString<32> str; + llvm::raw_svector_ostream buf(str); if (!CheckSolenoidModule(m_moduleNumber)) { buf << "Solenoid Module " << m_moduleNumber; wpi_setWPIErrorWithContext(ModuleIndexOutOfRange, buf.str()); diff --git a/wpilibc/athena/src/Utility.cpp b/wpilibc/athena/src/Utility.cpp index 1a5325167d..cbf2c99b6a 100644 --- a/wpilibc/athena/src/Utility.cpp +++ b/wpilibc/athena/src/Utility.cpp @@ -13,12 +13,12 @@ #include #include #include -#include #include "ErrorBase.h" #include "HAL/DriverStation.h" #include "HAL/HAL.h" #include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -32,19 +32,21 @@ bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName) { if (!conditionValue) { - std::stringstream locStream; + llvm::SmallString<128> locBuf; + llvm::raw_svector_ostream locStream(locBuf); locStream << funcName << " ["; llvm::SmallString<128> fileTemp; locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]"; - std::stringstream errorStream; + llvm::SmallString<128> errorBuf; + llvm::raw_svector_ostream errorStream(errorBuf); errorStream << "Assertion \"" << conditionText << "\" "; if (!message.empty()) { - errorStream << "failed: " << message << std::endl; + errorStream << "failed: " << message << "\n"; } else { - errorStream << "failed." << std::endl; + errorStream << "failed.\n"; } std::string stack = GetStackTrace(2); @@ -68,20 +70,22 @@ void wpi_assertEqual_common_impl(llvm::StringRef valueA, llvm::StringRef valueB, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName) { - std::stringstream locStream; + llvm::SmallString<128> locBuf; + llvm::raw_svector_ostream locStream(locBuf); locStream << funcName << " ["; llvm::SmallString<128> fileTemp; locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]"; - std::stringstream errorStream; + llvm::SmallString<128> errorBuf; + llvm::raw_svector_ostream errorStream(errorBuf); errorStream << "Assertion \"" << valueA << " " << equalityType << " " << valueB << "\" "; if (!message.empty()) { - errorStream << "failed: " << message << std::endl; + errorStream << "failed: " << message << "\n"; } else { - errorStream << "failed." << std::endl; + errorStream << "failed.\n"; } std::string trace = GetStackTrace(3); @@ -217,12 +221,13 @@ std::string GetStackTrace(int offset) { void* stackTrace[128]; int stackSize = backtrace(stackTrace, 128); char** mangledSymbols = backtrace_symbols(stackTrace, stackSize); - std::stringstream trace; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream trace(buf); for (int i = offset; i < stackSize; i++) { // Only print recursive functions once in a row. if (i == 0 || stackTrace[i] != stackTrace[i - 1]) { - trace << "\tat " << demangle(mangledSymbols[i]) << std::endl; + trace << "\tat " << demangle(mangledSymbols[i]) << "\n"; } } diff --git a/wpilibc/shared/src/Error.cpp b/wpilibc/shared/src/Error.cpp index b853b5046c..3feed2702e 100644 --- a/wpilibc/shared/src/Error.cpp +++ b/wpilibc/shared/src/Error.cpp @@ -7,11 +7,11 @@ #include "Error.h" -#include - #include "DriverStation.h" #include "Timer.h" #include "Utility.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -64,7 +64,8 @@ void Error::Set(Code code, llvm::StringRef contextMessage, } void Error::Report() { - std::stringstream locStream; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream locStream(buf); locStream << m_function << " ["; #if defined(_WIN32) diff --git a/wpilibc/shared/src/ErrorBase.cpp b/wpilibc/shared/src/ErrorBase.cpp index 36141e4227..5cfcb04aef 100644 --- a/wpilibc/shared/src/ErrorBase.cpp +++ b/wpilibc/shared/src/ErrorBase.cpp @@ -15,6 +15,8 @@ #define WPI_ERRORS_DEFINE_STRINGS #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -83,7 +85,8 @@ void ErrorBase::SetImaqError(int success, llvm::StringRef contextMessage, int lineNumber) const { // If there was an error if (success <= 0) { - std::stringstream err; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream err(buf); err << success << ": " << contextMessage; // Set the current error information for this object. diff --git a/wpilibc/shared/src/LiveWindow/LiveWindow.cpp b/wpilibc/shared/src/LiveWindow/LiveWindow.cpp index 1328545744..91c6523b94 100644 --- a/wpilibc/shared/src/LiveWindow/LiveWindow.cpp +++ b/wpilibc/shared/src/LiveWindow/LiveWindow.cpp @@ -8,8 +8,9 @@ #include "LiveWindow/LiveWindow.h" #include -#include +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" #include "networktables/NetworkTable.h" using namespace frc; @@ -154,7 +155,8 @@ void LiveWindow::AddActuator(const std::string& subsystem, */ void LiveWindow::AddSensor(std::string type, int channel, LiveWindowSendable* component) { - std::ostringstream oss; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss(buf); oss << type << "[" << channel << "]"; AddSensor("Ungrouped", oss.str(), component); std::shared_ptr component_stl( @@ -169,7 +171,8 @@ void LiveWindow::AddSensor(std::string type, int channel, */ void LiveWindow::AddActuator(std::string type, int channel, LiveWindowSendable* component) { - std::ostringstream oss; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss(buf); oss << type << "[" << channel << "]"; AddActuator("Ungrouped", oss.str(), std::shared_ptr(component, @@ -181,7 +184,8 @@ void LiveWindow::AddActuator(std::string type, int channel, */ void LiveWindow::AddActuator(std::string type, int module, int channel, LiveWindowSendable* component) { - std::ostringstream oss; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss(buf); oss << type << "[" << module << "," << channel << "]"; AddActuator("Ungrouped", oss.str(), std::shared_ptr(component, diff --git a/wpilibc/sim/include/MotorSafety.h b/wpilibc/sim/include/MotorSafety.h index 27c938cd9d..d78c310209 100644 --- a/wpilibc/sim/include/MotorSafety.h +++ b/wpilibc/sim/include/MotorSafety.h @@ -9,7 +9,7 @@ #define DEFAULT_SAFETY_EXPIRATION 0.1 -#include +#include "llvm/raw_ostream.h" namespace frc { @@ -21,7 +21,7 @@ class MotorSafety { virtual void StopMotor() = 0; virtual void SetSafetyEnabled(bool enabled) = 0; virtual bool IsSafetyEnabled() const = 0; - virtual void GetDescription(std::ostringstream& desc) const = 0; + virtual void GetDescription(llvm::raw_ostream& desc) const = 0; }; } // namespace frc diff --git a/wpilibc/sim/include/Relay.h b/wpilibc/sim/include/Relay.h index 19ddd7d9a1..f8b640f848 100644 --- a/wpilibc/sim/include/Relay.h +++ b/wpilibc/sim/include/Relay.h @@ -13,6 +13,7 @@ #include "LiveWindow/LiveWindowSendable.h" #include "MotorSafety.h" #include "SensorBase.h" +#include "llvm/raw_ostream.h" #include "simulation/SimContinuousOutput.h" #include "tables/ITable.h" #include "tables/ITableListener.h" @@ -55,7 +56,7 @@ class Relay : public MotorSafety, void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(std::ostringstream& desc) const override; + void GetDescription(llvm::raw_ostream& desc) const override; void ValueChanged(ITable* source, llvm::StringRef key, std::shared_ptr value, bool isNew) override; diff --git a/wpilibc/sim/include/RobotDrive.h b/wpilibc/sim/include/RobotDrive.h index de4306ad87..2f892d1870 100644 --- a/wpilibc/sim/include/RobotDrive.h +++ b/wpilibc/sim/include/RobotDrive.h @@ -14,6 +14,7 @@ #include "ErrorBase.h" #include "MotorSafety.h" #include "MotorSafetyHelper.h" +#include "llvm/raw_ostream.h" namespace frc { @@ -97,7 +98,7 @@ class RobotDrive : public MotorSafety, public ErrorBase { void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(std::ostringstream& desc) const override; + void GetDescription(llvm::raw_ostream& desc) const override; protected: void InitRobotDrive(); diff --git a/wpilibc/sim/include/SafePWM.h b/wpilibc/sim/include/SafePWM.h index 91eaa8e54c..108f688307 100644 --- a/wpilibc/sim/include/SafePWM.h +++ b/wpilibc/sim/include/SafePWM.h @@ -12,6 +12,7 @@ #include "MotorSafety.h" #include "MotorSafetyHelper.h" #include "PWM.h" +#include "llvm/raw_ostream.h" namespace frc { @@ -34,7 +35,7 @@ class SafePWM : public PWM, public MotorSafety { void StopMotor(); bool IsSafetyEnabled() const; void SetSafetyEnabled(bool enabled); - void GetDescription(std::ostringstream& desc) const; + void GetDescription(llvm::raw_ostream& desc) const; virtual void SetSpeed(double speed); diff --git a/wpilibc/sim/src/AnalogGyro.cpp b/wpilibc/sim/src/AnalogGyro.cpp index 77b231c652..1d697a84ae 100644 --- a/wpilibc/sim/src/AnalogGyro.cpp +++ b/wpilibc/sim/src/AnalogGyro.cpp @@ -7,11 +7,11 @@ #include "AnalogGyro.h" -#include - #include "LiveWindow/LiveWindow.h" #include "Timer.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -34,9 +34,10 @@ const double AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007; void AnalogGyro::InitAnalogGyro(int channel) { SetPIDSourceType(PIDSourceType::kDisplacement); - std::stringstream ss; - ss << "analog/" << channel; - impl = new SimGyro(ss.str()); + llvm::SmallString<128> buf; + llvm::raw_svector_ostream oss(buf); + oss << "analog/" << channel; + impl = new SimGyro(oss.str()); LiveWindow::GetInstance()->AddSensor("AnalogGyro", channel, this); } diff --git a/wpilibc/sim/src/AnalogInput.cpp b/wpilibc/sim/src/AnalogInput.cpp index 0c00b6e7b4..77191552d5 100644 --- a/wpilibc/sim/src/AnalogInput.cpp +++ b/wpilibc/sim/src/AnalogInput.cpp @@ -7,10 +7,10 @@ #include "AnalogInput.h" -#include - #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -20,9 +20,10 @@ using namespace frc; * @param channel The channel number to represent. */ AnalogInput::AnalogInput(int channel) : m_channel(channel) { - std::stringstream ss; - ss << "analog/" << channel; - m_impl = new SimFloatInput(ss.str()); + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); + oss << "analog/" << channel; + m_impl = new SimFloatInput(oss.str()); LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this); } diff --git a/wpilibc/sim/src/DigitalInput.cpp b/wpilibc/sim/src/DigitalInput.cpp index a560761b6f..4123d615c7 100644 --- a/wpilibc/sim/src/DigitalInput.cpp +++ b/wpilibc/sim/src/DigitalInput.cpp @@ -20,9 +20,9 @@ using namespace frc; * @param channel The digital channel (1..14). */ DigitalInput::DigitalInput(int channel) : m_channel(channel) { - std::stringstream ss; - ss << "dio/" << channel; - m_impl = new SimDigitalInput(ss.str()); + std::ostringstream oss; + oss << "dio/" << channel; + m_impl = new SimDigitalInput(oss.str()); } /** diff --git a/wpilibc/sim/src/DoubleSolenoid.cpp b/wpilibc/sim/src/DoubleSolenoid.cpp index 1607dc8ff9..7ca3c273c5 100644 --- a/wpilibc/sim/src/DoubleSolenoid.cpp +++ b/wpilibc/sim/src/DoubleSolenoid.cpp @@ -9,6 +9,8 @@ #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -37,10 +39,11 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel, forwardChannel = channel; m_reversed = true; } - std::stringstream ss; - ss << "pneumatic/" << moduleNumber << "/" << forwardChannel << "/" - << moduleNumber << "/" << reverseChannel; - m_impl = new SimContinuousOutput(ss.str()); + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); + oss << "pneumatic/" << moduleNumber << "/" << forwardChannel << "/" + << moduleNumber << "/" << reverseChannel; + m_impl = new SimContinuousOutput(oss.str()); LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber, forwardChannel, this); diff --git a/wpilibc/sim/src/Encoder.cpp b/wpilibc/sim/src/Encoder.cpp index cef4bef331..8f1d5dd4fe 100644 --- a/wpilibc/sim/src/Encoder.cpp +++ b/wpilibc/sim/src/Encoder.cpp @@ -7,10 +7,10 @@ #include "Encoder.h" -#include - #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -52,9 +52,10 @@ void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, } else { m_reverseDirection = reverseDirection; } - std::stringstream ss; - ss << "dio/" << channelA << "/" << channelB; - impl = new SimEncoder(ss.str()); + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); + oss << "dio/" << channelA << "/" << channelB; + impl = new SimEncoder(oss.str()); impl->Start(); } diff --git a/wpilibc/sim/src/MotorSafetyHelper.cpp b/wpilibc/sim/src/MotorSafetyHelper.cpp index 83604d941f..be8a695c15 100644 --- a/wpilibc/sim/src/MotorSafetyHelper.cpp +++ b/wpilibc/sim/src/MotorSafetyHelper.cpp @@ -7,12 +7,12 @@ #include "MotorSafetyHelper.h" -#include - #include "DriverStation.h" #include "MotorSafety.h" #include "Timer.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -100,10 +100,11 @@ void MotorSafetyHelper::Check() { std::lock_guard sync(m_syncMutex); if (m_stopTime < Timer::GetFPGATimestamp()) { - std::ostringstream desc; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream desc(buf); m_safeObject->GetDescription(desc); desc << "... Output not updated often enough."; - wpi_setWPIErrorWithContext(Timeout, desc.str().c_str()); + wpi_setWPIErrorWithContext(Timeout, desc.str()); m_safeObject->StopMotor(); } } diff --git a/wpilibc/sim/src/PWM.cpp b/wpilibc/sim/src/PWM.cpp index efdaae74a3..9c3f4342ee 100644 --- a/wpilibc/sim/src/PWM.cpp +++ b/wpilibc/sim/src/PWM.cpp @@ -7,10 +7,10 @@ #include "PWM.h" -#include - #include "Utility.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -30,16 +30,17 @@ const int PWM::kPwmDisabled = 0; * port */ PWM::PWM(int channel) { - std::stringstream ss; + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); if (!CheckPWMChannel(channel)) { - ss << "PWM Channel " << channel; - wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str()); + oss << "PWM Channel " << channel; + wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, oss.str()); return; } - ss << "pwm/" << channel; - impl = new SimContinuousOutput(ss.str()); + oss << "pwm/" << channel; + impl = new SimContinuousOutput(oss.str()); m_channel = channel; m_eliminateDeadband = false; diff --git a/wpilibc/sim/src/Relay.cpp b/wpilibc/sim/src/Relay.cpp index 898612a317..a44786fa67 100644 --- a/wpilibc/sim/src/Relay.cpp +++ b/wpilibc/sim/src/Relay.cpp @@ -7,11 +7,10 @@ #include "Relay.h" -#include - #include "LiveWindow/LiveWindow.h" #include "MotorSafetyHelper.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" using namespace frc; @@ -26,21 +25,22 @@ using namespace frc; */ Relay::Relay(int channel, Relay::Direction direction) : m_channel(channel), m_direction(direction) { - std::stringstream ss; + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); if (!SensorBase::CheckRelayChannel(m_channel)) { - ss << "Relay Channel " << m_channel; - wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str()); + oss << "Relay Channel " << m_channel; + wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, oss.str()); return; } m_safetyHelper = std::make_unique(this); m_safetyHelper->SetSafetyEnabled(false); - ss << "relay/" << m_channel; - impl = new SimContinuousOutput(ss.str()); // TODO: Allow two different relays - // (targetting the different halves - // of a relay) to be combined to - // control one motor. + oss << "relay/" << m_channel; + + // TODO: Allow two different relays (targetting the different halves of a + // relay) to be combined to control one motor. + impl = new SimContinuousOutput(oss.str()); LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this); go_pos = go_neg = false; } @@ -194,7 +194,7 @@ bool Relay::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void Relay::GetDescription(std::ostringstream& desc) const { +void Relay::GetDescription(llvm::raw_ostream& desc) const { desc << "Relay " << GetChannel(); } diff --git a/wpilibc/sim/src/RobotDrive.cpp b/wpilibc/sim/src/RobotDrive.cpp index cdcc994018..59f26bd538 100644 --- a/wpilibc/sim/src/RobotDrive.cpp +++ b/wpilibc/sim/src/RobotDrive.cpp @@ -715,7 +715,7 @@ void RobotDrive::SetSafetyEnabled(bool enabled) { // FIXME: m_safetyHelper->SetSafetyEnabled(enabled); } -void RobotDrive::GetDescription(std::ostringstream& desc) const { +void RobotDrive::GetDescription(llvm::raw_ostream& desc) const { desc << "RobotDrive"; } diff --git a/wpilibc/sim/src/SafePWM.cpp b/wpilibc/sim/src/SafePWM.cpp index 4e42958f32..3217784041 100644 --- a/wpilibc/sim/src/SafePWM.cpp +++ b/wpilibc/sim/src/SafePWM.cpp @@ -8,7 +8,6 @@ #include "SafePWM.h" #include -#include using namespace frc; @@ -76,7 +75,7 @@ bool SafePWM::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void SafePWM::GetDescription(std::ostringstream& desc) const { +void SafePWM::GetDescription(llvm::raw_ostream& desc) const { desc << "PWM " << GetChannel(); } diff --git a/wpilibc/sim/src/Solenoid.cpp b/wpilibc/sim/src/Solenoid.cpp index ef19ffba9a..2ddb4bcf4c 100644 --- a/wpilibc/sim/src/Solenoid.cpp +++ b/wpilibc/sim/src/Solenoid.cpp @@ -7,10 +7,10 @@ #include "Solenoid.h" -#include - #include "LiveWindow/LiveWindow.h" #include "WPIErrors.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" #include "simulation/simTime.h" using namespace frc; @@ -29,9 +29,10 @@ Solenoid::Solenoid(int channel) : Solenoid(1, channel) {} * @param channel The channel on the solenoid module to control (1..8). */ Solenoid::Solenoid(int moduleNumber, int channel) { - std::stringstream ss; - ss << "pneumatic/" << moduleNumber << "/" << channel; - m_impl = new SimContinuousOutput(ss.str()); + llvm::SmallString<32> buf; + llvm::raw_svector_ostream oss(buf); + oss << "pneumatic/" << moduleNumber << "/" << channel; + m_impl = new SimContinuousOutput(oss.str()); LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel, this); diff --git a/wpilibc/sim/src/Utility.cpp b/wpilibc/sim/src/Utility.cpp index 1f386f9818..390e658d5d 100644 --- a/wpilibc/sim/src/Utility.cpp +++ b/wpilibc/sim/src/Utility.cpp @@ -15,10 +15,10 @@ #include #include #include -#include #include "Timer.h" #include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" #include "simulation/simTime.h" using namespace frc; @@ -61,7 +61,8 @@ bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName) { if (!conditionValue) { - std::stringstream errorStream; + llvm::SmallString<1024> errorBuf; + llvm::raw_svector_ostream errorStream(errorBuf); errorStream << "Assertion \"" << conditionText << "\" "; errorStream << "on line " << lineNumber << " "; @@ -70,9 +71,9 @@ bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText, errorStream << "of " << basename(fileName.c_str(fileTemp)) << " "; if (!message.empty()) { - errorStream << "failed: " << message << std::endl; + errorStream << "failed: " << message << "\n"; } else { - errorStream << "failed." << std::endl; + errorStream << "failed.\n"; } // Print to console and send to remote dashboard @@ -94,7 +95,8 @@ void wpi_assertEqual_common_impl(int valueA, int valueB, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName) { // Error string buffer - std::stringstream error; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream error(buf); // If an error message was specified, include it // Build error string @@ -192,12 +194,13 @@ std::string GetStackTrace(int offset) { void* stackTrace[128]; int stackSize = backtrace(stackTrace, 128); char** mangledSymbols = backtrace_symbols(stackTrace, stackSize); - std::stringstream trace; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream trace(buf); for (int i = offset; i < stackSize; i++) { // Only print recursive functions once in a row. if (i == 0 || stackTrace[i] != stackTrace[i - 1]) { - trace << "\tat " << demangle(mangledSymbols[i]) << std::endl; + trace << "\tat " << demangle(mangledSymbols[i]) << "\n"; } } diff --git a/wpilibj/src/athena/cpp/lib/CANJNI.cpp b/wpilibj/src/athena/cpp/lib/CANJNI.cpp index 94a381198a..2a7ec77867 100644 --- a/wpilibj/src/athena/cpp/lib/CANJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/CANJNI.cpp @@ -7,13 +7,14 @@ #include #include -#include "HAL/cpp/Log.h" - -#include "edu_wpi_first_wpilibj_can_CANJNI.h" #include "FRC_NetworkCommunication/CANSessionMux.h" #include "HAL/CAN.h" +#include "HAL/cpp/Log.h" #include "HALUtil.h" +#include "edu_wpi_first_wpilibj_can_CANJNI.h" +#include "llvm/SmallString.h" +#include "llvm/raw_ostream.h" using namespace frc; @@ -44,14 +45,15 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxSendMessage( (uint8_t *)(data ? env->GetDirectBufferAddress(data) : 0); uint8_t dataSize = (uint8_t)(data ? env->GetDirectBufferCapacity(data) : 0); - CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << messageID; + CANJNI_LOG(logDEBUG) << "Message ID "; + CANJNI_LOG(logDEBUG).write_hex(messageID); if (logDEBUG <= canJNILogLevel) { if (dataBuffer) { - std::ostringstream str; - str << std::setfill('0') << std::hex; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream str(buf); for (int32_t i = 0; i < dataSize; i++) { - str << std::setw(2) << (int)dataBuffer[i] << ' '; + str.write_hex(dataBuffer[i]) << ' '; } Log().Get(logDEBUG) << "Data: " << str.str(); @@ -93,13 +95,20 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage( FRC_NetworkCommunication_CANSessionMux_receiveMessage( messageIDPtr, messageIDMask, buffer, &dataSize, timeStampPtr, &status); - CANJNI_LOG(logDEBUG) << "Message ID " << std::hex << *messageIDPtr; + CANJNI_LOG(logDEBUG) << "Message ID "; + CANJNI_LOG(logDEBUG).write_hex(*messageIDPtr); if (logDEBUG <= canJNILogLevel) { - std::ostringstream str; - str << std::setfill('0') << std::hex; + llvm::SmallString<128> buf; + llvm::raw_svector_ostream str(buf); + for (int32_t i = 0; i < dataSize; i++) { - str << std::setw(2) << (int)buffer[i] << ' '; + // Pad one-digit data with a zero + if (buffer[i] <= 16) { + str << '0'; + } + + str.write_hex(buffer[i]) << ' '; } Log().Get(logDEBUG) << "Data: " << str.str(); diff --git a/wpilibj/src/athena/cpp/lib/HALUtil.cpp b/wpilibj/src/athena/cpp/lib/HALUtil.cpp index a06daeb8c8..5ad1e53293 100644 --- a/wpilibj/src/athena/cpp/lib/HALUtil.cpp +++ b/wpilibj/src/athena/cpp/lib/HALUtil.cpp @@ -59,20 +59,21 @@ namespace frc { void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange, int32_t requestedValue, int32_t status) { const char *message = HAL_GetErrorMessage(status); - char *buf = new char[strlen(message) + 100]; - sprintf(buf, - " Code: $%d. %s, Minimum Value: %d, Maximum Value: %d, Requested Value: %d", - status, message, minRange, maxRange, requestedValue); - allocationExCls.Throw(env, buf); - delete[] buf; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream oss(buf); + oss << " Code: " << status << ". " << message << ", Minimum Value: " + << minRange << ", Maximum Value: " << maxRange << ", Requested Value: " + << requestedValue; + env->ThrowNew(allocationExCls, buf.c_str()); + allocationExCls.Throw(env, buf.c_str()); } void ThrowHalHandleException(JNIEnv *env, int32_t status) { const char *message = HAL_GetErrorMessage(status); - char *buf = new char[strlen(message) + 30]; - sprintf(buf, " Code: $%d. %s", status, message); - halHandleExCls.Throw(env, buf); - delete[] buf; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream oss(buf); + oss << " Code: " << status << ". " << message; + halHandleExCls.Throw(env, buf.c_str()); } constexpr const char wpilibjPrefix[] = "edu.wpi.first.wpilibj"; @@ -84,10 +85,10 @@ void ReportError(JNIEnv *env, int32_t status, bool do_throw) { } const char *message = HAL_GetErrorMessage(status); if (do_throw && status < 0) { - char *buf = new char[strlen(message) + 30]; - sprintf(buf, " Code: %d. %s", status, message); - runtimeExCls.Throw(env, buf); - delete[] buf; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream oss(buf); + oss << " Code: " << status << ". " << message; + runtimeExCls.Throw(env, buf.c_str()); } else { std::string func; auto stack = GetJavaStackTrace(env, &func); @@ -107,10 +108,10 @@ void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange, ThrowHalHandleException(env, status); } const char *message = HAL_GetErrorMessage(status); - char *buf = new char[strlen(message) + 30]; - sprintf(buf, " Code: %d. %s", status, message); - runtimeExCls.Throw(env, buf); - delete[] buf; + llvm::SmallString<1024> buf; + llvm::raw_svector_ostream oss(buf); + oss << " Code: " << status << ". " << message; + runtimeExCls.Throw(env, buf.c_str()); } void ReportCANError(JNIEnv *env, int32_t status, int message_id) { @@ -143,9 +144,10 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { } case ERR_CANSessionMux_NotAllowed: case kRIOStatusFeatureNotSupported: { - char buf[100]; - sprintf(buf, "MessageID = %d", message_id); - canMessageNotAllowedExCls.Throw(env, buf); + llvm::SmallString<100> buf; + llvm::raw_svector_ostream oss(buf); + oss << "MessageID = " << message_id; + canMessageNotAllowedExCls.Throw(env, buf.c_str()); break; } case ERR_CANSessionMux_NotInitialized: @@ -160,9 +162,10 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { break; } default: { - char buf[100]; - sprintf(buf, "Fatal status code detected: %d", status); - uncleanStatusExCls.Throw(env, buf); + llvm::SmallString<100> buf; + llvm::raw_svector_ostream oss(buf); + oss << "Fatal status code detected: " << status; + uncleanStatusExCls.Throw(env, buf.c_str()); break; } }