use nullptr instead of NULL
This commit is contained in:
@@ -66,7 +66,7 @@ result_t TemParamDataType::readSymbols(size_t offset, size_t length, const Symbo
|
||||
if (outputFormat & OF_JSON) {
|
||||
*output << "null";
|
||||
} else {
|
||||
*output << NULL_VALUE;
|
||||
*output << nullptr_VALUE;
|
||||
}
|
||||
return RESULT_OK;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ result_t TemParamDataType::writeSymbols(const size_t offset, const size_t length
|
||||
unsigned int value;
|
||||
unsigned int grp, num;
|
||||
|
||||
if (input->str() == NULL_VALUE) {
|
||||
if (input->str() == nullptr_VALUE) {
|
||||
value = m_replacement; // replacement value
|
||||
} else {
|
||||
string token;
|
||||
@@ -102,24 +102,24 @@ result_t TemParamDataType::writeSymbols(const size_t offset, const size_t length
|
||||
return RESULT_ERR_EOF; // incomplete
|
||||
}
|
||||
const char* str = token.c_str();
|
||||
if (str == NULL || *str == 0) {
|
||||
if (str == nullptr || *str == 0) {
|
||||
return RESULT_ERR_EOF; // input too short
|
||||
}
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
grp = (unsigned int)strtoul(str, &strEnd, 10);
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
|
||||
if (strEnd == nullptr || strEnd == str || *strEnd != 0) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
if (input->eof() || !getline(*input, token, '-')) {
|
||||
return RESULT_ERR_EOF; // incomplete
|
||||
}
|
||||
str = token.c_str();
|
||||
if (str == NULL || *str == 0) {
|
||||
if (str == nullptr || *str == 0) {
|
||||
return RESULT_ERR_EOF; // input too short
|
||||
}
|
||||
strEnd = NULL;
|
||||
strEnd = nullptr;
|
||||
num = (unsigned int)strtoul(str, &strEnd, 10);
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
|
||||
if (strEnd == nullptr || strEnd == str || *strEnd != 0) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
if (grp > 0x1f || num > 0x7f) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class TemParamDataType : public NumberDataType {
|
||||
* @param id the type identifier.
|
||||
*/
|
||||
explicit TemParamDataType(const string& id)
|
||||
: NumberDataType(id, 16, 0, 0xffff, 0, 0xffff, 0, NULL) {}
|
||||
: NumberDataType(id, 16, 0, 0xffff, 0, 0xffff, 0, nullptr) {}
|
||||
|
||||
// @copydoc
|
||||
result_t derive(int divisor, size_t bitCount, const NumberDataType** derived) const override;
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestReader : public MappedFileReader {
|
||||
public:
|
||||
TestReader(DataFieldTemplates* templates, bool isSet, bool isMasterDest)
|
||||
: MappedFileReader::MappedFileReader(true), m_templates(templates), m_isSet(isSet), m_isMasterDest(isMasterDest),
|
||||
m_fields(NULL) {}
|
||||
m_fields(nullptr) {}
|
||||
result_t getFieldMap(const string& preferLanguage, vector<string>* row, string* errorDescription) const override {
|
||||
if (row->empty()) {
|
||||
row->push_back("*name");
|
||||
@@ -90,7 +90,7 @@ class TestReader : public MappedFileReader {
|
||||
|
||||
int main() {
|
||||
const DataType* type = DataTypeList::getInstance()->get("TEM_P");
|
||||
if (type == NULL) {
|
||||
if (type == nullptr) {
|
||||
cout << "datatype not registered" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -118,8 +118,8 @@ int main() {
|
||||
istringstream dummystr("#");
|
||||
string errorDescription;
|
||||
vector<string> row;
|
||||
templates->readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
const DataField* fields = NULL;
|
||||
templates->readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
const DataField* fields = nullptr;
|
||||
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
|
||||
string check[5] = checks[i];
|
||||
istringstream isstr(check[0]);
|
||||
@@ -146,9 +146,9 @@ int main() {
|
||||
bool failedWriteMatch = flags.find('W') != string::npos;
|
||||
string item;
|
||||
|
||||
if (fields != NULL) {
|
||||
if (fields != nullptr) {
|
||||
delete fields;
|
||||
fields = NULL;
|
||||
fields = nullptr;
|
||||
}
|
||||
|
||||
string errorDescription;
|
||||
@@ -156,7 +156,7 @@ int main() {
|
||||
lineNo = 0;
|
||||
dummystr.clear();
|
||||
dummystr.str("#");
|
||||
result = reader.readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = reader.readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": reader header error: " << getResultCode(result) << ", " << errorDescription
|
||||
<< endl;
|
||||
@@ -164,7 +164,7 @@ int main() {
|
||||
continue;
|
||||
}
|
||||
lineNo = baseLine + i;
|
||||
result = reader.readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = reader.readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
fields = reader.m_fields;
|
||||
|
||||
if (result != RESULT_OK) {
|
||||
@@ -172,8 +172,8 @@ int main() {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
if (fields == NULL) {
|
||||
cout << "\"" << check[0] << "\": create error: NULL" << endl;
|
||||
if (fields == nullptr) {
|
||||
cout << "\"" << check[0] << "\": create error: nullptr" << endl;
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
@@ -194,9 +194,9 @@ int main() {
|
||||
cout << " parse \"" << sstr.getStr().substr(0, 2) << "\" error: " << getResultCode(result) << endl;
|
||||
error = true;
|
||||
}
|
||||
result = fields->read(mstr, 0, false, NULL, -1, 0, -1, &output);
|
||||
result = fields->read(mstr, 0, false, nullptr, -1, 0, -1, &output);
|
||||
if (result >= RESULT_OK) {
|
||||
result = fields->read(sstr, 0, !output.str().empty(), NULL, -1, 0, -1, &output);
|
||||
result = fields->read(sstr, 0, !output.str().empty(), nullptr, -1, 0, -1, &output);
|
||||
}
|
||||
if (failedRead) {
|
||||
if (result >= RESULT_OK) {
|
||||
@@ -217,9 +217,9 @@ int main() {
|
||||
}
|
||||
|
||||
istringstream input(expectStr);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeMstr, NULL);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeMstr, nullptr);
|
||||
if (result >= RESULT_OK) {
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeSstr, NULL);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeSstr, nullptr);
|
||||
}
|
||||
if (failedWrite) {
|
||||
if (result >= RESULT_OK) {
|
||||
@@ -240,7 +240,7 @@ int main() {
|
||||
writeMstr.getStr() + " " + writeSstr.getStr());
|
||||
}
|
||||
delete fields;
|
||||
fields = NULL;
|
||||
fields = nullptr;
|
||||
}
|
||||
|
||||
delete templates;
|
||||
|
||||
+25
-25
@@ -84,7 +84,7 @@ void AttributedItem::appendJson(bool prependFieldSeparator, const string& name,
|
||||
plain = value == "false" || value == "true";
|
||||
if (!plain) {
|
||||
const char* str = value.c_str();
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
strtod(str, &strEnd);
|
||||
plain = strEnd && !*strEnd;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ result_t DataField::create(bool isWriteMessage, bool isTemplate, bool isBroadcas
|
||||
while (getline(stream, token, VALUE_SEPARATOR)) {
|
||||
FileReader::trim(&token);
|
||||
const char* str = token.c_str();
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
unsigned long id;
|
||||
if (strncasecmp(str, "0x", 2) == 0) {
|
||||
str += 2;
|
||||
@@ -277,7 +277,7 @@ result_t DataField::create(bool isWriteMessage, bool isTemplate, bool isBroadcas
|
||||
} else {
|
||||
id = strtoul(str, &strEnd, 10); // decimal
|
||||
}
|
||||
if (strEnd == NULL || strEnd == str || id > MAX_VALUE) {
|
||||
if (strEnd == nullptr || strEnd == str || id > MAX_VALUE) {
|
||||
*errorDescription = "value "+token+" in field "+formatInt(fieldIndex);
|
||||
result = RESULT_ERR_INVALID_LIST;
|
||||
break;
|
||||
@@ -307,10 +307,10 @@ result_t DataField::create(bool isWriteMessage, bool isTemplate, bool isBroadcas
|
||||
FileReader::trim(&token);
|
||||
const DataField* templ = templates->get(token);
|
||||
size_t pos = token.find(LENGTH_SEPARATOR);
|
||||
if (templ == NULL && pos != string::npos) {
|
||||
if (templ == nullptr && pos != string::npos) {
|
||||
templ = templates->get(token.substr(0, pos));
|
||||
}
|
||||
if (templ == NULL) { // basetype[:len]
|
||||
if (templ == nullptr) { // basetype[:len]
|
||||
size_t length;
|
||||
string typeName;
|
||||
if (pos == string::npos) {
|
||||
@@ -334,10 +334,10 @@ result_t DataField::create(bool isWriteMessage, bool isTemplate, bool isBroadcas
|
||||
result = RESULT_ERR_NOTFOUND;
|
||||
*errorDescription = "field type "+typeName+" in field "+formatInt(fieldIndex);
|
||||
} else {
|
||||
SingleDataField* add = NULL;
|
||||
SingleDataField* add = nullptr;
|
||||
result = SingleDataField::create(firstType ? name : "", row, dataType, partType, length, divisor,
|
||||
constantValue, verifyValue, &values, &add);
|
||||
if (add != NULL) {
|
||||
if (add != nullptr) {
|
||||
fields.push_back(add);
|
||||
} else {
|
||||
if (result == RESULT_OK) {
|
||||
@@ -509,7 +509,7 @@ result_t SingleDataField::read(const SymbolString& data, size_t offset,
|
||||
if (offset + (remainder?1:m_length) > data.getDataSize()) {
|
||||
return RESULT_ERR_INVALID_POS;
|
||||
}
|
||||
if (isIgnored() || (fieldName != NULL && m_name != fieldName) || fieldIndex > 0) {
|
||||
if (isIgnored() || (fieldName != nullptr && m_name != fieldName) || fieldIndex > 0) {
|
||||
return RESULT_EMPTY;
|
||||
}
|
||||
result_t res = m_dataType->readRawValue(offset, m_length, data, output);
|
||||
@@ -529,7 +529,7 @@ result_t SingleDataField::read(const SymbolString& data, size_t offset,
|
||||
if (offset + (remainder?1:m_length) > data.getDataSize()) {
|
||||
return RESULT_ERR_INVALID_POS;
|
||||
}
|
||||
if (isIgnored() || (fieldName != NULL && m_name != fieldName) || fieldIndex > 0) {
|
||||
if (isIgnored() || (fieldName != nullptr && m_name != fieldName) || fieldIndex > 0) {
|
||||
return RESULT_EMPTY;
|
||||
}
|
||||
bool shortFormat = outputFormat & OF_SHORT;
|
||||
@@ -636,7 +636,7 @@ result_t SingleDataField::derive(const string& name, PartType partType, int divi
|
||||
|
||||
bool SingleDataField::hasField(const char* fieldName, bool numeric) const {
|
||||
bool numericType = m_dataType->isNumeric();
|
||||
return numeric == numericType && (fieldName == NULL || fieldName == m_name);
|
||||
return numeric == numericType && (fieldName == nullptr || fieldName == m_name);
|
||||
}
|
||||
|
||||
size_t SingleDataField::getLength(PartType partType, size_t maxLength) const {
|
||||
@@ -663,7 +663,7 @@ bool SingleDataField::hasFullByteOffset(bool after) const {
|
||||
}
|
||||
|
||||
size_t SingleDataField::getCount(PartType partType, const char* fieldName) const {
|
||||
return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != NULL && m_name != fieldName)
|
||||
return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != nullptr && m_name != fieldName)
|
||||
? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ result_t ValueListDataField::readSymbols(const SymbolString& input, size_t offse
|
||||
if (outputFormat & OF_JSON) {
|
||||
*output << "null";
|
||||
} else if (value == m_dataType->getReplacement()) {
|
||||
*output << NULL_VALUE;
|
||||
*output << nullptr_VALUE;
|
||||
}
|
||||
} else if (outputFormat & OF_NUMERIC) {
|
||||
*output << setw(0) << dec << value;
|
||||
@@ -765,7 +765,7 @@ result_t ValueListDataField::readSymbols(const SymbolString& input, size_t offse
|
||||
result_t ValueListDataField::writeSymbols(size_t offset, istringstream* input,
|
||||
SymbolString* output, size_t* usedLength) const {
|
||||
const NumberDataType* numType = reinterpret_cast<const NumberDataType*>(m_dataType);
|
||||
if (isIgnored() || input->str() == NULL_VALUE) {
|
||||
if (isIgnored() || input->str() == nullptr_VALUE) {
|
||||
// replacement value
|
||||
return numType->writeRawValue(numType->getReplacement(), offset, m_length, output, usedLength);
|
||||
}
|
||||
@@ -776,10 +776,10 @@ result_t ValueListDataField::writeSymbols(size_t offset, istringstream* input,
|
||||
return numType->writeRawValue(it->first, offset, m_length, output, usedLength);
|
||||
}
|
||||
}
|
||||
char* strEnd = NULL; // fall back to raw value in input
|
||||
char* strEnd = nullptr; // fall back to raw value in input
|
||||
unsigned int value;
|
||||
value = (unsigned int)strtoul(str, &strEnd, 10);
|
||||
if (strEnd == NULL || strEnd == str || (*strEnd != 0 && *strEnd != '.')) {
|
||||
if (strEnd == nullptr || strEnd == str || (*strEnd != 0 && *strEnd != '.')) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
if (m_values.find(value) != m_values.end()) {
|
||||
@@ -851,10 +851,10 @@ result_t ConstantDataField::writeSymbols(size_t offset, istringstream* input,
|
||||
}
|
||||
|
||||
|
||||
DataFieldSet* DataFieldSet::s_identFields = NULL;
|
||||
DataFieldSet* DataFieldSet::s_identFields = nullptr;
|
||||
|
||||
DataFieldSet* DataFieldSet::getIdentFields() {
|
||||
if (s_identFields == NULL) {
|
||||
if (s_identFields == nullptr) {
|
||||
const NumberDataType* uchDataType = reinterpret_cast<const NumberDataType*>(
|
||||
DataTypeList::getInstance()->get("UCH"));
|
||||
const StringDataType* stringDataType = reinterpret_cast<const StringDataType*>(
|
||||
@@ -936,7 +936,7 @@ size_t DataFieldSet::getLength(PartType partType, size_t maxLength) const {
|
||||
}
|
||||
|
||||
size_t DataFieldSet::getCount(PartType partType, const char* fieldName) const {
|
||||
if (partType == pt_any && fieldName == NULL) {
|
||||
if (partType == pt_any && fieldName == nullptr) {
|
||||
return m_fields.size() - m_ignoredCount;
|
||||
}
|
||||
size_t count = 0;
|
||||
@@ -1027,7 +1027,7 @@ result_t DataFieldSet::read(const SymbolString& data, size_t offset,
|
||||
if (result != RESULT_EMPTY) {
|
||||
found = true;
|
||||
}
|
||||
if (findFieldIndex && !field->isIgnored() && (fieldName == NULL || fieldName == field->getName(-1))) {
|
||||
if (findFieldIndex && !field->isIgnored() && (fieldName == nullptr || fieldName == field->getName(-1))) {
|
||||
if (fieldIndex == 0) {
|
||||
if (!found) {
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
@@ -1074,7 +1074,7 @@ result_t DataFieldSet::read(const SymbolString& data, size_t offset,
|
||||
found = true;
|
||||
leadingSeparator = true;
|
||||
}
|
||||
if (findFieldIndex && !field->isIgnored() && (fieldName == NULL || fieldName == field->getName(-1))) {
|
||||
if (findFieldIndex && !field->isIgnored() && (fieldName == nullptr || fieldName == field->getName(-1))) {
|
||||
if (fieldIndex == 0) {
|
||||
if (!found) {
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
@@ -1127,7 +1127,7 @@ result_t DataFieldSet::write(char separator, size_t offset, istringstream* input
|
||||
previousFullByteOffset = field->hasFullByteOffset(true);
|
||||
}
|
||||
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = offset-baseOffset;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -1201,7 +1201,7 @@ result_t LoadableDataFieldSet::getFieldMap(const string& preferLanguage, vector<
|
||||
|
||||
result_t LoadableDataFieldSet::addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
|
||||
vector< map<string, string> >* subRows, string* errorDescription, bool replace) {
|
||||
const DataField* field = NULL;
|
||||
const DataField* field = nullptr;
|
||||
result_t result = DataField::create(false, false, false, MAX_POS, m_templates, subRows, errorDescription, &field);
|
||||
if (result != RESULT_OK) {
|
||||
return result;
|
||||
@@ -1262,7 +1262,7 @@ DataFieldTemplates::DataFieldTemplates(const DataFieldTemplates& other)
|
||||
void DataFieldTemplates::clear() {
|
||||
for (auto it : m_fieldsByName) {
|
||||
delete it.second;
|
||||
it.second = NULL;
|
||||
it.second = nullptr;
|
||||
}
|
||||
m_fieldsByName.clear();
|
||||
}
|
||||
@@ -1383,7 +1383,7 @@ result_t DataFieldTemplates::addFromFile(const string& filename, unsigned int li
|
||||
firstFieldName = name.substr(colon+1);
|
||||
name = name.substr(0, colon);
|
||||
}
|
||||
const DataField* field = NULL;
|
||||
const DataField* field = nullptr;
|
||||
if (!subRows->empty()) {
|
||||
map<string, string>::iterator it = (*subRows)[0].find("name");
|
||||
if (it == (*subRows)[0].end() || it->second.empty()) {
|
||||
@@ -1407,7 +1407,7 @@ result_t DataFieldTemplates::addFromFile(const string& filename, unsigned int li
|
||||
const DataField* DataFieldTemplates::get(const string& name) const {
|
||||
const auto ref = m_fieldsByName.find(name);
|
||||
if (ref == m_fieldsByName.end()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return ref->second;
|
||||
}
|
||||
|
||||
+13
-13
@@ -215,7 +215,7 @@ class DataField : public AttributedItem {
|
||||
* @param isTemplate true for creating a template @a DataField.
|
||||
* @param isBroadcastOrMasterDestination true if the destination bus address is @a BRODCAST or a master address.
|
||||
* @param maxFieldLength the maximum allowed length of a single field (e.g. @a MAX_POS).
|
||||
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
|
||||
* @param templates the @a DataFieldTemplates to be referenced by name, or nullptr.
|
||||
* @param rows the mapped field definition rows (may be modified).
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
* @param returnField the variable in which to store the created instance.
|
||||
@@ -258,10 +258,10 @@ class DataField : public AttributedItem {
|
||||
/**
|
||||
* Get the field count (excluding ignored fields).
|
||||
* @param partType the optional part to count, or @ pt_any.
|
||||
* @param fieldName the optional field name to count, or NULL.
|
||||
* @param fieldName the optional field name to count, or nullptr.
|
||||
* @return the field count (excluding ignored fields).
|
||||
*/
|
||||
virtual size_t getCount(PartType partType = pt_any, const char* fieldName = NULL) const = 0;
|
||||
virtual size_t getCount(PartType partType = pt_any, const char* fieldName = nullptr) const = 0;
|
||||
|
||||
/**
|
||||
* Get the specified field name.
|
||||
@@ -280,7 +280,7 @@ class DataField : public AttributedItem {
|
||||
|
||||
/**
|
||||
* Return whether the field is available.
|
||||
* @param fieldName the name of the field to find, or NULL for any.
|
||||
* @param fieldName the name of the field to find, or nullptr for any.
|
||||
* @param numeric true for a numeric field, false for a string field.
|
||||
* @return true if the field is available.
|
||||
*/
|
||||
@@ -290,7 +290,7 @@ class DataField : public AttributedItem {
|
||||
* Reads the numeric value from the @a SymbolString.
|
||||
* @param data the data @a SymbolString for reading binary data.
|
||||
* @param offset the additional offset to add for reading binary data.
|
||||
* @param fieldName the name of the field to read, or NULL for the first field.
|
||||
* @param fieldName the name of the field to read, or nullptr for the first field.
|
||||
* @param fieldIndex the optional index of the field (either named or overall), or -1.
|
||||
* @param output the variable in which to store the numeric value.
|
||||
* @return @a RESULT_OK on success,
|
||||
@@ -325,7 +325,7 @@ class DataField : public AttributedItem {
|
||||
* @param separator the separator character between multiple fields.
|
||||
* @param offset the additional offset to add for writing binary data.
|
||||
* @param data the data @a SymbolString to write binary data to.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or NULL.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t write(char separator, size_t offset, istringstream* input,
|
||||
@@ -407,7 +407,7 @@ class SingleDataField : public DataField {
|
||||
bool hasFullByteOffset(bool after) const;
|
||||
|
||||
// @copydoc
|
||||
size_t getCount(PartType partType = pt_any, const char* fieldName = NULL) const override;
|
||||
size_t getCount(PartType partType = pt_any, const char* fieldName = nullptr) const override;
|
||||
|
||||
// @copydoc
|
||||
virtual string getName(ssize_t fieldIndex) const {
|
||||
@@ -466,7 +466,7 @@ class SingleDataField : public DataField {
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
* @param offset the offset in the @a SymbolString.
|
||||
* @param output the @a SymbolString to write the binary value to.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or NULL.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t writeSymbols(size_t offset, istringstream* input,
|
||||
@@ -650,7 +650,7 @@ class DataFieldSet : public DataField {
|
||||
size_t getLength(PartType partType, size_t maxLength) const override;
|
||||
|
||||
// @copydoc
|
||||
size_t getCount(PartType partType = pt_any, const char* fieldName = NULL) const override;
|
||||
size_t getCount(PartType partType = pt_any, const char* fieldName = nullptr) const override;
|
||||
|
||||
// @copydoc
|
||||
string getName(ssize_t fieldIndex) const override;
|
||||
@@ -663,11 +663,11 @@ class DataFieldSet : public DataField {
|
||||
/**
|
||||
* Returns the @a SingleDataField at the specified index.
|
||||
* @param index the index of the @a SingleDataField to return.
|
||||
* @return the @a SingleDataField at the specified index, or NULL.
|
||||
* @return the @a SingleDataField at the specified index, or nullptr.
|
||||
*/
|
||||
const SingleDataField* operator[](size_t index) const {
|
||||
if (index >= m_fields.size()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return m_fields[index];
|
||||
}
|
||||
@@ -699,7 +699,7 @@ class DataFieldSet : public DataField {
|
||||
|
||||
|
||||
private:
|
||||
/** the @a DataFieldSet containing the ident message @a SingleDataField instances, or NULL. */
|
||||
/** the @a DataFieldSet containing the ident message @a SingleDataField instances, or nullptr. */
|
||||
static DataFieldSet* s_identFields;
|
||||
|
||||
protected:
|
||||
@@ -788,7 +788,7 @@ class DataFieldTemplates : public MappedFileReader {
|
||||
/**
|
||||
* Gets the template @a DataField instance with the specified name.
|
||||
* @param name the name of the template to get.
|
||||
* @return the template @a DataField instance, or NULL.
|
||||
* @return the template @a DataField instance, or nullptr.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
const DataField* get(const string& name) const;
|
||||
|
||||
+54
-54
@@ -142,7 +142,7 @@ result_t StringDataType::writeSymbols(size_t offset, size_t length, istringstrea
|
||||
for (size_t index = start, i = 0; i < count; index += incr, i++) {
|
||||
output->dataAt(offset + index) = (symbol_t)m_replacement; // fill up with replacement
|
||||
}
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = count;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -197,7 +197,7 @@ result_t StringDataType::writeSymbols(size_t offset, size_t length, istringstrea
|
||||
if (!remainder && i < count) {
|
||||
return RESULT_ERR_EOF; // input too short
|
||||
}
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = (index-start)*incr;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -243,13 +243,13 @@ result_t DateTimeDataType::readSymbols(size_t offset, size_t length, const Symbo
|
||||
case 2: // date only
|
||||
if (!hasFlag(REQ) && symbol == m_replacement) {
|
||||
if (i + 1 != length) {
|
||||
*output << NULL_VALUE << ".";
|
||||
*output << nullptr_VALUE << ".";
|
||||
break;
|
||||
} else if (last == m_replacement) {
|
||||
if (length == 2) { // number of days since 01.01.1900
|
||||
*output << NULL_VALUE << ".";
|
||||
*output << nullptr_VALUE << ".";
|
||||
}
|
||||
*output << NULL_VALUE;
|
||||
*output << nullptr_VALUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -282,13 +282,13 @@ result_t DateTimeDataType::readSymbols(size_t offset, size_t length, const Symbo
|
||||
case 1: // time only
|
||||
if (!hasFlag(REQ) && symbol == m_replacement) {
|
||||
if (length == 1) { // truncated time
|
||||
*output << NULL_VALUE << ":" << NULL_VALUE;
|
||||
*output << nullptr_VALUE << ":" << nullptr_VALUE;
|
||||
break;
|
||||
}
|
||||
if (i > 0) {
|
||||
*output << ":";
|
||||
}
|
||||
*output << NULL_VALUE;
|
||||
*output << nullptr_VALUE;
|
||||
break;
|
||||
}
|
||||
if (hasFlag(SPE)) { // minutes since midnight
|
||||
@@ -359,7 +359,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
for (size_t index = start, i = 0; i < count; index += incr, i++) {
|
||||
output->dataAt(offset + index) = (symbol_t)m_replacement; // fill up with replacement
|
||||
}
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = count;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -378,7 +378,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
if (input->eof() || !getline(*input, token, '.')) {
|
||||
return RESULT_ERR_EOF; // incomplete
|
||||
}
|
||||
if (!hasFlag(REQ) && token == NULL_VALUE) {
|
||||
if (!hasFlag(REQ) && token == nullptr_VALUE) {
|
||||
value = m_replacement;
|
||||
break;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
if (input->eof() || !getline(*input, token, LENGTH_SEPARATOR)) {
|
||||
return RESULT_ERR_EOF; // incomplete
|
||||
}
|
||||
if (!hasFlag(REQ) && token == NULL_VALUE) {
|
||||
if (!hasFlag(REQ) && token == nullptr_VALUE) {
|
||||
value = m_replacement;
|
||||
if (length == 1) { // truncated time
|
||||
if (i == 0) {
|
||||
@@ -493,7 +493,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
if (!remainder && i < count) {
|
||||
return RESULT_ERR_EOF; // input too short
|
||||
}
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = (index-start)*incr;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -654,7 +654,7 @@ result_t NumberDataType::readSymbols(size_t offset, size_t length, const SymbolS
|
||||
if (outputFormat & OF_JSON) {
|
||||
*output << "null";
|
||||
} else {
|
||||
*output << NULL_VALUE;
|
||||
*output << nullptr_VALUE;
|
||||
}
|
||||
return RESULT_OK;
|
||||
}
|
||||
@@ -787,7 +787,7 @@ result_t NumberDataType::writeRawValue(unsigned int value, size_t offset, size_t
|
||||
output->dataAt(offset + index) = symbol;
|
||||
}
|
||||
}
|
||||
if (usedLength != NULL) {
|
||||
if (usedLength != nullptr) {
|
||||
*usedLength = length;
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -797,15 +797,15 @@ result_t NumberDataType::writeSymbols(size_t offset, size_t length, istringstrea
|
||||
SymbolString* output, size_t* usedLength) const {
|
||||
unsigned int value;
|
||||
|
||||
if (!hasFlag(REQ) && (isIgnored() || input->str() == NULL_VALUE)) {
|
||||
if (!hasFlag(REQ) && (isIgnored() || input->str() == nullptr_VALUE)) {
|
||||
value = m_replacement; // replacement value
|
||||
} else if (input->str().empty()) {
|
||||
return RESULT_ERR_EOF; // input too short
|
||||
} else if (hasFlag(EXP)) { // IEEE 754 binary32
|
||||
const char* str = input->str().c_str();
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
double dvalue = strtod(str, &strEnd);
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
|
||||
if (strEnd == nullptr || strEnd == str || *strEnd != 0) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
if (m_divisor < 0) {
|
||||
@@ -842,7 +842,7 @@ result_t NumberDataType::writeSymbols(size_t offset, size_t length, istringstrea
|
||||
#endif
|
||||
} else {
|
||||
const char* str = input->str().c_str();
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
if (m_divisor == 1) {
|
||||
if (hasFlag(SIG)) {
|
||||
long signedValue = strtol(str, &strEnd, 10);
|
||||
@@ -854,12 +854,12 @@ result_t NumberDataType::writeSymbols(size_t offset, size_t length, istringstrea
|
||||
} else {
|
||||
value = (unsigned int)strtoul(str, &strEnd, 10);
|
||||
}
|
||||
if (strEnd == NULL || strEnd == str || (*strEnd != 0 && *strEnd != '.')) {
|
||||
if (strEnd == nullptr || strEnd == str || (*strEnd != 0 && *strEnd != '.')) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
} else {
|
||||
double dvalue = strtod(str, &strEnd);
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
|
||||
if (strEnd == nullptr || strEnd == str || *strEnd != 0) {
|
||||
return RESULT_ERR_INVALID_NUM; // invalid value
|
||||
}
|
||||
if (m_divisor < 0) {
|
||||
@@ -912,8 +912,8 @@ bool DataTypeList::s_contrib_initialized = libebus_contrib_register();
|
||||
DataTypeList::DataTypeList() {
|
||||
add(new StringDataType("STR", MAX_LEN*8, ADJ, ' ')); // >= 1 byte character string filled up with space
|
||||
// unsigned decimal in BCD, 0000 - 9999 (fixed length)
|
||||
add(new NumberDataType("PIN", 16, FIX|BCD|REV, 0xffff, 0, 0x9999, 1, NULL));
|
||||
add(new NumberDataType("UCH", 8, 0, 0xff, 0, 0xfe, 1, NULL)); // unsigned integer, 0 - 254
|
||||
add(new NumberDataType("PIN", 16, FIX|BCD|REV, 0xffff, 0, 0x9999, 1, nullptr));
|
||||
add(new NumberDataType("UCH", 8, 0, 0xff, 0, 0xfe, 1, nullptr)); // unsigned integer, 0 - 254
|
||||
add(new StringDataType("IGN", MAX_LEN*8, IGN|ADJ, 0)); // >= 1 byte ignored data
|
||||
// >= 1 byte character string filled up with 0x00 (null terminated string)
|
||||
add(new StringDataType("NTS", MAX_LEN*8, ADJ, 0));
|
||||
@@ -951,56 +951,56 @@ DataTypeList::DataTypeList() {
|
||||
add(new DateTimeDataType("TTH", 6, 0, 0, false, true, 30));
|
||||
// truncated time (only multiple of 15 minutes), 00:00 - 24:00 (minutes div 15 + hour * 4 as integer)
|
||||
add(new DateTimeDataType("TTQ", 7, 0, 0, false, true, 15));
|
||||
add(new NumberDataType("BDY", 8, DAY, 0x07, 0, 6, 1, NULL)); // weekday, "Mon" - "Sun" (0x00 - 0x06) [eBUS type]
|
||||
add(new NumberDataType("HDY", 8, DAY, 0x00, 1, 7, 1, NULL)); // weekday, "Mon" - "Sun" (0x01 - 0x07) [Vaillant type]
|
||||
add(new NumberDataType("BCD", 8, BCD, 0xff, 0, 99, 1, NULL)); // unsigned decimal in BCD, 0 - 99
|
||||
add(new NumberDataType("BCD", 16, BCD, 0xffff, 0, 9999, 1, NULL)); // unsigned decimal in BCD, 0 - 9999
|
||||
add(new NumberDataType("BCD", 24, BCD, 0xffffff, 0, 999999, 1, NULL)); // unsigned decimal in BCD, 0 - 999999
|
||||
add(new NumberDataType("BCD", 32, BCD, 0xffffffff, 0, 99999999, 1, NULL)); // unsigned decimal in BCD, 0 - 99999999
|
||||
add(new NumberDataType("HCD", 32, HCD|BCD|REQ, 0, 0, 99999999, 1, NULL)); // unsigned decimal in HCD, 0 - 99999999
|
||||
add(new NumberDataType("HCD", 8, HCD|BCD|REQ, 0, 0, 99, 1, NULL)); // unsigned decimal in HCD, 0 - 99
|
||||
add(new NumberDataType("HCD", 16, HCD|BCD|REQ, 0, 0, 9999, 1, NULL)); // unsigned decimal in HCD, 0 - 9999
|
||||
add(new NumberDataType("HCD", 24, HCD|BCD|REQ, 0, 0, 999999, 1, NULL)); // unsigned decimal in HCD, 0 - 999999
|
||||
add(new NumberDataType("SCH", 8, SIG, 0x80, 0x81, 0x7f, 1, NULL)); // signed integer, -127 - +127
|
||||
add(new NumberDataType("D1B", 8, SIG, 0x80, 0x81, 0x7f, 1, NULL)); // signed integer, -127 - +127
|
||||
add(new NumberDataType("BDY", 8, DAY, 0x07, 0, 6, 1, nullptr)); // weekday, "Mon" - "Sun" (0x00 - 0x06) [eBUS type]
|
||||
add(new NumberDataType("HDY", 8, DAY, 0x00, 1, 7, 1, nullptr)); // weekday, "Mon" - "Sun" (0x01 - 0x07) [Vaillant type]
|
||||
add(new NumberDataType("BCD", 8, BCD, 0xff, 0, 99, 1, nullptr)); // unsigned decimal in BCD, 0 - 99
|
||||
add(new NumberDataType("BCD", 16, BCD, 0xffff, 0, 9999, 1, nullptr)); // unsigned decimal in BCD, 0 - 9999
|
||||
add(new NumberDataType("BCD", 24, BCD, 0xffffff, 0, 999999, 1, nullptr)); // unsigned decimal in BCD, 0 - 999999
|
||||
add(new NumberDataType("BCD", 32, BCD, 0xffffffff, 0, 99999999, 1, nullptr)); // unsigned decimal in BCD, 0 - 99999999
|
||||
add(new NumberDataType("HCD", 32, HCD|BCD|REQ, 0, 0, 99999999, 1, nullptr)); // unsigned decimal in HCD, 0 - 99999999
|
||||
add(new NumberDataType("HCD", 8, HCD|BCD|REQ, 0, 0, 99, 1, nullptr)); // unsigned decimal in HCD, 0 - 99
|
||||
add(new NumberDataType("HCD", 16, HCD|BCD|REQ, 0, 0, 9999, 1, nullptr)); // unsigned decimal in HCD, 0 - 9999
|
||||
add(new NumberDataType("HCD", 24, HCD|BCD|REQ, 0, 0, 999999, 1, nullptr)); // unsigned decimal in HCD, 0 - 999999
|
||||
add(new NumberDataType("SCH", 8, SIG, 0x80, 0x81, 0x7f, 1, nullptr)); // signed integer, -127 - +127
|
||||
add(new NumberDataType("D1B", 8, SIG, 0x80, 0x81, 0x7f, 1, nullptr)); // signed integer, -127 - +127
|
||||
// unsigned number (fraction 1/2), 0 - 100 (0x00 - 0xc8, replacement 0xff)
|
||||
add(new NumberDataType("D1C", 8, 0, 0xff, 0x00, 0xc8, 2, NULL));
|
||||
add(new NumberDataType("D1C", 8, 0, 0xff, 0x00, 0xc8, 2, nullptr));
|
||||
// signed number (fraction 1/256), -127.99 - +127.99
|
||||
add(new NumberDataType("D2B", 16, SIG, 0x8000, 0x8001, 0x7fff, 256, NULL));
|
||||
add(new NumberDataType("D2B", 16, SIG, 0x8000, 0x8001, 0x7fff, 256, nullptr));
|
||||
// signed number (fraction 1/16), -2047.9 - +2047.9
|
||||
add(new NumberDataType("D2C", 16, SIG, 0x8000, 0x8001, 0x7fff, 16, NULL));
|
||||
add(new NumberDataType("D2C", 16, SIG, 0x8000, 0x8001, 0x7fff, 16, nullptr));
|
||||
// signed number (fraction 1/1000), -32.767 - +32.767, little endian
|
||||
add(new NumberDataType("FLT", 16, SIG, 0x8000, 0x8001, 0x7fff, 1000, NULL));
|
||||
add(new NumberDataType("FLT", 16, SIG, 0x8000, 0x8001, 0x7fff, 1000, nullptr));
|
||||
// signed number (fraction 1/1000), -32.767 - +32.767, big endian
|
||||
add(new NumberDataType("FLR", 16, SIG|REV, 0x8000, 0x8001, 0x7fff, 1000, NULL));
|
||||
add(new NumberDataType("FLR", 16, SIG|REV, 0x8000, 0x8001, 0x7fff, 1000, nullptr));
|
||||
// signed number (IEEE 754 binary32: 1 bit sign, 8 bits exponent, 23 bits significand), little endian
|
||||
add(new NumberDataType("EXP", 32, SIG|EXP, 0x7f800000, 0x00000000, 0xffffffff, 1, NULL));
|
||||
add(new NumberDataType("EXP", 32, SIG|EXP, 0x7f800000, 0x00000000, 0xffffffff, 1, nullptr));
|
||||
// signed number (IEEE 754 binary32: 1 bit sign, 8 bits exponent, 23 bits significand), big endian
|
||||
add(new NumberDataType("EXR", 32, SIG|EXP|REV, 0x7f800000, 0x00000000, 0xffffffff, 1, NULL));
|
||||
add(new NumberDataType("EXR", 32, SIG|EXP|REV, 0x7f800000, 0x00000000, 0xffffffff, 1, nullptr));
|
||||
// unsigned integer, 0 - 65534, little endian
|
||||
add(new NumberDataType("UIN", 16, 0, 0xffff, 0, 0xfffe, 1, NULL));
|
||||
add(new NumberDataType("UIN", 16, 0, 0xffff, 0, 0xfffe, 1, nullptr));
|
||||
// unsigned integer, 0 - 65534, big endian
|
||||
add(new NumberDataType("UIR", 16, REV, 0xffff, 0, 0xfffe, 1, NULL));
|
||||
add(new NumberDataType("UIR", 16, REV, 0xffff, 0, 0xfffe, 1, nullptr));
|
||||
// signed integer, -32767 - +32767, little endian
|
||||
add(new NumberDataType("SIN", 16, SIG, 0x8000, 0x8001, 0x7fff, 1, NULL));
|
||||
add(new NumberDataType("SIN", 16, SIG, 0x8000, 0x8001, 0x7fff, 1, nullptr));
|
||||
// signed integer, -32767 - +32767, big endian
|
||||
add(new NumberDataType("SIR", 16, SIG|REV, 0x8000, 0x8001, 0x7fff, 1, NULL));
|
||||
add(new NumberDataType("SIR", 16, SIG|REV, 0x8000, 0x8001, 0x7fff, 1, nullptr));
|
||||
// unsigned 3 bytes int, 0 - 16777214, little endian
|
||||
add(new NumberDataType("U3N", 24, 0, 0xffffff, 0, 0xfffffe, 1, NULL));
|
||||
add(new NumberDataType("U3N", 24, 0, 0xffffff, 0, 0xfffffe, 1, nullptr));
|
||||
// unsigned 3 bytes int, 0 - 16777214, big endian
|
||||
add(new NumberDataType("U3R", 24, REV, 0xffffff, 0, 0xfffffe, 1, NULL));
|
||||
add(new NumberDataType("U3R", 24, REV, 0xffffff, 0, 0xfffffe, 1, nullptr));
|
||||
// signed 3 bytes int, -8388607 - +8388607, little endian
|
||||
add(new NumberDataType("S3N", 24, SIG, 0x800000, 0x800001, 0xffffff, 1, NULL));
|
||||
add(new NumberDataType("S3N", 24, SIG, 0x800000, 0x800001, 0xffffff, 1, nullptr));
|
||||
// signed 3 bytes int, -8388607 - +8388607, big endian
|
||||
add(new NumberDataType("S3R", 24, SIG|REV, 0x800000, 0x800001, 0xffffff, 1, NULL));
|
||||
add(new NumberDataType("S3R", 24, SIG|REV, 0x800000, 0x800001, 0xffffff, 1, nullptr));
|
||||
// unsigned integer, 0 - 4294967294, little endian
|
||||
add(new NumberDataType("ULG", 32, 0, 0xffffffff, 0, 0xfffffffe, 1, NULL));
|
||||
add(new NumberDataType("ULG", 32, 0, 0xffffffff, 0, 0xfffffffe, 1, nullptr));
|
||||
// unsigned integer, 0 - 4294967294, big endian
|
||||
add(new NumberDataType("ULR", 32, REV, 0xffffffff, 0, 0xfffffffe, 1, NULL));
|
||||
add(new NumberDataType("ULR", 32, REV, 0xffffffff, 0, 0xfffffffe, 1, nullptr));
|
||||
// signed integer, -2147483647 - +2147483647, little endian
|
||||
add(new NumberDataType("SLG", 32, SIG, 0x80000000, 0x80000001, 0xffffffff, 1, NULL));
|
||||
add(new NumberDataType("SLG", 32, SIG, 0x80000000, 0x80000001, 0xffffffff, 1, nullptr));
|
||||
// signed integer, -2147483647 - +2147483647, big endian
|
||||
add(new NumberDataType("SLR", 32, SIG|REV, 0x80000000, 0x80000001, 0xffffffff, 1, NULL));
|
||||
add(new NumberDataType("SLR", 32, SIG|REV, 0x80000000, 0x80000001, 0xffffffff, 1, nullptr));
|
||||
add(new NumberDataType("BI0", 7, ADJ|REQ, 0, 0, 1)); // bit 0 (up to 7 bits until bit 6)
|
||||
add(new NumberDataType("BI1", 7, ADJ|REQ, 0, 1, 1)); // bit 1 (up to 7 bits until bit 7)
|
||||
add(new NumberDataType("BI2", 6, ADJ|REQ, 0, 2, 1)); // bit 2 (up to 6 bits until bit 7)
|
||||
@@ -1056,10 +1056,10 @@ const DataType* DataTypeList::get(const string& id, size_t length) const {
|
||||
}
|
||||
auto it = m_typesById.find(id);
|
||||
if (it == m_typesById.end()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (length > 0 && !it->second->isAdjustableLength()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ using std::ostringstream;
|
||||
#define LENGTH_SEPARATOR ':'
|
||||
|
||||
/** the replacement string for undefined values (in UI and CSV). */
|
||||
#define NULL_VALUE "-"
|
||||
#define nullptr_VALUE "-"
|
||||
|
||||
/** the separator character used between fields (in UI only). */
|
||||
#define UI_FIELD_SEPARATOR ';'
|
||||
@@ -134,7 +134,7 @@ enum PartType {
|
||||
/** bit flag for @a DataType: fixed width formatting. */
|
||||
#define FIX 0x20
|
||||
|
||||
/** bit flag for @a DataType: value may not be NULL. */
|
||||
/** bit flag for @a DataType: value may not be nullptr. */
|
||||
#define REQ 0x40
|
||||
|
||||
/** bit flag for @a DataType: binary representation is hex converted to decimal and interpreted as 2 digits
|
||||
@@ -256,7 +256,7 @@ class DataType {
|
||||
* @param length the number of symbols to write, or @a REMAIN_LEN.
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
* @param output the @a SymbolString to write the binary value to.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or NULL.
|
||||
* @param usedLength the variable in which to store the used length in bytes, or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t writeSymbols(size_t offset, size_t length, istringstream* input,
|
||||
@@ -399,7 +399,7 @@ class NumberDataType : public DataType {
|
||||
* @param minValue the minimum raw value.
|
||||
* @param maxValue the maximum raw value.
|
||||
* @param divisor the divisor (negative for reciprocal).
|
||||
* @param baseType the base @a NumberDataType for derived instances, or NULL.
|
||||
* @param baseType the base @a NumberDataType for derived instances, or nullptr.
|
||||
*/
|
||||
NumberDataType(const string& id, size_t bitCount, uint16_t flags, unsigned int replacement,
|
||||
unsigned int minValue, unsigned int maxValue, int divisor,
|
||||
@@ -415,10 +415,10 @@ class NumberDataType : public DataType {
|
||||
* @param replacement the replacement value (no replacement if zero).
|
||||
* @param firstBit the offset to the first bit.
|
||||
* @param divisor the divisor (negative for reciprocal).
|
||||
* @param baseType the base @a NumberDataType for derived instances, or NULL.
|
||||
* @param baseType the base @a NumberDataType for derived instances, or nullptr.
|
||||
*/
|
||||
NumberDataType(const string& id, size_t bitCount, uint16_t flags, unsigned int replacement,
|
||||
int16_t firstBit, int divisor, const NumberDataType* baseType = NULL)
|
||||
int16_t firstBit, int divisor, const NumberDataType* baseType = nullptr)
|
||||
: DataType(id, bitCount, flags|NUM, replacement), m_minValue(0), m_maxValue((1 << bitCount)-1), m_divisor(divisor),
|
||||
m_precision(0), m_firstBit(firstBit), m_baseType(baseType) {}
|
||||
|
||||
@@ -490,7 +490,7 @@ class NumberDataType : public DataType {
|
||||
* @param length the number of symbols to write, or @a REMAIN_LEN.
|
||||
* @param output the @a SymbolString to write the binary value to.
|
||||
* @param usedLength the variable in which to store the used length in bytes,
|
||||
* or NULL.
|
||||
* or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t writeRawValue(unsigned int value, size_t offset, size_t length,
|
||||
@@ -568,7 +568,7 @@ class DataTypeList {
|
||||
* Gets the @a DataType instance with the specified ID.
|
||||
* @param id the ID string (excluding optional length suffix).
|
||||
* @param length the length in bytes, or 0 for default.
|
||||
* @return the @a DataType instance, or NULL if not available.
|
||||
* @return the @a DataType instance, or nullptr if not available.
|
||||
* Note: the caller may not free the instance.
|
||||
*/
|
||||
const DataType* get(const string& id, size_t length = 0) const;
|
||||
|
||||
+10
-10
@@ -52,7 +52,7 @@ Device::~Device() {
|
||||
}
|
||||
|
||||
Device* Device::create(const char* name, bool checkDevice, bool readOnly, bool initialSend) {
|
||||
if (strchr(name, '/') == NULL && strchr(name, ':') != NULL) {
|
||||
if (strchr(name, '/') == nullptr && strchr(name, ':') != nullptr) {
|
||||
char* in = strdup(name);
|
||||
bool udp = false;
|
||||
char* addrpos = in;
|
||||
@@ -61,24 +61,24 @@ Device* Device::create(const char* name, bool checkDevice, bool readOnly, bool i
|
||||
addrpos += 4;
|
||||
portpos = strchr(addrpos, ':');
|
||||
}
|
||||
if (portpos == NULL) {
|
||||
if (portpos == nullptr) {
|
||||
free(in);
|
||||
return NULL; // invalid protocol or missing port
|
||||
return nullptr; // invalid protocol or missing port
|
||||
}
|
||||
result_t result = RESULT_OK;
|
||||
unsigned int port = parseInt(portpos+1, 10, 1, 65535, &result);
|
||||
if (result != RESULT_OK) {
|
||||
free(in);
|
||||
return NULL; // invalid port
|
||||
return nullptr; // invalid port
|
||||
}
|
||||
struct sockaddr_in address;
|
||||
memset(reinterpret_cast<char*>(&address), 0, sizeof(address));
|
||||
*portpos = 0;
|
||||
if (inet_aton(addrpos, &address.sin_addr) == 0) {
|
||||
struct hostent* h = gethostbyname(addrpos);
|
||||
if (h == NULL) {
|
||||
if (h == nullptr) {
|
||||
free(in);
|
||||
return NULL; // invalid host
|
||||
return nullptr; // invalid host
|
||||
}
|
||||
memcpy(&address.sin_addr, h->h_addr_list[0], h->h_length);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ result_t Device::send(symbol_t value) {
|
||||
if (m_readOnly || write(value) != 1) {
|
||||
return RESULT_ERR_SEND;
|
||||
}
|
||||
if (m_listener != NULL) {
|
||||
if (m_listener != nullptr) {
|
||||
m_listener->notifyDeviceData(value, false);
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -140,7 +140,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
|
||||
fds[0].fd = m_fd;
|
||||
fds[0].events = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
|
||||
ret = ppoll(fds, nfds, &tdiff, NULL);
|
||||
ret = ppoll(fds, nfds, &tdiff, nullptr);
|
||||
if (ret >= 0 && fds[0].revents & (POLLERR | POLLHUP | POLLRDHUP)) {
|
||||
ret = -1;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
FD_ZERO(&exceptfds);
|
||||
FD_SET(m_fd, &readfds);
|
||||
|
||||
ret = pselect(m_fd + 1, &readfds, NULL, &exceptfds, &tdiff, NULL);
|
||||
ret = pselect(m_fd + 1, &readfds, nullptr, &exceptfds, &tdiff, nullptr);
|
||||
if (ret >= 1 && FD_ISSET(m_fd, &exceptfds)) {
|
||||
ret = -1;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
close();
|
||||
return RESULT_ERR_DEVICE;
|
||||
}
|
||||
if (m_listener != NULL) {
|
||||
if (m_listener != nullptr) {
|
||||
m_listener->notifyDeviceData(*value, true);
|
||||
}
|
||||
return RESULT_OK;
|
||||
|
||||
@@ -72,7 +72,7 @@ class Device {
|
||||
*/
|
||||
Device(const char* name, bool checkDevice, bool readOnly, bool initialSend)
|
||||
: m_name(name), m_checkDevice(checkDevice), m_readOnly(readOnly), m_initialSend(initialSend), m_fd(-1),
|
||||
m_listener(NULL) {}
|
||||
m_listener(nullptr) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -85,7 +85,7 @@ class Device {
|
||||
* @param checkDevice whether to regularly check the device availability (only for serial devices).
|
||||
* @param readOnly whether to allow read access to the device only.
|
||||
* @param initialSend whether to send an initial @a ESC symbol in @a open().
|
||||
* @return the new @a Device, or NULL on error.
|
||||
* @return the new @a Device, or nullptr on error.
|
||||
* Note: the caller needs to free the created instance.
|
||||
*/
|
||||
static Device* create(const char* name, bool checkDevice = true, bool readOnly = false,
|
||||
@@ -191,7 +191,7 @@ class Device {
|
||||
|
||||
|
||||
private:
|
||||
/** the @a DeviceListener, or NULL. */
|
||||
/** the @a DeviceListener, or nullptr. */
|
||||
DeviceListener* m_listener;
|
||||
};
|
||||
|
||||
@@ -243,7 +243,7 @@ class NetworkDevice : public Device {
|
||||
NetworkDevice(const char* name, const struct sockaddr_in& address, bool readOnly, bool initialSend,
|
||||
bool udp)
|
||||
: Device(name, true, readOnly, initialSend), m_address(address), m_udp(udp),
|
||||
m_buffer(NULL), m_bufSize(0), m_bufLen(0), m_bufPos(0) {}
|
||||
m_buffer(nullptr), m_bufSize(0), m_bufLen(0), m_bufPos(0) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -284,7 +284,7 @@ class NetworkDevice : public Device {
|
||||
/** true for UDP, false to TCP. */
|
||||
const bool m_udp;
|
||||
|
||||
/** the buffer memory, or NULL. */
|
||||
/** the buffer memory, or nullptr. */
|
||||
symbol_t* m_buffer;
|
||||
|
||||
/** the buffer size. */
|
||||
|
||||
@@ -40,18 +40,18 @@ istream* FileReader::openFile(const string& filename, string* errorDescription,
|
||||
struct stat st;
|
||||
if (stat(filename.c_str(), &st) != 0) {
|
||||
*errorDescription = filename;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
*errorDescription = filename+" is a directory";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ifstream* stream = new ifstream();
|
||||
stream->open(filename.c_str(), ifstream::in);
|
||||
if (!stream->is_open()) {
|
||||
*errorDescription = filename;
|
||||
delete(stream);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (time) {
|
||||
*time = st.st_mtime;
|
||||
|
||||
+19
-19
@@ -79,10 +79,10 @@ class FileReader {
|
||||
* Open a file as stream for reading.
|
||||
* @param filename the name of the file being read.
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or NULL.
|
||||
* @return the opened @a istream on success, or NULL on error.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or nullptr.
|
||||
* @return the opened @a istream on success, or nullptr on error.
|
||||
*/
|
||||
static istream* openFile(const string& filename, string* errorDescription, time_t* time = NULL);
|
||||
static istream* openFile(const string& filename, string* errorDescription, time_t* time = nullptr);
|
||||
|
||||
/**
|
||||
* Read the definitions from a stream.
|
||||
@@ -90,16 +90,16 @@ class FileReader {
|
||||
* @param filename the relative name of the file being read.
|
||||
* @param mtime a @a time_t value with the modification time of the file.
|
||||
* @param verbose whether to verbosely log problems.
|
||||
* @param defaults the default values by name (potentially overwritten by file name), or NULL to not use defaults.
|
||||
* @param defaults the default values by name (potentially overwritten by file name), or nullptr to not use defaults.
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
* @param replace whether to replace an already existing entry.
|
||||
* @param hash optional pointer to a @a size_t value for storing the hash of the file, or NULL.
|
||||
* @param size optional pointer to a @a size_t value for storing the normalized size of the file, or NULL.
|
||||
* @param hash optional pointer to a @a size_t value for storing the hash of the file, or nullptr.
|
||||
* @param size optional pointer to a @a size_t value for storing the normalized size of the file, or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = NULL,
|
||||
size_t* size = NULL);
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = nullptr,
|
||||
size_t* size = nullptr);
|
||||
|
||||
/**
|
||||
* Read a single line definition from the stream.
|
||||
@@ -110,8 +110,8 @@ class FileReader {
|
||||
* @param row the definition row to clear and update with the read data (for performance reasons only).
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
* @param replace whether to replace an already existing entry.
|
||||
* @param hash optional pointer to a @a size_t value for updating with the hash of the line, or NULL.
|
||||
* @param size optional pointer to a @a size_t value for updating with the normalized length of the line, or NULL.
|
||||
* @param hash optional pointer to a @a size_t value for updating with the hash of the line, or nullptr.
|
||||
* @param size optional pointer to a @a size_t value for updating with the normalized length of the line, or nullptr.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t readLineFromStream(istream* stream, const string& filename, bool verbose,
|
||||
@@ -146,12 +146,12 @@ class FileReader {
|
||||
* @param stream the @a istream to read from.
|
||||
* @param row the @a vector to which to add the fields. This will be empty for completely empty and comment lines.
|
||||
* @param lineNo the current line number (incremented with each line read).
|
||||
* @param hash optional pointer to a @a size_t value for combining the hash of the line with, or NULL.
|
||||
* @param size optional pointer to a @a size_t value to add the trimmed line length to, or NULL.
|
||||
* @param hash optional pointer to a @a size_t value for combining the hash of the line with, or nullptr.
|
||||
* @param size optional pointer to a @a size_t value to add the trimmed line length to, or nullptr.
|
||||
* @return true if there are more lines to read, false when there are no more lines left.
|
||||
*/
|
||||
static bool splitFields(istream* stream, vector<string>* row, unsigned int* lineNo,
|
||||
size_t* hash = NULL, size_t* size = NULL);
|
||||
size_t* hash = nullptr, size_t* size = nullptr);
|
||||
|
||||
/**
|
||||
* Format the specified hash as 8 hex digits to the output stream.
|
||||
@@ -209,20 +209,20 @@ class MappedFileReader : public FileReader {
|
||||
|
||||
// @copydoc
|
||||
result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = NULL,
|
||||
size_t* size = NULL) override;
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = nullptr,
|
||||
size_t* size = nullptr) override;
|
||||
|
||||
/**
|
||||
* Extract default values from the file name.
|
||||
* @param filename the name of the file (without path)
|
||||
* @param defaults the default values by name to add to.
|
||||
* @param destAddress optional pointer to a variable in which to store the numeric destination address, or NULL.
|
||||
* @param software optional pointer to a in which to store the numeric software version, or NULL.
|
||||
* @param hardware optional pointer to a in which to store the numeric hardware version, or NULL.
|
||||
* @param destAddress optional pointer to a variable in which to store the numeric destination address, or nullptr.
|
||||
* @param software optional pointer to a in which to store the numeric software version, or nullptr.
|
||||
* @param hardware optional pointer to a in which to store the numeric hardware version, or nullptr.
|
||||
* @return true if the minimum parts were extracted, false otherwise.
|
||||
*/
|
||||
virtual bool extractDefaultsFromFilename(const string& filename, map<string, string>* defaults,
|
||||
symbol_t* destAddress = NULL, unsigned int* software = NULL, unsigned int* hardware = NULL) const {
|
||||
symbol_t* destAddress = nullptr, unsigned int* software = nullptr, unsigned int* hardware = nullptr) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+55
-55
@@ -115,7 +115,7 @@ Message::Message(const string& circuit, const string& level, const string& name,
|
||||
m_id({pb, sb}), m_key(createKey(pb, sb, broadcast)),
|
||||
m_data(data), m_deleteData(deleteData),
|
||||
m_pollPriority(0),
|
||||
m_usedByCondition(false), m_isScanMessage(true), m_condition(NULL),
|
||||
m_usedByCondition(false), m_isScanMessage(true), m_condition(nullptr),
|
||||
m_lastUpdateTime(0), m_lastChangeTime(0), m_pollCount(0), m_lastPollTime(0) {
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ Message::Message(const string& circuit, const string& level, const string& name,
|
||||
/**
|
||||
* Helper method for getting a default if the value is empty.
|
||||
* @param value the value to check.
|
||||
* @param defaults a @a vector of defaults, or NULL.
|
||||
* @param defaults a @a vector of defaults, or nullptr.
|
||||
* @param pos the position in defaults.
|
||||
* @param replaceStar whether to replace a star in the default with the value.
|
||||
* If there is no star in the default and the value is empty, use the complete
|
||||
@@ -433,7 +433,7 @@ result_t Message::create(const string& filename, const DataFieldTemplates* templ
|
||||
if (subIt != subRowDefaults.end()) {
|
||||
subRows->insert(subRows->begin(), subIt->second.begin(), subIt->second.end());
|
||||
}
|
||||
const DataField* data = NULL;
|
||||
const DataField* data = nullptr;
|
||||
if (subRows->empty()) {
|
||||
vector<const SingleDataField*> fields;
|
||||
data = new DataFieldSet("", fields);
|
||||
@@ -610,7 +610,7 @@ void Message::setUsedByCondition() {
|
||||
}
|
||||
|
||||
bool Message::isAvailable() {
|
||||
return (m_condition == NULL) || m_condition->isTrue();
|
||||
return (m_condition == nullptr) || m_condition->isTrue();
|
||||
}
|
||||
|
||||
bool Message::hasField(const char* fieldName, bool numeric) const {
|
||||
@@ -653,7 +653,7 @@ result_t Message::prepareMasterPart(size_t index, char separator, istringstream*
|
||||
for (size_t i = 2; i < m_id.size(); i++) {
|
||||
master->push_back(m_id[i]);
|
||||
}
|
||||
result_t result = m_data->write(separator, getIdLength(), input, master, NULL);
|
||||
result_t result = m_data->write(separator, getIdLength(), input, master, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ result_t Message::prepareSlave(istringstream* input, SlaveSymbolString* slave) {
|
||||
}
|
||||
slave->clear();
|
||||
slave->push_back(0); // length, will be set later
|
||||
result_t result = m_data->write(UI_FIELD_SEPARATOR, 0, input, slave, NULL);
|
||||
result_t result = m_data->write(UI_FIELD_SEPARATOR, 0, input, slave, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
@@ -730,7 +730,7 @@ result_t Message::decodeLastData(bool master, bool leadingSeparator, const char*
|
||||
if (result < RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
if (result == RESULT_EMPTY && (fieldName != NULL || fieldIndex >= 0)) {
|
||||
if (result == RESULT_EMPTY && (fieldName != nullptr || fieldIndex >= 0)) {
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
}
|
||||
return result;
|
||||
@@ -763,7 +763,7 @@ result_t Message::decodeLastData(bool leadingSeparator, const char* fieldName,
|
||||
result = RESULT_OK; // OK if at least one part was non-empty
|
||||
}
|
||||
}
|
||||
if (result == RESULT_EMPTY && (fieldName != NULL || fieldIndex >= 0)) {
|
||||
if (result == RESULT_EMPTY && (fieldName != nullptr || fieldIndex >= 0)) {
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
}
|
||||
return result;
|
||||
@@ -808,7 +808,7 @@ bool Message::isLessPollWeight(const Message* other) const {
|
||||
|
||||
void Message::dumpHeader(const vector<string>* fieldNames, ostream* output) {
|
||||
bool first = true;
|
||||
if (fieldNames == NULL) {
|
||||
if (fieldNames == nullptr) {
|
||||
for (const auto& fieldName : defaultMessageFieldMap) {
|
||||
if (first) {
|
||||
first = false;
|
||||
@@ -831,7 +831,7 @@ void Message::dumpHeader(const vector<string>* fieldNames, ostream* output) {
|
||||
|
||||
void Message::dump(const vector<string>* fieldNames, bool withConditions, ostream* output) const {
|
||||
bool first = true;
|
||||
if (fieldNames == NULL) {
|
||||
if (fieldNames == nullptr) {
|
||||
for (const auto& fieldName : knownFieldNamesFull) {
|
||||
if (fieldName == FIELNAME_LEVEL) {
|
||||
continue; // access level not included in default dump format
|
||||
@@ -857,7 +857,7 @@ void Message::dump(const vector<string>* fieldNames, bool withConditions, ostrea
|
||||
|
||||
void Message::dumpField(const string& fieldName, bool withConditions, ostream* output) const {
|
||||
if (fieldName == "type") {
|
||||
if (withConditions && m_condition != NULL) {
|
||||
if (withConditions && m_condition != nullptr) {
|
||||
m_condition->dump(false, output);
|
||||
}
|
||||
if (m_isPassive) {
|
||||
@@ -976,7 +976,7 @@ void Message::decodeJson(bool leadingSeparator, bool appendDirection, bool addRa
|
||||
}
|
||||
size_t pos = (size_t)output->tellp();
|
||||
*output << ",\n \"fields\": {";
|
||||
result_t dret = decodeLastData(false, NULL, -1, outputFormat, output);
|
||||
result_t dret = decodeLastData(false, nullptr, -1, outputFormat, output);
|
||||
if (dret == RESULT_OK) {
|
||||
*output << "\n }";
|
||||
} else {
|
||||
@@ -1023,9 +1023,9 @@ ChainedMessage::ChainedMessage(const string& circuit, const string& level, const
|
||||
ChainedMessage::~ChainedMessage() {
|
||||
for (size_t index = 0; index < m_ids.size(); index++) {
|
||||
delete m_lastMasterDatas[index];
|
||||
m_lastMasterDatas[index] = NULL;
|
||||
m_lastMasterDatas[index] = nullptr;
|
||||
delete m_lastSlaveDatas[index];
|
||||
m_lastSlaveDatas[index] = NULL;
|
||||
m_lastSlaveDatas[index] = nullptr;
|
||||
}
|
||||
free(m_lastMasterDatas);
|
||||
free(m_lastSlaveDatas);
|
||||
@@ -1113,7 +1113,7 @@ result_t ChainedMessage::prepareMasterPart(size_t index, char separator, istring
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
}
|
||||
MasterSymbolString allData;
|
||||
result_t result = m_data->write(separator, 0, input, &allData, NULL);
|
||||
result_t result = m_data->write(separator, 0, input, &allData, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
@@ -1271,14 +1271,14 @@ void ChainedMessage::dumpField(const string& fieldName, bool withConditions, ost
|
||||
Message* getFirstAvailable(const vector<Message*>& messages, const MasterSymbolString* sameIdExtAs,
|
||||
const bool onlyAvailable = true) {
|
||||
for (auto message : messages) {
|
||||
if (sameIdExtAs && !message->checkId(*sameIdExtAs, NULL)) {
|
||||
if (sameIdExtAs && !message->checkId(*sameIdExtAs, nullptr)) {
|
||||
continue;
|
||||
}
|
||||
if (!onlyAvailable || message->isAvailable()) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1288,7 +1288,7 @@ Message* getFirstAvailable(const vector<Message*>& messages, const MasterSymbolS
|
||||
* @param onlyAvailable true to include only available messages (default true), false to also include messages that
|
||||
* are currently not available (e.g. due to unresolved or false conditions).
|
||||
*/
|
||||
Message* getFirstAvailable(const vector<Message*>& messages, const Message* sameIdExtAs = NULL,
|
||||
Message* getFirstAvailable(const vector<Message*>& messages, const Message* sameIdExtAs = nullptr,
|
||||
const bool onlyAvailable = true) {
|
||||
for (auto message : messages) {
|
||||
if (sameIdExtAs && !message->checkId(*sameIdExtAs)) {
|
||||
@@ -1298,7 +1298,7 @@ Message* getFirstAvailable(const vector<Message*>& messages, const Message* same
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1445,7 +1445,7 @@ result_t Condition::create(const string& condName, const map<string, string>& ro
|
||||
|
||||
SimpleCondition* SimpleCondition::derive(const string& valueList) const {
|
||||
if (valueList.empty()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
string useValueList = valueList;
|
||||
string name = m_condName+useValueList;
|
||||
@@ -1458,18 +1458,18 @@ SimpleCondition* SimpleCondition::derive(const string& valueList) const {
|
||||
vector<string> values;
|
||||
result = splitValues(useValueList, &values);
|
||||
if (result != RESULT_OK) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return new SimpleStringCondition(name, m_refName, m_circuit, m_level, m_name, m_dstAddress, m_field, values);
|
||||
}
|
||||
// numbers
|
||||
if (!isNumeric()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
vector<unsigned int> valueRanges;
|
||||
result = splitValues(useValueList, &valueRanges);
|
||||
if (result != RESULT_OK) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return new SimpleNumericCondition(name, m_refName, m_circuit, m_level, m_name, m_dstAddress, m_field, valueRanges);
|
||||
}
|
||||
@@ -1496,7 +1496,7 @@ CombinedCondition* SimpleCondition::combineAnd(Condition* other) {
|
||||
|
||||
result_t SimpleCondition::resolve(void (*readMessageFunc)(Message* message), MessageMap* messages,
|
||||
ostringstream* errorMessage) {
|
||||
if (m_message == NULL) {
|
||||
if (m_message == nullptr) {
|
||||
Message* message;
|
||||
if (m_name.length() == 0) {
|
||||
message = messages->getScanMessage(m_dstAddress);
|
||||
@@ -1525,12 +1525,12 @@ result_t SimpleCondition::resolve(void (*readMessageFunc)(Message* message), Mes
|
||||
// clone the message with dedicated dstAddress if necessary
|
||||
uint64_t key = message->getDerivedKey(m_dstAddress);
|
||||
const vector<Message*>* derived = messages->getByKey(key);
|
||||
if (derived == NULL) {
|
||||
if (derived == nullptr) {
|
||||
message = message->derive(m_dstAddress, true);
|
||||
messages->add(true, message);
|
||||
} else {
|
||||
Message* first = getFirstAvailable(*derived, message);
|
||||
if (first == NULL) {
|
||||
if (first == nullptr) {
|
||||
*errorMessage << ": conditional derived message " << message->getCircuit() << "." << message->getName()
|
||||
<< " for " << hex << setw(2) << setfill('0') << static_cast<unsigned>(m_dstAddress) << " not found";
|
||||
return RESULT_ERR_INVALID_ARG;
|
||||
@@ -1540,7 +1540,7 @@ result_t SimpleCondition::resolve(void (*readMessageFunc)(Message* message), Mes
|
||||
}
|
||||
|
||||
if (m_hasValues) {
|
||||
if (!message->hasField(m_field.length() > 0 ? m_field.c_str() : NULL, isNumeric())) {
|
||||
if (!message->hasField(m_field.length() > 0 ? m_field.c_str() : nullptr, isNumeric())) {
|
||||
*errorMessage << (isNumeric() ? ": numeric field " : ": string field ") << m_field << " not found";
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
}
|
||||
@@ -1551,7 +1551,7 @@ result_t SimpleCondition::resolve(void (*readMessageFunc)(Message* message), Mes
|
||||
messages->addPollMessage(true, message);
|
||||
}
|
||||
}
|
||||
if (m_message->getLastUpdateTime() == 0 && readMessageFunc != NULL) {
|
||||
if (m_message->getLastUpdateTime() == 0 && readMessageFunc != nullptr) {
|
||||
(*readMessageFunc)(m_message);
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -1575,7 +1575,7 @@ bool SimpleCondition::isTrue() {
|
||||
|
||||
bool SimpleNumericCondition::checkValue(const Message* message, const string& field) {
|
||||
unsigned int value = 0;
|
||||
result_t result = message->decodeLastDataNumField(field.length() == 0 ? NULL : field.c_str(), -1, &value);
|
||||
result_t result = message->decodeLastDataNumField(field.length() == 0 ? nullptr : field.c_str(), -1, &value);
|
||||
if (result == RESULT_OK) {
|
||||
for (size_t i = 0; i+1 < m_valueRanges.size(); i+=2) {
|
||||
if (m_valueRanges[i] <= value && value <= m_valueRanges[i+1]) {
|
||||
@@ -1590,7 +1590,7 @@ bool SimpleNumericCondition::checkValue(const Message* message, const string& fi
|
||||
|
||||
bool SimpleStringCondition::checkValue(const Message* message, const string& field) {
|
||||
ostringstream output;
|
||||
result_t result = message->decodeLastData(false, field.length() == 0 ? NULL : field.c_str(), -1, 0, &output);
|
||||
result_t result = message->decodeLastData(false, field.length() == 0 ? nullptr : field.c_str(), -1, 0, &output);
|
||||
if (result == RESULT_OK) {
|
||||
string value = output.str();
|
||||
for (size_t i = 0; i < m_values.size(); i++) {
|
||||
@@ -1755,7 +1755,7 @@ result_t MessageMap::add(bool storeByName, Message* message, bool replace) {
|
||||
}
|
||||
} else {
|
||||
Message *other = getFirstAvailable(keyIt->second, message);
|
||||
if (other != NULL && (!conditional || !other->isConditional())) {
|
||||
if (other != nullptr && (!conditional || !other->isConditional())) {
|
||||
unlock();
|
||||
return RESULT_ERR_DUPLICATE; // duplicate key
|
||||
}
|
||||
@@ -1838,7 +1838,7 @@ result_t MessageMap::add(bool storeByName, Message* message, bool replace) {
|
||||
}
|
||||
|
||||
void MessageMap::remove(Message* message) {
|
||||
if (message == NULL) {
|
||||
if (message == nullptr) {
|
||||
return;
|
||||
}
|
||||
lock();
|
||||
@@ -2010,9 +2010,9 @@ result_t MessageMap::addDefaultFromFile(const string& filename, unsigned int lin
|
||||
*errorDescription = "condition "+type+" already defined";
|
||||
return RESULT_ERR_DUPLICATE_NAME;
|
||||
}
|
||||
SimpleCondition* condition = NULL;
|
||||
SimpleCondition* condition = nullptr;
|
||||
result_t result = Condition::create(type, defaults, row, &condition);
|
||||
if (condition == NULL || result != RESULT_OK) {
|
||||
if (condition == nullptr || result != RESULT_OK) {
|
||||
*errorDescription = "invalid condition";
|
||||
return result;
|
||||
}
|
||||
@@ -2077,12 +2077,12 @@ result_t MessageMap::readConditions(const string& filename, string* types, strin
|
||||
types->erase(0, pos+1);
|
||||
} else {
|
||||
bool store = false;
|
||||
*condition = NULL;
|
||||
*condition = nullptr;
|
||||
while ((pos=types->find(']')) != string::npos) {
|
||||
// simple condition
|
||||
string key = filename+":"+types->substr(1, pos-1);
|
||||
it = m_conditions.find(key);
|
||||
Condition* add = NULL;
|
||||
Condition* add = nullptr;
|
||||
if (it == m_conditions.end()) {
|
||||
// check for on-the-fly condition
|
||||
size_t sep = key.find_first_of("=<>", filename.length()+1);
|
||||
@@ -2091,14 +2091,14 @@ result_t MessageMap::readConditions(const string& filename, string* types, strin
|
||||
if (it != m_conditions.end()) {
|
||||
// derive from another condition
|
||||
add = it->second->derive(key.substr(sep));
|
||||
if (add == NULL) {
|
||||
if (add == nullptr) {
|
||||
*errorDescription = "derive condition with values "+key.substr(sep)+" failed";
|
||||
return RESULT_ERR_INVALID_ARG;
|
||||
}
|
||||
m_conditions[key] = add; // store derived condition
|
||||
}
|
||||
}
|
||||
if (add == NULL) {
|
||||
if (add == nullptr) {
|
||||
// shared condition not available
|
||||
*errorDescription = "condition "+types->substr(1, pos-1)+" not defined";
|
||||
return RESULT_ERR_NOTFOUND;
|
||||
@@ -2229,7 +2229,7 @@ result_t MessageMap::readFromStream(istream* stream, const string& filename, con
|
||||
|
||||
result_t MessageMap::addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
|
||||
vector< map<string, string> >* subRows, string* errorDescription, bool replace) {
|
||||
Condition* condition = NULL;
|
||||
Condition* condition = nullptr;
|
||||
string types = AttributedItem::pluck("type", row);
|
||||
result_t result = readConditions(filename, &types, errorDescription, &condition);
|
||||
if (result != RESULT_OK) {
|
||||
@@ -2242,9 +2242,9 @@ result_t MessageMap::addFromFile(const string& filename, unsigned int lineNo, ma
|
||||
return RESULT_ERR_INVALID_ARG;
|
||||
}
|
||||
types = types.substr(1);
|
||||
Instruction* instruction = NULL;
|
||||
Instruction* instruction = nullptr;
|
||||
result = Instruction::create(filename, types, condition, *row, getDefaults()[""], &instruction);
|
||||
if (instruction == NULL || result != RESULT_OK) {
|
||||
if (instruction == nullptr || result != RESULT_OK) {
|
||||
*errorDescription = "invalid instruction";
|
||||
return result;
|
||||
}
|
||||
@@ -2308,11 +2308,11 @@ Message* MessageMap::getScanMessage(symbol_t dstAddress) {
|
||||
return m_broadcastScanMessage;
|
||||
}
|
||||
if (!isValidAddress(dstAddress, true) || isMaster(dstAddress)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uint64_t key = m_scanMessage->getDerivedKey(dstAddress);
|
||||
const vector<Message*>* msgs = getByKey(key);
|
||||
if (msgs != NULL) {
|
||||
if (msgs != nullptr) {
|
||||
return msgs->front();
|
||||
}
|
||||
Message* message = m_scanMessage->derive(dstAddress, true);
|
||||
@@ -2324,7 +2324,7 @@ result_t MessageMap::resolveConditions(bool verbose, string* errorDescription) {
|
||||
result_t overallResult = RESULT_OK;
|
||||
for (const auto& it : m_conditions) {
|
||||
Condition* condition = it.second;
|
||||
result_t result = resolveCondition(NULL, condition, errorDescription);
|
||||
result_t result = resolveCondition(nullptr, condition, errorDescription);
|
||||
if (result != RESULT_OK) {
|
||||
overallResult = result;
|
||||
}
|
||||
@@ -2361,10 +2361,10 @@ result_t MessageMap::executeInstructions(void (*readMessageFunc)(Message* messag
|
||||
continue;
|
||||
}
|
||||
Condition* condition = instruction->getCondition();
|
||||
bool execute = m_addAll || condition == NULL;
|
||||
bool execute = m_addAll || condition == nullptr;
|
||||
if (!execute) {
|
||||
string errorDescription;
|
||||
result_t result = resolveCondition(instruction->isSingleton()?readMessageFunc:NULL, condition,
|
||||
result_t result = resolveCondition(instruction->isSingleton()?readMessageFunc:nullptr, condition,
|
||||
&errorDescription);
|
||||
if (result != RESULT_OK) {
|
||||
overallResult = result;
|
||||
@@ -2474,7 +2474,7 @@ const vector<Message*>* MessageMap::getByKey(uint64_t key) const {
|
||||
if (it != m_messagesByKey.end()) {
|
||||
return &it->second;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Message* MessageMap::find(const string& circuit, const string& name, const string& levels, bool isWrite,
|
||||
@@ -2501,7 +2501,7 @@ Message* MessageMap::find(const string& circuit, const string& name, const strin
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MessageMap::findAll(const string& circuit, const string& name, const string& levels,
|
||||
@@ -2574,7 +2574,7 @@ Message* MessageMap::find(const MasterSymbolString& master, bool anyDestination,
|
||||
uint64_t baseKey = Message::createKey(master,
|
||||
anyDestination || master[1] != BROADCAST ? m_maxIdLength : m_maxBroadcastIdLength, anyDestination);
|
||||
if (baseKey == INVALID_KEY) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
size_t maxIdLength = Message::getKeyLength(baseKey);
|
||||
for (size_t idLength = maxIdLength; true; idLength--) {
|
||||
@@ -2636,7 +2636,7 @@ Message* MessageMap::find(const MasterSymbolString& master, bool anyDestination,
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MessageMap::invalidateCache(Message* message) {
|
||||
@@ -2656,7 +2656,7 @@ void MessageMap::invalidateCache(Message* message) {
|
||||
}
|
||||
|
||||
void MessageMap::addPollMessage(bool toFront, Message* message) {
|
||||
if (message != NULL && message->getPollPriority() > 0) {
|
||||
if (message != nullptr && message->getPollPriority() > 0) {
|
||||
lock();
|
||||
message->m_lastPollTime = toFront ? 0 : m_pollMessages.size();
|
||||
m_pollMessages.push(message);
|
||||
@@ -2749,7 +2749,7 @@ void MessageMap::clear() {
|
||||
|
||||
Message* MessageMap::getNextPoll() {
|
||||
if (m_pollMessages.empty()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Message* ret = m_pollMessages.top();
|
||||
m_pollMessages.pop();
|
||||
@@ -2761,7 +2761,7 @@ Message* MessageMap::getNextPoll() {
|
||||
|
||||
void MessageMap::dump(bool withConditions, ostream* output) const {
|
||||
bool first = true;
|
||||
Message::dumpHeader(NULL, output);
|
||||
Message::dumpHeader(nullptr, output);
|
||||
*output << endl;
|
||||
for (const auto it : m_messagesByName) {
|
||||
if (it.first[0] == FIELD_SEPARATOR) { // skip instances stored multiple times (key starting with "-")
|
||||
@@ -2777,7 +2777,7 @@ void MessageMap::dump(bool withConditions, ostream* output) const {
|
||||
} else {
|
||||
*output << endl;
|
||||
}
|
||||
message->dump(NULL, withConditions, output);
|
||||
message->dump(nullptr, withConditions, output);
|
||||
}
|
||||
} else {
|
||||
Message* message = getFirstAvailable(it.second);
|
||||
@@ -2789,7 +2789,7 @@ void MessageMap::dump(bool withConditions, ostream* output) const {
|
||||
} else {
|
||||
*output << endl;
|
||||
}
|
||||
message->dump(NULL, withConditions, output);
|
||||
message->dump(nullptr, withConditions, output);
|
||||
}
|
||||
}
|
||||
if (!first) {
|
||||
|
||||
+36
-36
@@ -90,7 +90,7 @@ class Message : public AttributedItem {
|
||||
* @param data the @a DataField for encoding/decoding the message.
|
||||
* @param deleteData whether to delete the @a DataField during destruction.
|
||||
* @param pollPriority the priority for polling, or 0 for no polling at all.
|
||||
* @param condition the @a Condition for this message, or NULL.
|
||||
* @param condition the @a Condition for this message, or nullptr.
|
||||
*/
|
||||
Message(const string& circuit, const string& level, const string& name,
|
||||
bool isWrite, bool isPassive, const map<string, string>& attributes,
|
||||
@@ -98,7 +98,7 @@ class Message : public AttributedItem {
|
||||
const vector<symbol_t>& id,
|
||||
const DataField* data, bool deleteData,
|
||||
size_t pollPriority = 0,
|
||||
Condition* condition = NULL);
|
||||
Condition* condition = nullptr);
|
||||
|
||||
|
||||
private:
|
||||
@@ -173,11 +173,11 @@ class Message : public AttributedItem {
|
||||
/**
|
||||
* Factory method for creating new instances.
|
||||
* @param filename the name of the file being read.
|
||||
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
|
||||
* @param templates the @a DataFieldTemplates to be referenced by name, or nullptr.
|
||||
* @param rowDefaults the mapped message definition defaults.
|
||||
* @param subRowDefaults the mapped field definition defaults.
|
||||
* @param typeStr the single type of message to create.
|
||||
* @param condition the @a Condition instance for the message, or NULL.
|
||||
* @param condition the @a Condition instance for the message, or nullptr.
|
||||
* @param row the mapped message definition row (may be modified).
|
||||
* @param subRows the mapped field definition rows (may be modified).
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
@@ -333,7 +333,7 @@ class Message : public AttributedItem {
|
||||
/**
|
||||
* Check the ID against the master @a SymbolString data.
|
||||
* @param master the @a MasterSymbolString to check against.
|
||||
* @param index the variable in which to store the message part index, or NULL to ignore.
|
||||
* @param index the variable in which to store the message part index, or nullptr to ignore.
|
||||
* @return true if the ID matches, false otherwise.
|
||||
*/
|
||||
virtual bool checkId(const MasterSymbolString& master, size_t* index) const;
|
||||
@@ -380,7 +380,7 @@ class Message : public AttributedItem {
|
||||
* Return whether this @a Message depends on a @a Condition.
|
||||
* @return true when this @a Message depends on a @a Condition.
|
||||
*/
|
||||
bool isConditional() const { return m_condition != NULL; }
|
||||
bool isConditional() const { return m_condition != nullptr; }
|
||||
|
||||
/**
|
||||
* Return whether this @a Message is available (optionally depending on a @a Condition evaluation).
|
||||
@@ -390,7 +390,7 @@ class Message : public AttributedItem {
|
||||
|
||||
/**
|
||||
* Return whether the field is available.
|
||||
* @param fieldName the name of the field to find, or NULL for any.
|
||||
* @param fieldName the name of the field to find, or nullptr for any.
|
||||
* @param numeric true for a numeric field, false for a string field.
|
||||
* @return true if the field is available.
|
||||
*/
|
||||
@@ -487,7 +487,7 @@ class Message : public AttributedItem {
|
||||
|
||||
/**
|
||||
* Decode a particular numeric field value from the last stored data.
|
||||
* @param fieldName the name of the field to decode, or NULL for the first field.
|
||||
* @param fieldName the name of the field to decode, or nullptr for the first field.
|
||||
* @param fieldIndex the optional index of the field (either named or overall), or -1.
|
||||
* @param output the variable in which to store the value.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
@@ -533,14 +533,14 @@ class Message : public AttributedItem {
|
||||
|
||||
/**
|
||||
* Write the message definition header or parts of it to the @a ostream.
|
||||
* @param fieldNames the list of field names to write, or NULL for all.
|
||||
* @param fieldNames the list of field names to write, or nullptr for all.
|
||||
* @param output the @a ostream to append the formatted value to.
|
||||
*/
|
||||
static void dumpHeader(const vector<string>* fieldNames, ostream* output);
|
||||
|
||||
/**
|
||||
* Write the message definition or parts of it to the @a ostream.
|
||||
* @param fieldNames the list of field names to write, or NULL for all.
|
||||
* @param fieldNames the list of field names to write, or nullptr for all.
|
||||
* @param withConditions whether to include the optional conditions prefix.
|
||||
* @param output the @a ostream to append the formatted value to.
|
||||
*/
|
||||
@@ -626,7 +626,7 @@ class Message : public AttributedItem {
|
||||
/** whether this is a special scanning @a Message instance. */
|
||||
bool m_isScanMessage;
|
||||
|
||||
/** the @a Condition for this message, or NULL. */
|
||||
/** the @a Condition for this message, or nullptr. */
|
||||
Condition* m_condition;
|
||||
|
||||
/** the last seen @a MasterSymbolString. */
|
||||
@@ -669,7 +669,7 @@ class ChainedMessage : public Message {
|
||||
* @param data the @a DataField for encoding/decoding the chained message.
|
||||
* @param deleteData whether to delete the @a DataField during destruction.
|
||||
* @param pollPriority the priority for polling, or 0 for no polling at all.
|
||||
* @param condition the @a Condition for this message, or NULL.
|
||||
* @param condition the @a Condition for this message, or nullptr.
|
||||
*/
|
||||
ChainedMessage(const string& circuit, const string& level, const string& name,
|
||||
bool isWrite, const map<string, string>& attributes,
|
||||
@@ -678,7 +678,7 @@ class ChainedMessage : public Message {
|
||||
const vector< vector<symbol_t> >& ids, const vector<size_t>& lengths,
|
||||
const DataField* data, bool deleteData,
|
||||
size_t pollPriority = 0,
|
||||
Condition* condition = NULL);
|
||||
Condition* condition = nullptr);
|
||||
|
||||
virtual ~ChainedMessage();
|
||||
|
||||
@@ -827,9 +827,9 @@ class Condition {
|
||||
/**
|
||||
* Derive a new @a SimpleCondition from this condition.
|
||||
* @param valueList the @a string with the new list of values.
|
||||
* @return the derived @a SimpleCondition instance, or NULL if the value list is invalid.
|
||||
* @return the derived @a SimpleCondition instance, or nullptr if the value list is invalid.
|
||||
*/
|
||||
virtual SimpleCondition* derive(const string& valueList) const { return NULL; }
|
||||
virtual SimpleCondition* derive(const string& valueList) const { return nullptr; }
|
||||
|
||||
/**
|
||||
* Write the condition definition or resolved expression to the @a ostream.
|
||||
@@ -848,7 +848,7 @@ class Condition {
|
||||
/**
|
||||
* Resolve the referred @a Message instance(s) and field index(es).
|
||||
* @param messages the @a MessageMap instance for resolving.
|
||||
* @param readMessageFunc the function to call for immediate reading of a @a Message from the bus, or NULL.
|
||||
* @param readMessageFunc the function to call for immediate reading of a @a Message from the bus, or nullptr.
|
||||
* @param errorMessage a @a ostringstream to which to add optional error messages.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
@@ -892,7 +892,7 @@ class SimpleCondition : public Condition {
|
||||
const string& name, symbol_t dstAddress, const string& field, bool hasValues = false)
|
||||
: Condition(),
|
||||
m_condName(condName), m_refName(refName), m_circuit(circuit), m_level(level), m_name(name),
|
||||
m_dstAddress(dstAddress), m_field(field), m_hasValues(hasValues), m_message(NULL) { }
|
||||
m_dstAddress(dstAddress), m_field(field), m_hasValues(hasValues), m_message(nullptr) { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -961,7 +961,7 @@ class SimpleCondition : public Condition {
|
||||
/** whether a value has to be checked against. */
|
||||
const bool m_hasValues;
|
||||
|
||||
/** the resolved @a Message instance, or NULL. */
|
||||
/** the resolved @a Message instance, or nullptr. */
|
||||
Message* m_message;
|
||||
};
|
||||
|
||||
@@ -1105,7 +1105,7 @@ class Instruction {
|
||||
* Factory method for creating a new instance.
|
||||
* @param relPath the relative path and/or filename context being loaded.
|
||||
* @param type the type of the instruction.
|
||||
* @param condition the @a Condition for the instruction, or NULL.
|
||||
* @param condition the @a Condition for the instruction, or nullptr.
|
||||
* @param row the definition row by field name.
|
||||
* @param defaults the default values by name.
|
||||
* @param returnValue the variable in which to store the created instance.
|
||||
@@ -1233,11 +1233,11 @@ class MessageMap : public MappedFileReader {
|
||||
clear();
|
||||
if (m_scanMessage) {
|
||||
delete m_scanMessage;
|
||||
m_scanMessage = NULL;
|
||||
m_scanMessage = nullptr;
|
||||
}
|
||||
if (m_broadcastScanMessage) {
|
||||
delete m_broadcastScanMessage;
|
||||
m_broadcastScanMessage = NULL;
|
||||
m_broadcastScanMessage = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1276,12 +1276,12 @@ class MessageMap : public MappedFileReader {
|
||||
|
||||
// @copydoc
|
||||
bool extractDefaultsFromFilename(const string& filename, map<string, string>* defaults,
|
||||
symbol_t* destAddress = NULL, unsigned int* software = NULL, unsigned int* hardware = NULL) const override;
|
||||
symbol_t* destAddress = nullptr, unsigned int* software = nullptr, unsigned int* hardware = nullptr) const override;
|
||||
|
||||
// @copydoc
|
||||
result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = NULL,
|
||||
size_t* size = NULL) override;
|
||||
map<string, string>* defaults, string* errorDescription, bool replace = false, size_t* hash = nullptr,
|
||||
size_t* size = nullptr) override;
|
||||
|
||||
// @copydoc
|
||||
result_t addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
|
||||
@@ -1290,7 +1290,7 @@ class MessageMap : public MappedFileReader {
|
||||
/**
|
||||
* Get the scan @a Message instance for the specified address.
|
||||
* @param dstAddress the destination address, or @a SYN for the base scan @a Message.
|
||||
* @return the scan @a Message instance, or NULL if the dstAddress is no slave.
|
||||
* @return the scan @a Message instance, or nullptr if the dstAddress is no slave.
|
||||
*/
|
||||
Message* getScanMessage(const symbol_t dstAddress = SYN);
|
||||
|
||||
@@ -1310,7 +1310,7 @@ class MessageMap : public MappedFileReader {
|
||||
|
||||
/**
|
||||
* Resolve a @a Condition.
|
||||
* @param readMessageFunc the function to call for immediate reading of a @a Message from the bus, or NULL.
|
||||
* @param readMessageFunc the function to call for immediate reading of a @a Message from the bus, or nullptr.
|
||||
* @param condition the @a Condition to resolve.
|
||||
* @param errorDescription a string in which to store the error description in case of error.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
@@ -1321,7 +1321,7 @@ class MessageMap : public MappedFileReader {
|
||||
/**
|
||||
* Run all executable @a Instruction instances.
|
||||
* @param readMessageFunc the function to call for immediate reading of a
|
||||
* @a Message values from the bus required for singleton instructions, or NULL.
|
||||
* @a Message values from the bus required for singleton instructions, or nullptr.
|
||||
* @param log the @a ostringstream to log success messages to (if necessary).
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
@@ -1352,18 +1352,18 @@ class MessageMap : public MappedFileReader {
|
||||
* Get the infos for a loaded file.
|
||||
* @param filename the name of the configuration file (including relative path).
|
||||
* @param comment a string in which the comment is stored.
|
||||
* @param hash optional pointer to a @a size_t value for storing the hash of the file, or NULL.
|
||||
* @param size optional pointer to a @a size_t value for storing the normalized size of the file, or NULL.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or NULL.
|
||||
* @param hash optional pointer to a @a size_t value for storing the hash of the file, or nullptr.
|
||||
* @param size optional pointer to a @a size_t value for storing the normalized size of the file, or nullptr.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or nullptr.
|
||||
* @return true if the file info was found, false otherwise.
|
||||
*/
|
||||
bool getLoadedFileInfo(const string& filename, string* comment, size_t* hash = NULL, size_t* size = NULL,
|
||||
time_t* time = NULL) const;
|
||||
bool getLoadedFileInfo(const string& filename, string* comment, size_t* hash = nullptr, size_t* size = nullptr,
|
||||
time_t* time = nullptr) const;
|
||||
|
||||
/**
|
||||
* Get the stored @a Message instances for the key.
|
||||
* @param key the key of the @a Message.
|
||||
* @return the found @a Message instances, or NULL.
|
||||
* @return the found @a Message instances, or nullptr.
|
||||
* Note: the caller may not free the returned instances.
|
||||
*/
|
||||
const vector<Message*>* getByKey(uint64_t key) const;
|
||||
@@ -1375,7 +1375,7 @@ class MessageMap : public MappedFileReader {
|
||||
* @param levels the access levels to match.
|
||||
* @param isWrite whether this is a write message.
|
||||
* @param isPassive whether this is a passive message.
|
||||
* @return the @a Message instance, or NULL.
|
||||
* @return the @a Message instance, or nullptr.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(const string& circuit, const string& name, const string& levels, bool isWrite,
|
||||
@@ -1415,7 +1415,7 @@ class MessageMap : public MappedFileReader {
|
||||
* @param withPassive true to include passive messages (default true).
|
||||
* @param onlyAvailable true to include only available messages (default true), false to also include messages that
|
||||
* are currently not available (e.g. due to unresolved or false conditions).
|
||||
* @return the @a Message instance, or NULL.
|
||||
* @return the @a Message instance, or nullptr.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(const MasterSymbolString& master, bool anyDestination = false, bool withRead = true,
|
||||
@@ -1484,7 +1484,7 @@ class MessageMap : public MappedFileReader {
|
||||
|
||||
/**
|
||||
* Get the next @a Message to poll.
|
||||
* @return the next @a Message to poll, or NULL.
|
||||
* @return the next @a Message to poll, or nullptr.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* getNextPoll();
|
||||
|
||||
@@ -56,11 +56,11 @@ static const symbol_t CRC_LOOKUP_TABLE[] = {
|
||||
|
||||
unsigned int parseInt(const char* str, int base, unsigned int minValue, unsigned int maxValue,
|
||||
result_t* result, size_t* length) {
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
|
||||
unsigned long ret = strtoul(str, &strEnd, base);
|
||||
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
|
||||
if (strEnd == nullptr || strEnd == str || *strEnd != 0) {
|
||||
*result = RESULT_ERR_INVALID_NUM; // invalid value
|
||||
return 0;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ unsigned int parseInt(const char* str, int base, unsigned int minValue, unsigned
|
||||
*result = RESULT_ERR_OUT_OF_RANGE; // invalid value
|
||||
return 0;
|
||||
}
|
||||
if (length != NULL) {
|
||||
if (length != nullptr) {
|
||||
*length = (unsigned int)(strEnd - str);
|
||||
}
|
||||
*result = RESULT_OK;
|
||||
@@ -78,11 +78,11 @@ unsigned int parseInt(const char* str, int base, unsigned int minValue, unsigned
|
||||
|
||||
int parseSignedInt(const char* str, int base, int minValue, int maxValue,
|
||||
result_t* result, size_t* length) {
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
|
||||
long ret = strtol(str, &strEnd, base);
|
||||
|
||||
if (strEnd == NULL || *strEnd != 0) {
|
||||
if (strEnd == nullptr || *strEnd != 0) {
|
||||
*result = RESULT_ERR_INVALID_NUM; // invalid value
|
||||
return 0;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ int parseSignedInt(const char* str, int base, int minValue, int maxValue,
|
||||
*result = RESULT_ERR_OUT_OF_RANGE; // invalid value
|
||||
return 0;
|
||||
}
|
||||
if (length != NULL) {
|
||||
if (length != nullptr) {
|
||||
*length = (unsigned int)(strEnd - str);
|
||||
}
|
||||
*result = RESULT_OK;
|
||||
|
||||
@@ -97,7 +97,7 @@ typedef unsigned char symbol_t;
|
||||
* @return the parsed value.
|
||||
*/
|
||||
unsigned int parseInt(const char* str, int base, unsigned int minValue, unsigned int maxValue,
|
||||
result_t* result, size_t* length = NULL);
|
||||
result_t* result, size_t* length = nullptr);
|
||||
|
||||
/**
|
||||
* Parse a signed int value.
|
||||
@@ -110,7 +110,7 @@ unsigned int parseInt(const char* str, int base, unsigned int minValue, unsigned
|
||||
* @return the parsed value.
|
||||
*/
|
||||
int parseSignedInt(const char* str, int base, int minValue, int maxValue,
|
||||
result_t* result, size_t* length = NULL);
|
||||
result_t* result, size_t* length = nullptr);
|
||||
|
||||
/**
|
||||
* A string of unescaped bus symbols.
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestReader : public MappedFileReader {
|
||||
public:
|
||||
TestReader(DataFieldTemplates* templates, bool isSet, bool isMasterDest)
|
||||
: MappedFileReader::MappedFileReader(true), m_templates(templates), m_isSet(isSet), m_isMasterDest(isMasterDest),
|
||||
m_fields(NULL) {}
|
||||
m_fields(nullptr) {}
|
||||
result_t getFieldMap(const string& preferLanguage, vector<string>* row, string* errorDescription) const override {
|
||||
if (row->empty()) {
|
||||
row->push_back("*name");
|
||||
@@ -512,8 +512,8 @@ int main() {
|
||||
istringstream dummystr("#");
|
||||
string errorDescription;
|
||||
vector<string> row;
|
||||
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
const DataField* fields = NULL;
|
||||
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
const DataField* fields = nullptr;
|
||||
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
|
||||
string check[5] = checks[i];
|
||||
istringstream isstr(check[0]);
|
||||
@@ -539,7 +539,7 @@ int main() {
|
||||
bool failedReadMatch = flags.find('R') != string::npos;
|
||||
bool failedWrite = flags.find('w') != string::npos;
|
||||
bool failedWriteMatch = flags.find('W') != string::npos;
|
||||
const char* findName = flags.find('I') == string::npos ? NULL : "x";
|
||||
const char* findName = flags.find('I') == string::npos ? nullptr : "x";
|
||||
ssize_t findIndex = -1;
|
||||
if (flags.find('i') != string::npos) {
|
||||
findIndex = parseSignedInt(flags.substr(flags.find('i')+1).c_str(), 10, 0, 9, &result);
|
||||
@@ -561,13 +561,13 @@ int main() {
|
||||
bool isTemplate = flags.find('t') != string::npos;
|
||||
string item;
|
||||
|
||||
if (fields != NULL) {
|
||||
if (fields != nullptr) {
|
||||
delete fields;
|
||||
fields = NULL;
|
||||
fields = nullptr;
|
||||
}
|
||||
if (isTemplate) {
|
||||
lineNo = baseLine + i;
|
||||
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", "
|
||||
<< errorDescription << endl;
|
||||
@@ -579,7 +579,7 @@ int main() {
|
||||
lineNo = 0;
|
||||
dummystr.clear();
|
||||
dummystr.str("#");
|
||||
result = reader.readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = reader.readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": read header error: " << getResultCode(result) << ", " << errorDescription
|
||||
<< endl;
|
||||
@@ -587,7 +587,7 @@ int main() {
|
||||
continue;
|
||||
}
|
||||
lineNo = baseLine + i;
|
||||
result = reader.readLineFromStream(&isstr, "", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = reader.readLineFromStream(&isstr, "", false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
fields = reader.m_fields;
|
||||
if (failedCreate) {
|
||||
if (result == RESULT_OK) {
|
||||
@@ -603,8 +603,8 @@ int main() {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
if (fields == NULL) {
|
||||
cout << "\"" << check[0] << "\": create error: NULL" << endl;
|
||||
if (fields == nullptr) {
|
||||
cout << "\"" << check[0] << "\": create error: nullptr" << endl;
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
@@ -649,9 +649,9 @@ int main() {
|
||||
|
||||
if (verbosity == 0) {
|
||||
istringstream input(expectStr);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeMstr, NULL);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeMstr, nullptr);
|
||||
if (result >= RESULT_OK) {
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeSstr, NULL);
|
||||
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeSstr, nullptr);
|
||||
}
|
||||
if (failedWrite) {
|
||||
if (result >= RESULT_OK) {
|
||||
@@ -673,7 +673,7 @@ int main() {
|
||||
}
|
||||
}
|
||||
delete fields;
|
||||
fields = NULL;
|
||||
fields = nullptr;
|
||||
}
|
||||
|
||||
delete templates;
|
||||
|
||||
@@ -25,7 +25,7 @@ using namespace ebusd;
|
||||
|
||||
int main() {
|
||||
Device* device = Device::create("/dev/ttyUSB20", true, false, false);
|
||||
if (device == NULL) {
|
||||
if (device == nullptr) {
|
||||
cout << "unable to create device" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ int main(int argc, char** argv) {
|
||||
if (!stream) {
|
||||
result = RESULT_ERR_NOTFOUND;
|
||||
} else {
|
||||
result = reader.readFromStream(stream, argv[argpos], time, false, NULL, &errorDescription, false, &hash, &size);
|
||||
result = reader.readFromStream(stream, argv[argpos], time, false, nullptr, &errorDescription, false, &hash, &size);
|
||||
}
|
||||
cout << argv[argpos] << " ";
|
||||
if (result != RESULT_OK) {
|
||||
|
||||
@@ -50,7 +50,7 @@ void verify(bool expectFailMatch, string type, string input,
|
||||
}
|
||||
}
|
||||
|
||||
DataFieldTemplates* templates = NULL;
|
||||
DataFieldTemplates* templates = nullptr;
|
||||
|
||||
namespace ebusd {
|
||||
|
||||
@@ -186,14 +186,14 @@ int main() {
|
||||
istringstream dummystr("#");
|
||||
string errorDescription;
|
||||
vector<string> row;
|
||||
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
lineNo = 0;
|
||||
MessageMap* messages = new MessageMap("");
|
||||
dummystr.clear();
|
||||
dummystr.str("#");
|
||||
messages->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
messages->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
vector< vector<string> > defaultsRows;
|
||||
Message* message = NULL;
|
||||
Message* message = nullptr;
|
||||
vector<MasterSymbolString*> mstrs;
|
||||
vector<SlaveSymbolString*> sstrs;
|
||||
mstrs.resize(1);
|
||||
@@ -222,7 +222,7 @@ int main() {
|
||||
lineNo = baseLine + i;
|
||||
cout << "line " << (lineNo+1) << " ";
|
||||
if (isTemplate) {
|
||||
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", " << errorDescription
|
||||
<< endl;
|
||||
@@ -236,7 +236,7 @@ int main() {
|
||||
}
|
||||
if (isstr.peek() == '*') {
|
||||
// store defaults or condition
|
||||
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": default read error: " << getResultCode(result) << ", " << errorDescription << endl;
|
||||
error = true;
|
||||
@@ -252,7 +252,7 @@ int main() {
|
||||
while (getline(stream, token, VALUE_SEPARATOR)) {
|
||||
if (pos >= mstrs.size()) {
|
||||
mstrs.resize(pos+1);
|
||||
} else if (mstrs[pos] != NULL) {
|
||||
} else if (mstrs[pos] != nullptr) {
|
||||
delete mstrs[pos];
|
||||
}
|
||||
mstrs[pos] = new MasterSymbolString();
|
||||
@@ -270,7 +270,7 @@ int main() {
|
||||
while (getline(stream, token, VALUE_SEPARATOR)) {
|
||||
if (pos >= sstrs.size()) {
|
||||
sstrs.resize(pos+1);
|
||||
} else if (sstrs[pos] != NULL) {
|
||||
} else if (sstrs[pos] != nullptr) {
|
||||
delete sstrs[pos];
|
||||
}
|
||||
sstrs[pos] = new SlaveSymbolString();
|
||||
@@ -287,7 +287,7 @@ int main() {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (mstrs[0] != NULL) {
|
||||
if (mstrs[0] != nullptr) {
|
||||
delete mstrs[0];
|
||||
}
|
||||
mstrs[0] = new MasterSymbolString();
|
||||
@@ -297,7 +297,7 @@ int main() {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
if (sstrs[0] != NULL) {
|
||||
if (sstrs[0] != nullptr) {
|
||||
delete sstrs[0];
|
||||
}
|
||||
sstrs[0] = new SlaveSymbolString();
|
||||
@@ -311,14 +311,14 @@ int main() {
|
||||
|
||||
if (isstr.peek() == EOF) {
|
||||
message = messages->find(*mstrs[0]);
|
||||
if (message == NULL) {
|
||||
cout << "\"" << check[2] << "\": find error: NULL" << endl;
|
||||
if (message == nullptr) {
|
||||
cout << "\"" << check[2] << "\": find error: nullptr" << endl;
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
cout << "\"" << check[2] << "\": find OK" << endl;
|
||||
} else {
|
||||
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
|
||||
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, nullptr, nullptr);
|
||||
if (failedCreate) {
|
||||
if (result == RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl;
|
||||
@@ -334,7 +334,7 @@ int main() {
|
||||
continue;
|
||||
}
|
||||
if (messages->size() == 0) {
|
||||
cout << "\"" << check[0] << "\": create error: NULL" << endl;
|
||||
cout << "\"" << check[0] << "\": create error: nullptr" << endl;
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ int main() {
|
||||
deque<Message*> msgs;
|
||||
messages->findAll("", "", "*", false, true, true, true, true, false, 0, 0, &msgs);
|
||||
if (msgs.empty()) {
|
||||
message = NULL;
|
||||
message = nullptr;
|
||||
cout << "\"" << check[0] << "\": create error: message not found" << endl;
|
||||
error = true;
|
||||
continue;
|
||||
@@ -364,7 +364,7 @@ int main() {
|
||||
Message* foundMessage = messages->find(*mstrs[0], false, true, true, true, false);
|
||||
if (foundMessage == message) {
|
||||
cout << " find OK" << endl;
|
||||
} else if (foundMessage == NULL) {
|
||||
} else if (foundMessage == nullptr) {
|
||||
cout << " find error: message not found by master " << mstrs[0]->getStr() << endl;
|
||||
error = true;
|
||||
continue;
|
||||
@@ -399,11 +399,11 @@ int main() {
|
||||
output.str("");
|
||||
output << str;
|
||||
} else {
|
||||
message->dump(NULL, true, &output);
|
||||
message->dump(nullptr, true, &output);
|
||||
}
|
||||
output << ": ";
|
||||
}
|
||||
result = message->decodeLastData(false, NULL, -1,
|
||||
result = message->decodeLastData(false, nullptr, -1,
|
||||
(decodeVerbose?OF_NAMES|OF_UNITS|OF_COMMENTS:0)|(decodeJson?OF_NAMES|OF_JSON:0), &output);
|
||||
if (result != RESULT_OK) {
|
||||
cout << " \"" << check[2] << "\" / \"" << check[3] << "\": decode error: "
|
||||
|
||||
@@ -58,9 +58,9 @@ bool HttpClient::parseUrl(const string& url, string& proto, string& host, uint16
|
||||
}
|
||||
port = 80;
|
||||
if (pos != string::npos) {
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
unsigned long value = strtoul(host.c_str()+pos+1, &strEnd, 10);
|
||||
if (strEnd == NULL || *strEnd != '\0' || value < 1 || value > 65535) {
|
||||
if (strEnd == nullptr || *strEnd != '\0' || value < 1 || value > 65535) {
|
||||
return false;
|
||||
}
|
||||
port = static_cast<uint16_t>(value);
|
||||
@@ -182,30 +182,30 @@ bool HttpClient::request(const string& method, const string& uri, const string&
|
||||
// Last-Modified: Wed, 21 Oct 2015 07:28:00 GMT
|
||||
struct tm t;
|
||||
pos += strlen("\r\nLast-Modified: ") + 5;
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
t.tm_mday = (int)strtol(hdrs + pos, &strEnd, 10);
|
||||
if (strEnd != hdrs + pos + 2 || t.tm_mday < 1 || t.tm_mday > 31) {
|
||||
t.tm_mday = -1;
|
||||
}
|
||||
t.tm_mon = indexToMonth[((hdrs[pos+4]&0x10)>>1) | (hdrs[pos+5]&0x17)] - 1;
|
||||
strEnd = NULL;
|
||||
strEnd = nullptr;
|
||||
t.tm_year = (int)strtol(hdrs + pos + 7, &strEnd, 10);
|
||||
if (strEnd != hdrs + pos + 11 || t.tm_year < 1970 || t.tm_year >= 3000) {
|
||||
t.tm_year = -1;
|
||||
} else {
|
||||
t.tm_year -= 1900;
|
||||
}
|
||||
strEnd = NULL;
|
||||
strEnd = nullptr;
|
||||
t.tm_hour = (int)strtol(hdrs + pos + 12, &strEnd, 10);
|
||||
if (strEnd != hdrs + pos + 14 || t.tm_hour > 23) {
|
||||
t.tm_hour = -1;
|
||||
}
|
||||
strEnd = NULL;
|
||||
strEnd = nullptr;
|
||||
t.tm_min = (int)strtol(hdrs + pos + 15, &strEnd, 10);
|
||||
if (strEnd != hdrs + pos + 17 || t.tm_min > 59) {
|
||||
t.tm_min = -1;
|
||||
}
|
||||
strEnd = NULL;
|
||||
strEnd = nullptr;
|
||||
t.tm_sec = (int)strtol(hdrs + pos + 18, &strEnd, 10);
|
||||
if (strEnd != hdrs + pos + 20 || t.tm_sec > 59) {
|
||||
t.tm_sec = -1;
|
||||
@@ -220,9 +220,9 @@ bool HttpClient::request(const string& method, const string& uri, const string&
|
||||
disconnect();
|
||||
return true;
|
||||
}
|
||||
char* strEnd = NULL;
|
||||
char* strEnd = nullptr;
|
||||
unsigned long length = strtoul(hdrs + pos + strlen("\r\nContent-Length: "), &strEnd, 10);
|
||||
if (strEnd == NULL || *strEnd != '\r') {
|
||||
if (strEnd == nullptr || *strEnd != '\r') {
|
||||
disconnect();
|
||||
response = "invalid content length ";
|
||||
return false;
|
||||
|
||||
@@ -100,10 +100,10 @@ class HttpClient {
|
||||
* @param uri the URI string.
|
||||
* @param body the optional body to send.
|
||||
* @param response the response body from the server (or the HTTP header on error).
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or NULL.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or nullptr.
|
||||
* @return true on success, false on error.
|
||||
*/
|
||||
bool get(const string& uri, const string& body, string& response, time_t* time = NULL);
|
||||
bool get(const string& uri, const string& body, string& response, time_t* time = nullptr);
|
||||
|
||||
/**
|
||||
* Execute a POST request.
|
||||
@@ -119,10 +119,10 @@ class HttpClient {
|
||||
* @param uri the URI string.
|
||||
* @param body the optional body to send.
|
||||
* @param response the response body from the server (or the HTTP header on error).
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or NULL.
|
||||
* @param time optional pointer to a @a time_t value for storing the modification time of the file, or nullptr.
|
||||
* @return true on success, false on error.
|
||||
*/
|
||||
bool request(const string& method, const string& uri, const string& body, string& response, time_t* time = NULL);
|
||||
bool request(const string& method, const string& uri, const string& body, string& response, time_t* time = nullptr);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ static const char *facilityNames[] = {
|
||||
"update",
|
||||
"other",
|
||||
"all",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
/** the name of each @a LogLevel. */
|
||||
@@ -49,7 +49,7 @@ static const char* levelNames[] = {
|
||||
"notice",
|
||||
"info",
|
||||
"debug",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
/** the current log level by log facility. */
|
||||
@@ -63,7 +63,7 @@ LogFacility parseLogFacility(const char* facility) {
|
||||
return lf_COUNT;
|
||||
}
|
||||
char *input = strdup(facility);
|
||||
char *opt = reinterpret_cast<char*>(input), *value = NULL;
|
||||
char *opt = reinterpret_cast<char*>(input), *value = nullptr;
|
||||
int val = getsubopt(&opt, (char *const *)facilityNames, &value);
|
||||
if (val < 0 || val >= lf_COUNT || value || *opt) {
|
||||
free(input);
|
||||
@@ -75,7 +75,7 @@ LogFacility parseLogFacility(const char* facility) {
|
||||
|
||||
int parseLogFacilities(const char* facilities) {
|
||||
char *input = strdup(facilities);
|
||||
char *opt = reinterpret_cast<char*>(input), *value = NULL;
|
||||
char *opt = reinterpret_cast<char*>(input), *value = nullptr;
|
||||
int newFacilites = 0;
|
||||
while (*opt) {
|
||||
int val = getsubopt(&opt, (char *const *)facilityNames, &value);
|
||||
@@ -98,7 +98,7 @@ LogLevel parseLogLevel(const char* level) {
|
||||
return ll_COUNT;
|
||||
}
|
||||
char *input = strdup(level);
|
||||
char *opt = reinterpret_cast<char*>(input), *value = NULL;
|
||||
char *opt = reinterpret_cast<char*>(input), *value = nullptr;
|
||||
int val = getsubopt(&opt, (char *const *)levelNames, &value);
|
||||
if (val < 0 || val >= ll_COUNT || value || *opt) {
|
||||
free(input);
|
||||
@@ -133,7 +133,7 @@ LogLevel getFacilityLogLevel(LogFacility facility) {
|
||||
|
||||
bool setLogFile(const char* filename) {
|
||||
FILE* newFile = fopen(filename, "a");
|
||||
if (newFile == NULL) {
|
||||
if (newFile == nullptr) {
|
||||
return false;
|
||||
}
|
||||
closeLogFile();
|
||||
@@ -142,11 +142,11 @@ bool setLogFile(const char* filename) {
|
||||
}
|
||||
|
||||
void closeLogFile() {
|
||||
if (s_logFile != NULL) {
|
||||
if (s_logFile != nullptr) {
|
||||
if (s_logFile != stdout) {
|
||||
fclose(s_logFile);
|
||||
}
|
||||
s_logFile = NULL;
|
||||
s_logFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ bool needsLog(const LogFacility facility, const LogLevel level) {
|
||||
}
|
||||
|
||||
void logWrite(const char* facility, const char* level, const char* message, va_list ap) {
|
||||
if (s_logFile == NULL) {
|
||||
if (s_logFile == nullptr) {
|
||||
return;
|
||||
}
|
||||
struct timespec ts;
|
||||
|
||||
@@ -41,8 +41,8 @@ class Queue {
|
||||
* Constructor.
|
||||
*/
|
||||
Queue() {
|
||||
pthread_mutex_init(&m_mutex, NULL);
|
||||
pthread_cond_init(&m_cond, NULL);
|
||||
pthread_mutex_init(&m_mutex, nullptr);
|
||||
pthread_cond_init(&m_cond, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class Queue {
|
||||
/**
|
||||
* Remove the first item from the queue optionally waiting for the queue being non-empty.
|
||||
* @param timeout the maximum time in seconds to wait for the queue being filled, or 0 for no wait.
|
||||
* @return the item, or NULL if no item is available within the specified time.
|
||||
* @return the item, or nullptr if no item is available within the specified time.
|
||||
*/
|
||||
T pop(int timeout = 0) {
|
||||
T item;
|
||||
@@ -93,7 +93,7 @@ class Queue {
|
||||
}
|
||||
}
|
||||
if (m_queue.empty()) {
|
||||
item = NULL;
|
||||
item = nullptr;
|
||||
} else {
|
||||
item = m_queue.front();
|
||||
m_queue.pop_front();
|
||||
@@ -137,13 +137,13 @@ class Queue {
|
||||
|
||||
/**
|
||||
* Return the first item in the queue without removing it.
|
||||
* @return the item, or NULL if no item is available.
|
||||
* @return the item, or nullptr if no item is available.
|
||||
*/
|
||||
T peek() {
|
||||
T item;
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
if (m_queue.empty()) {
|
||||
item = NULL;
|
||||
item = nullptr;
|
||||
} else {
|
||||
item = m_queue.front();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ using std::streamsize;
|
||||
RotateFile::~RotateFile() {
|
||||
if (m_stream) {
|
||||
fclose(m_stream);
|
||||
m_stream = NULL;
|
||||
m_stream = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ bool RotateFile::setEnabled(bool enabled) {
|
||||
m_enabled = enabled;
|
||||
if (m_stream) {
|
||||
fclose(m_stream);
|
||||
m_stream = NULL;
|
||||
m_stream = nullptr;
|
||||
}
|
||||
if (enabled) {
|
||||
m_stream = fopen(m_fileName.c_str(), m_textMode ? "w" : "wb");
|
||||
|
||||
+12
-12
@@ -54,14 +54,14 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port, int ti
|
||||
struct hostent* he;
|
||||
|
||||
he = gethostbyname(server.c_str());
|
||||
if (he == NULL) {
|
||||
return NULL;
|
||||
if (he == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(&address.sin_addr, he->h_addr_list[0], he->h_length);
|
||||
} else {
|
||||
ret = inet_aton(server.c_str(), &address.sin_addr);
|
||||
if (ret == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port, int ti
|
||||
|
||||
int sfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sfd < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#ifndef HAVE_PPOLL
|
||||
#ifndef HAVE_PSELECT
|
||||
@@ -79,13 +79,13 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port, int ti
|
||||
#endif
|
||||
if (timeout > 0 && fcntl(sfd, F_SETFL, O_NONBLOCK) < 0) { // set non-blocking
|
||||
close(sfd);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ret = ::connect(sfd, (struct sockaddr *) &address, sizeof(address));
|
||||
if (ret != 0) {
|
||||
if (ret < 0 && (timeout <= 0 || errno != EINPROGRESS)) {
|
||||
close(sfd);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (timeout > 0) {
|
||||
struct timespec tdiff;
|
||||
@@ -97,7 +97,7 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port, int ti
|
||||
memset(fds, 0, sizeof(fds));
|
||||
fds[0].fd = sfd;
|
||||
fds[0].events = POLLIN|POLLOUT;
|
||||
ret = ppoll(fds, nfds, &tdiff, NULL);
|
||||
ret = ppoll(fds, nfds, &tdiff, nullptr);
|
||||
if (ret == 1 && fds[0].revents & POLLERR) {
|
||||
ret = -1;
|
||||
}
|
||||
@@ -107,20 +107,20 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port, int ti
|
||||
FD_ZERO(&writefds);
|
||||
FD_ZERO(&exceptfds);
|
||||
FD_SET(sfd, &readfds);
|
||||
ret = pselect(sfd + 1, &readfds, &writefds, &exceptfds, &tdiff, NULL);
|
||||
ret = pselect(sfd + 1, &readfds, &writefds, &exceptfds, &tdiff, nullptr);
|
||||
if (ret >= 1 && FD_ISSET(sfd, &exceptfds)) {
|
||||
ret = -1;
|
||||
}
|
||||
#endif
|
||||
if (ret == -1 || ret == 0) {
|
||||
close(sfd);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (timeout > 0 && fcntl(sfd, F_SETFL, 0) < 0) { // set blocking again
|
||||
close(sfd);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
TCPSocket* s = new TCPSocket(sfd, &address);
|
||||
if (timeout > 0) {
|
||||
@@ -164,7 +164,7 @@ int TCPServer::start() {
|
||||
|
||||
TCPSocket* TCPServer::newSocket() {
|
||||
if (!m_listening) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
socketaddress address;
|
||||
socklen_t len = sizeof(address);
|
||||
@@ -173,7 +173,7 @@ TCPSocket* TCPServer::newSocket() {
|
||||
|
||||
int sfd = accept(m_lfd, (struct sockaddr*) &address, &len);
|
||||
if (sfd < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return new TCPSocket(sfd, &address);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ebusd {
|
||||
|
||||
void* Thread::runThread(void* arg) {
|
||||
reinterpret_cast<Thread*>(arg)->enter();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Thread::~Thread() {
|
||||
@@ -38,7 +38,7 @@ Thread::~Thread() {
|
||||
}
|
||||
|
||||
bool Thread::start(const char* name) {
|
||||
int result = pthread_create(&m_threadid, NULL, runThread, this);
|
||||
int result = pthread_create(&m_threadid, nullptr, runThread, this);
|
||||
if (result == 0) {
|
||||
#ifdef HAVE_PTHREAD_SETNAME_NP
|
||||
#ifndef __MACH__
|
||||
@@ -55,7 +55,7 @@ bool Thread::join() {
|
||||
int result = -1;
|
||||
if (m_started) {
|
||||
m_stopped = true;
|
||||
result = pthread_join(m_threadid, NULL);
|
||||
result = pthread_join(m_threadid, nullptr);
|
||||
if (result == 0) {
|
||||
m_started = false;
|
||||
}
|
||||
@@ -72,8 +72,8 @@ void Thread::enter() {
|
||||
|
||||
WaitThread::WaitThread()
|
||||
: Thread() {
|
||||
pthread_mutex_init(&m_mutex, NULL);
|
||||
pthread_cond_init(&m_cond, NULL);
|
||||
pthread_mutex_init(&m_mutex, nullptr);
|
||||
pthread_cond_init(&m_cond, nullptr);
|
||||
}
|
||||
|
||||
WaitThread::~WaitThread() {
|
||||
|
||||
@@ -43,7 +43,7 @@ class Thread {
|
||||
/**
|
||||
* Thread entry helper for pthread_create.
|
||||
* @param arg pointer to the @a Thread.
|
||||
* @return NULL.
|
||||
* @return nullptr.
|
||||
*/
|
||||
static void* runThread(void* arg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user