code style.

This commit is contained in:
Roland Jax
2014-11-04 20:23:43 +01:00
parent e587e2413d
commit 727bf600da
2 changed files with 13 additions and 15 deletions
+12 -14
View File
@@ -79,15 +79,13 @@ const std::string SymbolString::getDataStr(const bool unescape)
for (size_t i = 0; i < m_data.size(); i++) { for (size_t i = 0; i < m_data.size(); i++) {
unsigned char value = m_data[i]; unsigned char value = m_data[i];
if (m_unescapeState == 0 && unescape == true && previousEscape == true) { if (m_unescapeState == 0 && unescape == true && previousEscape == true) {
if (value == 0x00) { if (value == 0x00)
sstr << "a9"; // ESC sstr << "a9"; // ESC
} else if (value == 0x01)
else if (value == 0x01) {
sstr << "aa"; // SYN sstr << "aa"; // SYN
} else
else {
sstr << "XX"; // invalid escape sequence sstr << "XX"; // invalid escape sequence
}
previousEscape = false; previousEscape = false;
} }
else if (m_unescapeState == 0 && unescape == true && value == ESC) { else if (m_unescapeState == 0 && unescape == true && value == ESC) {
@@ -123,9 +121,9 @@ int SymbolString::push_back(const unsigned char value, const bool isEscaped, con
} }
else { else {
m_data.push_back(value); m_data.push_back(value);
if (updateCRC) { if (updateCRC)
addCRC(value); addCRC(value);
}
} }
return RESULT_OK; return RESULT_OK;
} }
@@ -149,9 +147,9 @@ int SymbolString::push_back(const unsigned char value, const bool isEscaped, con
return RESULT_OK; return RESULT_OK;
} }
else if (m_unescapeState != 1) { else if (m_unescapeState != 1) {
if (updateCRC) { if (updateCRC)
addCRC(value); addCRC(value);
}
if (value == 0x00) { if (value == 0x00) {
m_data.push_back(ESC); m_data.push_back(ESC);
m_unescapeState = 1; m_unescapeState = 1;
@@ -165,15 +163,15 @@ int SymbolString::push_back(const unsigned char value, const bool isEscaped, con
return RESULT_ERR_ESC; // invalid escape sequence return RESULT_ERR_ESC; // invalid escape sequence
} }
else if (value == ESC) { else if (value == ESC) {
if (updateCRC) { if (updateCRC)
addCRC(value); addCRC(value);
}
m_unescapeState = 2; m_unescapeState = 2;
return RESULT_IN_ESC; return RESULT_IN_ESC;
} }
if (updateCRC) { if (updateCRC)
addCRC(value); addCRC(value);
}
m_data.push_back(value); m_data.push_back(value);
return RESULT_OK; return RESULT_OK;
} }
+1 -1
View File
@@ -82,7 +82,7 @@ public:
* @param other the other instance. * @param other the other instance.
* @return true if this instance is equal to the other instance (i.e. both escaped or both unescaped and same symbols). * @return true if this instance is equal to the other instance (i.e. both escaped or both unescaped and same symbols).
*/ */
bool operator==(SymbolString other) { return (m_unescapeState==0)==(m_unescapeState==0) && m_data==other.m_data; } bool operator==(SymbolString other) { return (m_unescapeState==0)==(other.m_unescapeState==0) && m_data==other.m_data; }
/** /**
* @brief Appends a the symbol to the end of the symbol string and escapes/unescapes it if necessary. * @brief Appends a the symbol to the end of the symbol string and escapes/unescapes it if necessary.
* @param value the symbol to append. * @param value the symbol to append.