Merge branch 'master' of https://github.com/yuhu-/ebusd
Conflicts: src/ebusd/baseloop.h src/lib/ebus/data.h src/lib/ebus/message.h src/lib/ebus/result.h src/lib/ebus/symbol.h
This commit is contained in:
@@ -48,11 +48,13 @@ public:
|
||||
* @brief Creates a new unescaped empty instance.
|
||||
*/
|
||||
SymbolString() : m_unescapeState(1), m_crc(0) {}
|
||||
|
||||
/**
|
||||
* @brief Creates a new escaped instance from an unescaped hex string and adds the calculated CRC.
|
||||
* @param str the unescaped hex string.
|
||||
*/
|
||||
SymbolString(const string& str);
|
||||
|
||||
/**
|
||||
* @brief Creates a new escaped or unescaped instance from another @a SymbolString and adds the calculated CRC.
|
||||
* @param str the @a SymbolString top copy from.
|
||||
@@ -60,30 +62,35 @@ public:
|
||||
* @param addCrc whether to add the calculated CRC as last symbol.
|
||||
*/
|
||||
SymbolString(const SymbolString& str, const bool escape, const bool addCrc=true);
|
||||
|
||||
/**
|
||||
* @brief Creates a new unescaped instance from a hex string.
|
||||
* @param isEscaped whether the hex string is escaped and shall be unescaped.
|
||||
* @param str the hex string.
|
||||
*/
|
||||
SymbolString(const string& str, const bool isEscaped);
|
||||
|
||||
/**
|
||||
* @brief Returns the symbols as hex string.
|
||||
* @param unescape whether to unescape an escaped instance.
|
||||
* @return the symbols as hex string.
|
||||
*/
|
||||
const string getDataStr(const bool unescape=true);
|
||||
|
||||
/**
|
||||
* @brief Returns a reference to the symbol at the specified index.
|
||||
* @param index the index of the symbol to return.
|
||||
* @return the reference to the symbol at the specified index.
|
||||
*/
|
||||
unsigned char& operator[](const size_t index) { if (index >= m_data.size()) m_data.resize(index+1, 0); return m_data[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns the symbol at the specified index.
|
||||
* @param index the index of the symbol to return.
|
||||
* @return the symbol at the specified index.
|
||||
*/
|
||||
const unsigned char& operator[](const size_t index) const { return m_data[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns whether this instance is equal to the other instance.
|
||||
* @param other the other instance.
|
||||
@@ -103,6 +110,7 @@ public:
|
||||
cout<<"["<<static_cast<unsigned>(other.m_unescapeState)<<"]"<<endl;
|
||||
return ret;*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Appends a the symbol to the end of the symbol string and escapes/unescapes it if necessary.
|
||||
* @param value the symbol to append.
|
||||
@@ -113,16 +121,19 @@ public:
|
||||
* RESULT_ERR_ESC if this is an unescaped instance and an invalid escaped sequence was detected.
|
||||
*/
|
||||
result_t push_back(const unsigned char value, const bool isEscaped=true, const bool updateCRC=true);
|
||||
|
||||
/**
|
||||
* @brief Returns the number of symbols in this symbol string.
|
||||
* @return the number of available symbols.
|
||||
*/
|
||||
unsigned char size() const { return (unsigned char)m_data.size(); }
|
||||
|
||||
/**
|
||||
* @brief Returns the calculated CRC.
|
||||
* @return the calculated CRC.
|
||||
*/
|
||||
unsigned char getCRC() const { return m_crc; }
|
||||
|
||||
/**
|
||||
* @brief Clears the symbols.
|
||||
*/
|
||||
@@ -147,12 +158,14 @@ private:
|
||||
* @brief the string of bus symbols.
|
||||
*/
|
||||
vector<unsigned char> m_data;
|
||||
|
||||
/**
|
||||
* @brief 0 if the symbols in @a m_data are escaped,
|
||||
* 1 if the symbols in @a m_data are unescaped and the last symbol passed to @a push_back was a normal symbol,
|
||||
* 2 if the symbols in @a m_data are unescaped and the last symbol passed to @a push_back was the escape symbol.
|
||||
*/
|
||||
int m_unescapeState;
|
||||
|
||||
/**
|
||||
* @brief the calculated CRC.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user