added option to skip last symbol to addAll()
This commit is contained in:
@@ -47,12 +47,16 @@ static const unsigned char CRC_LOOKUP_TABLE[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void SymbolString::addAll(const SymbolString& str)
|
void SymbolString::addAll(const SymbolString& str, bool skipLastSymbol)
|
||||||
{
|
{
|
||||||
bool addCrc = m_unescapeState == 0;
|
bool addCrc = m_unescapeState == 0;
|
||||||
bool isEscaped = str.m_unescapeState == 0;
|
bool isEscaped = str.m_unescapeState == 0;
|
||||||
vector<unsigned char> data = str.m_data;
|
vector<unsigned char> data = str.m_data;
|
||||||
for (size_t i = 0; i < data.size(); i++) {
|
size_t end = data.size();
|
||||||
|
if (end>0 && skipLastSymbol) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < end; i++) {
|
||||||
push_back(data[i], isEscaped, addCrc);
|
push_back(data[i], isEscaped, addCrc);
|
||||||
}
|
}
|
||||||
if (addCrc)
|
if (addCrc)
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add all symbols from the other @a SymbolString and the calculated CRC if escaped.
|
* Add all symbols from the other @a SymbolString and the calculated CRC if escaped.
|
||||||
* @param str the @a SymbolString to copy from.
|
* @param str the @a SymbolString to copy from.
|
||||||
|
* @param skipLastSymbol whether to skip the last symbol (probably the CRC).
|
||||||
*/
|
*/
|
||||||
void addAll(const SymbolString& str);
|
void addAll(const SymbolString& str, const bool skipLastSymbol=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the escaped or unescaped hex @a string, add all symbols, and add the calculated CRC if escaped.
|
* Parse the escaped or unescaped hex @a string, add all symbols, and add the calculated CRC if escaped.
|
||||||
|
|||||||
Reference in New Issue
Block a user