use nullptr instead of NULL
This commit is contained in:
+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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user