This commit is contained in:
John
2023-11-04 09:31:08 +01:00
parent 607fc00c0e
commit 077d09b620
13 changed files with 38 additions and 33 deletions
-2
View File
@@ -31,8 +31,6 @@
namespace ebusd {
using std::dec;
bool check(int code, const char* method) {
if (code == MOSQ_ERR_SUCCESS) {
+1 -1
View File
@@ -954,7 +954,7 @@ void MqttHandler::run() {
auto vl = (dynamic_cast<const ValueListDataField*>(field))->getList();
string entryFormat = values["field_values-entry"];
string::size_type pos = -1;
while ((pos = entryFormat.find('$', pos+1)) != std::string::npos) {
while ((pos = entryFormat.find('$', pos+1)) != string::npos) {
if (entryFormat.substr(pos+1, 4) == "text" || entryFormat.substr(pos+1, 5) == "value") {
entryFormat.replace(pos, 1, "%");
}
-1
View File
@@ -40,7 +40,6 @@ using std::hex;
using std::setfill;
using std::setw;
using std::nouppercase;
using std::cout;
ScanHelper::~ScanHelper() {
+1 -2
View File
@@ -32,7 +32,6 @@
namespace ebusd {
using std::dec;
using std::hex;
using std::setw;
/** the week day names. */
@@ -1469,7 +1468,7 @@ bool DataFieldTemplates::dump(OutputFormat outputFormat, ostream* output) const
if (outputFormat & OF_JSON) {
if (dataField->isSet()) {
if (prependFieldSeparator) {
*output << ",\n";
*output << ",\n";
}
*output << "{\"name\":\"" << dataField->getName(-1) << "\", \"sequence\": [";
dataField->dump(false, outputFormat, output);
-2
View File
@@ -34,13 +34,11 @@
namespace ebusd {
using std::dec;
using std::defaultfloat;
using std::hex;
using std::fixed;
using std::setfill;
using std::setprecision;
using std::setw;
using std::endl;
using std::isfinite;
+24 -16
View File
@@ -46,6 +46,14 @@
namespace ebusd {
using std::hex;
using std::dec;
using std::setfill;
using std::setw;
using std::setprecision;
using std::fixed;
#define MTU 1540
#ifndef POLLRDHUP
@@ -728,37 +736,37 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a
case 0x0200:
case 0x0500: // with firmware version and jumper info
case 0x0800: // with firmware version, jumper info, and bootloader version
stream << std::hex << static_cast<unsigned>(m_infoBuf[1]) // features mask
stream << hex << static_cast<unsigned>(m_infoBuf[1]) // features mask
<< "." << static_cast<unsigned>(m_infoBuf[0]); // version minor
if (m_infoLen >= 5) {
stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(m_infoBuf[2])
<< std::setw(2) << static_cast<unsigned>(m_infoBuf[3]) << "]";
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(m_infoBuf[2])
<< setw(2) << static_cast<unsigned>(m_infoBuf[3]) << "]";
}
if (m_infoLen >= 8) {
stream << "." << std::dec << static_cast<unsigned>(m_infoBuf[5]);
stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(m_infoBuf[6])
<< std::setw(2) << static_cast<unsigned>(m_infoBuf[7]) << "]";
stream << "." << dec << static_cast<unsigned>(m_infoBuf[5]);
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(m_infoBuf[6])
<< setw(2) << static_cast<unsigned>(m_infoBuf[7]) << "]";
}
m_enhInfoVersion = stream.str();
stream.str(" ");
stream << "firmware " << m_enhInfoVersion;
if (m_infoLen >= 5) {
stream << ", jumpers 0x" << std::setw(2) << static_cast<unsigned>(m_infoBuf[4]);
stream << ", jumpers 0x" << setw(2) << static_cast<unsigned>(m_infoBuf[4]);
}
stream << std::setfill(' '); // reset
stream << setfill(' '); // reset
break;
case 0x0901:
case 0x0802:
case 0x0302:
stream << (m_infoId == 1 ? "ID" : "config");
stream << std::hex << std::setfill('0');
stream << hex << setfill('0');
for (uint8_t pos = 0; pos < m_infoPos; pos++) {
stream << " " << std::setw(2) << static_cast<unsigned>(m_infoBuf[pos]);
stream << " " << setw(2) << static_cast<unsigned>(m_infoBuf[pos]);
}
if (m_infoId == 2 && (m_infoBuf[2]&0x3f) != 0x3f) {
// non-default arbitration delay
val = (m_infoBuf[2]&0x3f)*10; // steps of 10us
stream << ", arbitration delay " << std::dec << static_cast<unsigned>(val) << " us";
stream << ", arbitration delay " << dec << static_cast<unsigned>(val) << " us";
}
break;
case 0x0203:
@@ -779,7 +787,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a
case 0x0205:
stream << "bus voltage ";
if (m_infoBuf[0] | m_infoBuf[1]) {
stream << std::fixed << std::setprecision(1)
stream << fixed << setprecision(1)
<< static_cast<float>(m_infoBuf[1] / 10.0) << " V - "
<< static_cast<float>(m_infoBuf[0] / 10.0) << " V";
} else {
@@ -807,8 +815,8 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a
}
break;
default:
stream << "unknown 0x" << std::hex << std::setfill('0') << std::setw(2)
<< static_cast<unsigned>(m_infoId) << ", len " << std::dec << std::setw(0)
stream << "unknown 0x" << hex << setfill('0') << setw(2)
<< static_cast<unsigned>(m_infoId) << ", len " << dec << setw(0)
<< static_cast<unsigned>(m_infoPos);
break;
}
@@ -834,7 +842,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a
stream << "overrun";
break;
default:
stream << "unknown 0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast<unsigned>(data);
stream << "unknown 0x" << setw(2) << setfill('0') << hex << static_cast<unsigned>(data);
break;
}
string str = stream.str();
@@ -845,7 +853,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a
default:
if (m_listener != nullptr) {
ostringstream stream;
stream << "unexpected enhanced command 0x" << std::setw(2) << std::setfill('0') << std::hex
stream << "unexpected enhanced command 0x" << setw(2) << setfill('0') << hex
<< static_cast<unsigned>(cmd);
string str = stream.str();
m_listener->notifyStatus(true, str.c_str());
-2
View File
@@ -32,8 +32,6 @@ using std::ifstream;
using std::ostringstream;
using std::cout;
using std::endl;
using std::setw;
using std::dec;
istream* FileReader::openFile(const string& filename, string* errorDescription, time_t* time) {
+5 -1
View File
@@ -44,6 +44,10 @@ using std::string;
using std::map;
using std::ostream;
using std::istream;
using std::hex;
using std::dec;
using std::setw;
using std::setfill;
/** the separator character used between fields. */
#define FIELD_SEPARATOR ','
@@ -174,7 +178,7 @@ class FileReader {
* @param stream the @a ostream to write to.
*/
static void formatHash(size_t hash, ostream* stream) {
*stream << std::hex << std::setw(8) << std::setfill('0') << (hash & 0xffffffff) << std::dec << std::setw(0);
*stream << hex << setw(8) << setfill('0') << (hash & 0xffffffff) << dec << setw(0);
}
/**
+1 -1
View File
@@ -902,7 +902,7 @@ class Condition {
* Write the values part of the condition definition in JSON to the @a ostream.
* @param output the @a ostream to append to.
*/
virtual void dumpValuesJson(ostream* output) const { /* empty on top level*/ };
virtual void dumpValuesJson(ostream* output) const { /* empty on top level*/ }
/**
* Combine this condition with another instance using a logical and.
+1 -1
View File
@@ -499,7 +499,7 @@ bool StringReplacers::set(const string& key, const string& value, bool removeRep
}
void StringReplacers::set(const string& key, int value) {
std::ostringstream str;
ostringstream str;
str << static_cast<signed>(value);
m_constants[key] = str.str();
}
+1 -1
View File
@@ -162,7 +162,7 @@ class StringReplacer {
* the number is negative for plain strings, the index to @a knownFieldNames for a known field, or the size of
* @a knownFieldNames for an unknown field.
*/
vector<std::pair<string, int>> m_parts;
vector<pair<string, int>> m_parts;
/** true when the complete result is supposed to be empty when at least one referenced variable
* is empty or not defined. */
+2 -1
View File
@@ -35,7 +35,8 @@ enum ArgFlag {
typedef struct argDef {
const char* name; //!< the (long) name of the argument, or nullptr for a group header or positional
int key; //!< the argument key, also used as short name if alphabetic or the question mark
const char* valueName; //!< the optional argument value name, or nullptr for group header or argument without value name
// the optional argument value name, or nullptr for group header or argument without value name
const char* valueName;
int flags; //!< flags for the argument, bit combination of @a ArgFlag
const char* help; //!< help text (mandatory)
} argDef;
+2 -2
View File
@@ -33,7 +33,6 @@ namespace ebusd {
using std::string;
using std::ostringstream;
using std::dec;
using std::hex;
#ifdef HAVE_SSL
@@ -434,7 +433,8 @@ void HttpClient::disconnect() {
}
}
bool HttpClient::get(const string& uri, const string& body, string* response, bool* repeatable, time_t* time, bool* jsonString) {
bool HttpClient::get(const string& uri, const string& body, string* response, bool* repeatable,
time_t* time, bool* jsonString) {
return request("GET", uri, body, response, repeatable, time, jsonString);
}