code style

This commit is contained in:
john30
2017-01-14 19:00:47 +01:00
parent ebcb260d5f
commit 5bf2f124b3
42 changed files with 1347 additions and 1066 deletions
+1 -1
View File
@@ -26,4 +26,4 @@ bool libebus_contrib_register() {
return true;
}
} // namespace ebusd
} // namespace ebusd
+2 -2
View File
@@ -32,6 +32,6 @@ namespace ebusd {
*/
bool libebus_contrib_register();
} // namespace ebusd
} // namespace ebusd
#endif // LIB_EBUS_CONTRIB_CONTRIB_H_
#endif // LIB_EBUS_CONTRIB_CONTRIB_H_
+17 -17
View File
@@ -73,11 +73,11 @@ result_t TemParamDataType::readSymbols(SymbolString& input, const bool isMaster,
}
int grp = 0, num = 0;
if (isMaster) {
grp = (value & 0x1f); // grp in bits 0...5
num = ((value >> 8) & 0x7f); // num in bits 8...13
grp = (value & 0x1f); // grp in bits 0...5
num = ((value >> 8) & 0x7f); // num in bits 8...13
} else {
grp = ((value >> 7) & 0x1f); // grp in bits 7...11
num = (value & 0x7f); // num in bits 0...6
grp = ((value >> 7) & 0x1f); // grp in bits 7...11
num = (value & 0x7f); // num in bits 0...6
}
if (outputFormat & OF_JSON) {
output << '"';
@@ -86,7 +86,7 @@ result_t TemParamDataType::readSymbols(SymbolString& input, const bool isMaster,
if (outputFormat & OF_JSON) {
output << '"';
}
output << setfill(' ') << setw(0); // reset
output << setfill(' ') << setw(0); // reset
return RESULT_OK;
}
@@ -99,45 +99,45 @@ result_t TemParamDataType::writeSymbols(istringstream& input,
const char* str = input.str().c_str();
if (strcasecmp(str, NULL_VALUE) == 0) {
value = m_replacement; // replacement value
value = m_replacement; // replacement value
} else {
if (input.eof() || !getline(input, token, '-')) {
return RESULT_ERR_EOF; // incomplete
return RESULT_ERR_EOF; // incomplete
}
str = token.c_str();
if (str == NULL || *str == 0) {
return RESULT_ERR_EOF; // input too short
return RESULT_ERR_EOF; // input too short
}
char* strEnd = NULL;
grp = (unsigned int)strtoul(str, &strEnd, 10);
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
return RESULT_ERR_INVALID_NUM; // invalid value
return RESULT_ERR_INVALID_NUM; // invalid value
}
if (input.eof() || !getline(input, token, '-')) {
return RESULT_ERR_EOF; // incomplete
return RESULT_ERR_EOF; // incomplete
}
str = token.c_str();
if (str == NULL || *str == 0) {
return RESULT_ERR_EOF; // input too short
return RESULT_ERR_EOF; // input too short
}
strEnd = NULL;
num = (unsigned int)strtoul(str, &strEnd, 10);
if (strEnd == NULL || strEnd == str || *strEnd != 0) {
return RESULT_ERR_INVALID_NUM; // invalid value
return RESULT_ERR_INVALID_NUM; // invalid value
}
if (grp < 0 || grp > 0x1f || num < 0 || num > 0x7f) {
return RESULT_ERR_OUT_OF_RANGE; // value out of range
return RESULT_ERR_OUT_OF_RANGE; // value out of range
}
if (isMaster) {
value = grp | (num << 8); // grp in bits 0...5, num in bits 8...13
value = grp | (num << 8); // grp in bits 0...5, num in bits 8...13
} else {
value = (grp << 7) | num; // grp in bits 7...11, num in bits 0...6
value = (grp << 7) | num; // grp in bits 7...11, num in bits 0...6
}
}
if (value < getMinValue() || value > getMaxValue()) {
return RESULT_ERR_OUT_OF_RANGE; // value out of range
return RESULT_ERR_OUT_OF_RANGE; // value out of range
}
return writeRawValue(value, offset, length, output, usedLength);
}
} // namespace ebusd
} // namespace ebusd
+3 -3
View File
@@ -41,7 +41,7 @@ namespace ebusd {
* data.
*/
class TemParamDataType : public NumberDataType {
public:
public:
/**
* Constructs a new instance.
* @param id the type identifier.
@@ -68,6 +68,6 @@ class TemParamDataType : public NumberDataType {
*/
void contrib_tem_register();
} // namespace ebusd
} // namespace ebusd
#endif // LIB_EBUS_CONTRIB_TEM_H_
#endif // LIB_EBUS_CONTRIB_TEM_H_
+8 -4
View File
@@ -108,7 +108,8 @@ int main() {
fields = NULL;
}
vector<string>::iterator it = entries.begin();
result = DataField::create(it, entries.end(), templates, fields, isSet, false, (mstr[1] == BROADCAST || isMaster(mstr[1])));
result = DataField::create(it, entries.end(), templates, fields, isSet, false,
(mstr[1] == BROADCAST || isMaster(mstr[1])));
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": create error: " << getResultCode(result) << endl;
error = true;
@@ -132,13 +133,15 @@ int main() {
SymbolString writeMstr(false);
result = writeMstr.parseHex(mstr.getDataStr(true, false).substr(0, 10));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getDataStr(true, false).substr(0, 10) << "\" error: " << getResultCode(result) << endl;
cout << " parse \"" << mstr.getDataStr(true, false).substr(0, 10) << "\" error: " << getResultCode(result)
<< endl;
error = true;
}
SymbolString writeSstr(false);
result = writeSstr.parseHex(sstr.getDataStr(true, false).substr(0, 2));
if (result != RESULT_OK) {
cout << " parse \"" << sstr.getDataStr(true, false).substr(0, 2) << "\" error: " << getResultCode(result) << endl;
cout << " parse \"" << sstr.getDataStr(true, false).substr(0, 2) << "\" error: " << getResultCode(result)
<< endl;
error = true;
}
result = fields->read(pt_masterData, mstr, 0, output, 0, -1, false);
@@ -183,7 +186,8 @@ int main() {
error = true;
} else {
bool match = mstr == writeMstr && sstr == writeSstr;
verify(failedWriteMatch, "write", expectStr, match, mstr.getDataStr(true, false) + " " + sstr.getDataStr(true, false), writeMstr.getDataStr(true, false) + " " + writeSstr.getDataStr(true, false));
verify(failedWriteMatch, "write", expectStr, match, mstr.getDataStr(true, false) + " "
+ sstr.getDataStr(true, false), writeMstr.getDataStr(true, false) + " " + writeSstr.getDataStr(true, false));
}
delete fields;
fields = NULL;