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:
+54
-1
@@ -85,7 +85,6 @@ typedef struct {
|
||||
const unsigned char precisionOrFirstBit; //!< @a bt_number: precision for formatting or offset to first bit if (@a numBits%8)!=0
|
||||
} dataType_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parse an unsigned int value.
|
||||
* @param str the string to parse.
|
||||
@@ -127,10 +126,12 @@ public:
|
||||
*/
|
||||
DataField(const string name, const string comment)
|
||||
: m_name(name), m_comment(comment) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~DataField() {}
|
||||
|
||||
/**
|
||||
* @brief Factory method for creating new instances.
|
||||
* @param it the iterator to traverse for the definition parts.
|
||||
@@ -145,12 +146,14 @@ public:
|
||||
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
|
||||
DataFieldTemplates* templates, DataField*& returnField,
|
||||
const bool isSetMessage=false, const unsigned char dstAddress=SYN);
|
||||
|
||||
/**
|
||||
* @brief Returns the length of this field (or contained fields) in bytes.
|
||||
* @param partType the message part of the contained fields to limit the length calculation to.
|
||||
* @return the length of this field (or contained fields) in bytes.
|
||||
*/
|
||||
virtual unsigned char getLength(PartType partType) = 0;
|
||||
|
||||
/**
|
||||
* @brief Derives a new DataField from this field.
|
||||
* @param name the field name.
|
||||
@@ -166,21 +169,25 @@ public:
|
||||
string unit, const PartType partType,
|
||||
unsigned int divisor, map<unsigned int, string> values,
|
||||
vector<SingleDataField*>& fields) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the field name.
|
||||
* @return the field name.
|
||||
*/
|
||||
string getName() const { return m_name; }
|
||||
|
||||
/**
|
||||
* @brief Get the field comment.
|
||||
* @return the field comment.
|
||||
*/
|
||||
string getComment() const { return m_comment; }
|
||||
|
||||
/**
|
||||
* @brief Dump the field settings to the output.
|
||||
* @param output the @a ostream to dump to.
|
||||
*/
|
||||
virtual void dump(ostream& output) = 0;
|
||||
|
||||
/**
|
||||
* @brief Reads the value from the @a SymbolString.
|
||||
* @param partType the @a PartType of the data.
|
||||
@@ -201,6 +208,7 @@ public:
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, const char* filterName=NULL,
|
||||
char separator=UI_FIELD_SEPARATOR) = 0;
|
||||
|
||||
/**
|
||||
* @brief Writes the value to the master or slave @a SymbolString.
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
@@ -218,6 +226,7 @@ protected:
|
||||
|
||||
/** the field name. */
|
||||
const string m_name;
|
||||
|
||||
/** the field comment. */
|
||||
const string m_comment;
|
||||
|
||||
@@ -246,28 +255,34 @@ public:
|
||||
: DataField(name, comment),
|
||||
m_unit(unit), m_dataType(dataType), m_partType(partType),
|
||||
m_length(length) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~SingleDataField() {}
|
||||
|
||||
/**
|
||||
* @brief Get the value unit.
|
||||
* @return the value unit.
|
||||
*/
|
||||
string getUnit() const { return m_unit; }
|
||||
|
||||
/**
|
||||
* @brief Get whether this field is ignored.
|
||||
* @return whether this field is ignored.
|
||||
*/
|
||||
bool isIgnored() const { return (m_dataType.flags & IGN) != 0; }
|
||||
|
||||
/**
|
||||
* @brief Get the message part in which the field is stored.
|
||||
* @return the message part in which the field is stored.
|
||||
*/
|
||||
PartType getPartType() const { return m_partType; }
|
||||
|
||||
// @copydoc
|
||||
virtual unsigned char getLength(PartType partType) { return partType == m_partType ? m_length : 0; };
|
||||
// re-use same position as previous field as not all bits of fully consumed yet
|
||||
|
||||
/**
|
||||
* @brief Get whether this field uses a full byte offset.
|
||||
* @param after @p true to check after consuming the bits, false to check before.
|
||||
@@ -275,14 +290,17 @@ public:
|
||||
* only consumes a part of a byte and a subsequent field may re-use the same offset.
|
||||
*/
|
||||
virtual bool hasFullByteOffset(bool after) { return true; }
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t read(const PartType partType,
|
||||
SymbolString& data, unsigned char offset,
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, const char* filterName=NULL,
|
||||
char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t write(istringstream& input,
|
||||
const PartType partType, SymbolString& data,
|
||||
@@ -298,6 +316,7 @@ protected:
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t readSymbols(SymbolString& input, const unsigned char offset, ostringstream& output) = 0;
|
||||
|
||||
/**
|
||||
* @brief Internal method for writing the field to a @a SymbolString.
|
||||
* @param input the @a istringstream to parse the formatted value from.
|
||||
@@ -311,10 +330,13 @@ protected:
|
||||
|
||||
/** the value unit. */
|
||||
const string m_unit;
|
||||
|
||||
/** the data type definition. */
|
||||
const dataType_t m_dataType;
|
||||
|
||||
/** the message part in which the field is stored. */
|
||||
const PartType m_partType;
|
||||
|
||||
/** the number of symbols in the message part in which the field is stored. */
|
||||
const unsigned char m_length;
|
||||
|
||||
@@ -341,15 +363,18 @@ public:
|
||||
const string unit, const dataType_t dataType, const PartType partType,
|
||||
const unsigned char length)
|
||||
: SingleDataField(name, comment, unit, dataType, partType, length) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~StringDataField() {}
|
||||
|
||||
// @copydoc
|
||||
virtual result_t derive(string name, string comment,
|
||||
string unit, const PartType partType,
|
||||
unsigned int divisor, map<unsigned int, string> values,
|
||||
vector<SingleDataField*>& fields);
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
@@ -357,6 +382,7 @@ protected:
|
||||
|
||||
// @copydoc
|
||||
virtual result_t readSymbols(SymbolString& input, const unsigned char offset, ostringstream& output);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t writeSymbols(istringstream& input, const unsigned char offset, SymbolString& output);
|
||||
|
||||
@@ -386,12 +412,15 @@ public:
|
||||
const unsigned char length, const unsigned char bitCount, const unsigned char bitOffset)
|
||||
: SingleDataField(name, comment, unit, dataType, partType, length),
|
||||
m_bitCount(bitCount), m_bitOffset(bitOffset) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~NumericDataField() {}
|
||||
|
||||
// @copydoc
|
||||
virtual bool hasFullByteOffset(bool after);
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
@@ -405,6 +434,7 @@ protected:
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t readRawValue(SymbolString& input, const unsigned char offset, unsigned int& value);
|
||||
|
||||
/**
|
||||
* @brief Internal method for writing the raw value to a @a SymbolString.
|
||||
* @param value the raw value to write.
|
||||
@@ -448,15 +478,18 @@ public:
|
||||
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
||||
(dataType.maxBits < 8) ? dataType.precisionOrFirstBit : 0),
|
||||
m_divisor(divisor) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~NumberDataField() {}
|
||||
|
||||
// @copydoc
|
||||
virtual result_t derive(string name, string comment,
|
||||
string unit, const PartType partType,
|
||||
unsigned int divisor, map<unsigned int, string> values,
|
||||
vector<SingleDataField*>& fields);
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
@@ -464,6 +497,7 @@ protected:
|
||||
|
||||
// @copydoc
|
||||
virtual result_t readSymbols(SymbolString& input, const unsigned char offset, ostringstream& output);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t writeSymbols(istringstream& input, const unsigned char offset, SymbolString& output);
|
||||
|
||||
@@ -500,15 +534,18 @@ public:
|
||||
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
||||
(dataType.maxBits < 8) ? dataType.precisionOrFirstBit : 0),
|
||||
m_values(values) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~ValueListDataField() {}
|
||||
|
||||
// @copydoc
|
||||
virtual result_t derive(string name, string comment,
|
||||
string unit, const PartType partType, unsigned int divisor,
|
||||
map<unsigned int, string> values,
|
||||
vector<SingleDataField*>& fields);
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
@@ -516,6 +553,7 @@ protected:
|
||||
|
||||
// @copydoc
|
||||
virtual result_t readSymbols(SymbolString& input, const unsigned char offset, ostringstream& output);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t writeSymbols(istringstream& input, const unsigned char offset, SymbolString& output);
|
||||
|
||||
@@ -539,6 +577,7 @@ public:
|
||||
* @return the @a DataFieldSet for parsing the identification message.
|
||||
*/
|
||||
static DataFieldSet* createIdentFields();
|
||||
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
* @param name the field name.
|
||||
@@ -549,42 +588,51 @@ public:
|
||||
const vector<SingleDataField*> fields)
|
||||
: DataField(name, comment),
|
||||
m_fields(fields) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~DataFieldSet();
|
||||
|
||||
// @copydoc
|
||||
virtual unsigned char getLength(PartType partType);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t derive(string name, string comment,
|
||||
string unit, const PartType partType,
|
||||
unsigned int divisor, map<unsigned int, string> values,
|
||||
vector<SingleDataField*>& fields);
|
||||
|
||||
/**
|
||||
* @brief Returns the @a SingleDataField at the specified index.
|
||||
* @param index the index of the @a SingleDataField to return.
|
||||
* @return the @a SingleDataField at the specified index, or NULL.
|
||||
*/
|
||||
SingleDataField* operator[](const size_t index) { if (index >= m_fields.size()) return NULL; return m_fields[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns the @a SingleDataField at the specified index.
|
||||
* @param index the index of the @a SingleDataField to return.
|
||||
* @return the @a SingleDataField at the specified index, or NULL.
|
||||
*/
|
||||
const SingleDataField* operator[](const size_t index) const { if (index >= m_fields.size()) return NULL; return m_fields[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of @a SingleDataFields instances in this set.
|
||||
* @return the number of available @a SingleDataField instances.
|
||||
*/
|
||||
size_t size() const { return m_fields.size(); }
|
||||
|
||||
// @copydoc
|
||||
virtual void dump(ostream& output);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t read(const PartType partType,
|
||||
SymbolString& data, unsigned char offset,
|
||||
ostringstream& output, bool leadingSeparator=false,
|
||||
bool verbose=false, const char* filterName=NULL,
|
||||
char separator=UI_FIELD_SEPARATOR);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t write(istringstream& input,
|
||||
const PartType partType, SymbolString& data,
|
||||
@@ -609,14 +657,17 @@ public:
|
||||
* @brief Constructs a new instance.
|
||||
*/
|
||||
DataFieldTemplates() : FileReader<void*>::FileReader(false) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~DataFieldTemplates() { clear(); }
|
||||
|
||||
/**
|
||||
* @brief Removes all @a DataField instances.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Adds a template @a DataField instance to this map.
|
||||
* @param field the @a DataField instance to add.
|
||||
@@ -625,8 +676,10 @@ public:
|
||||
* Note: the caller may not free the added instance on success.
|
||||
*/
|
||||
result_t add(DataField* field, bool replace=false);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t addFromFile(vector<string>& row, void* arg, vector< vector<string> >* defaults, const string& filename, unsigned int lineNo);
|
||||
|
||||
/**
|
||||
* @brief Gets the template @a DataField instance with the specified name.
|
||||
* @param name the name of the template to get.
|
||||
|
||||
+38
-1
@@ -61,6 +61,7 @@ public:
|
||||
const unsigned char srcAddress, const unsigned char dstAddress,
|
||||
const vector<unsigned char> id, DataField* data,
|
||||
const unsigned int pollPriority);
|
||||
|
||||
/**
|
||||
* @brief Construct a new temporary instance.
|
||||
* @param isSet whether this is a set message.
|
||||
@@ -73,10 +74,12 @@ public:
|
||||
Message(const bool isSet, const bool isPassive,
|
||||
const unsigned char pb, const unsigned char sb,
|
||||
DataField* data);
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~Message() { delete m_data; }
|
||||
|
||||
/**
|
||||
* @brief Factory method for creating a new instance.
|
||||
* @param it the iterator to traverse for the definition parts.
|
||||
@@ -90,52 +93,62 @@ public:
|
||||
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
|
||||
vector< vector<string> >* defaultsRows,
|
||||
DataFieldTemplates* templates, Message*& returnValue);
|
||||
|
||||
/**
|
||||
* @brief Get the optional device class.
|
||||
* @return the optional device class.
|
||||
*/
|
||||
string getClass() const { return m_class; }
|
||||
|
||||
/**
|
||||
* @brief Get the message name (unique within the same class and type).
|
||||
* @return the message name (unique within the same class and type).
|
||||
*/
|
||||
string getName() const { return m_name; }
|
||||
|
||||
/**
|
||||
* @brief Get whether this is a set message.
|
||||
* @return whether this is a set message.
|
||||
*/
|
||||
bool isSet() const { return m_isSet; }
|
||||
|
||||
/**
|
||||
* @brief Get whether message can be initiated only by a participant other than us.
|
||||
* @return true if message can only be initiated by a participant other than us,
|
||||
* false if message can be initiated by any participant.
|
||||
*/
|
||||
bool isPassive() const { return m_isPassive; }
|
||||
|
||||
/**
|
||||
* @brief Get the comment.
|
||||
* @return the comment.
|
||||
*/
|
||||
string getComment() const { return m_comment; }
|
||||
|
||||
/**
|
||||
* @brief Get the source address.
|
||||
* @return the source address, or @a SYN for any.
|
||||
*/
|
||||
unsigned char getSrcAddress() const { return m_srcAddress; }
|
||||
|
||||
/**
|
||||
* @brief Get the destination address.
|
||||
* @return the destination address, or @a SYN for any.
|
||||
*/
|
||||
unsigned char getDstAddress() const { return m_dstAddress; }
|
||||
|
||||
/**
|
||||
* @brief Get the command ID bytes.
|
||||
* @return the primary, secondary, and optionally further command ID bytes.
|
||||
*/
|
||||
vector<unsigned char> getId() const { return m_id; }
|
||||
|
||||
/**
|
||||
* @brief Return the key for storing in @a MessageSet.
|
||||
* @return the key for storing in @a MessageSet.
|
||||
*/
|
||||
unsigned long long getKey() { return m_key; }
|
||||
|
||||
/**
|
||||
* @brief Get the polling priority, or 0 for no polling at all.
|
||||
* @return the polling priority, or 0 for no polling at all.
|
||||
@@ -206,35 +219,49 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
/** the optional device class. */
|
||||
/** the optional device class. */
|
||||
const string m_class;
|
||||
|
||||
/** the message name (unique within the same class and type). */
|
||||
const string m_name;
|
||||
|
||||
/** whether this is a set message. */
|
||||
const bool m_isSet;
|
||||
|
||||
/** true if message can only be initiated by a participant other than us,
|
||||
* false if message can be initiated by any participant. */
|
||||
const bool m_isPassive;
|
||||
|
||||
/** the comment. */
|
||||
const string m_comment;
|
||||
|
||||
/** the source address, or @a SYN for any (only relevant if passive). */
|
||||
const unsigned char m_srcAddress;
|
||||
|
||||
/** the destination address. */
|
||||
const unsigned char m_dstAddress;
|
||||
|
||||
/** the primary, secondary, and optionally further command ID bytes. */
|
||||
vector<unsigned char> m_id;
|
||||
|
||||
/** the key for storing in @a MessageSet. */
|
||||
unsigned long long m_key;
|
||||
|
||||
/** the @a DataField for encoding/decoding the message. */
|
||||
DataField* m_data;
|
||||
|
||||
/** the priority for polling, or 0 for no polling at all. */
|
||||
const unsigned char m_pollPriority;
|
||||
|
||||
/** the last decoded value. */
|
||||
string m_lastValue;
|
||||
|
||||
/** the system time when @a m_lastValue was updated, 0 for never. */
|
||||
time_t m_lastUpdateTime;
|
||||
|
||||
/** the number of times this messages was already polled for. */
|
||||
unsigned int m_pollCount;
|
||||
|
||||
/** the system time when this message was last polled for, 0 for never. */
|
||||
time_t m_lastPollTime;
|
||||
|
||||
@@ -266,10 +293,12 @@ public:
|
||||
* @brief Construct a new instance.
|
||||
*/
|
||||
MessageMap() : FileReader<DataFieldTemplates*>::FileReader(true), m_minIdLength(4), m_maxIdLength(0), m_messageCount(0) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~MessageMap() { clear(); }
|
||||
|
||||
/**
|
||||
* @brief Add a @a Message instance to this set.
|
||||
* @param message the @a Message instance to add.
|
||||
@@ -277,8 +306,10 @@ public:
|
||||
* Note: the caller may not free the added instance on success.
|
||||
*/
|
||||
result_t add(Message* message);
|
||||
|
||||
// @copydoc
|
||||
virtual result_t addFromFile(vector<string>& row, DataFieldTemplates* arg, vector< vector<string> >* defaults, const string& filename, unsigned int lineNo);
|
||||
|
||||
/**
|
||||
* @brief Find the @a Message instance for the specified class and name.
|
||||
* @param clazz the optional device class.
|
||||
@@ -289,6 +320,7 @@ public:
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(const string& clazz, const string& name, const bool isSet, const bool isPassive=false);
|
||||
|
||||
/**
|
||||
* @brief Find all active get @a Message instances for the specified class and name.
|
||||
* @param clazz the device class, or empty for any.
|
||||
@@ -298,6 +330,7 @@ public:
|
||||
* Note: the caller may not free the returned instances.
|
||||
*/
|
||||
deque<Message*> findAll(const string& clazz, const string& name, const short pb);
|
||||
|
||||
/**
|
||||
* @brief Find the @a Message instance for the specified master data.
|
||||
* @param master the master @a SymbolString for identifying the @a Message.
|
||||
@@ -305,21 +338,25 @@ public:
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(SymbolString& master);
|
||||
|
||||
/**
|
||||
* @brief Removes all @a Message instances.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Get the number of stored @a Message instances.
|
||||
* @param passiveOnly true to count only passive messages, false to count all messages.
|
||||
* @return the the number of stored @a Message instances.
|
||||
*/
|
||||
int size(const bool passiveOnly=false) { return passiveOnly ? m_passiveMessagesByKey.size() : m_messageCount; }
|
||||
|
||||
/**
|
||||
* @brief Get the number of stored @a Message instances with a poll priority.
|
||||
* @return the the number of stored @a Message instances with a poll priority.
|
||||
*/
|
||||
int sizePoll() { return m_pollMessages.size(); }
|
||||
|
||||
/**
|
||||
* @brief Get the next @a Message to poll.
|
||||
* @return the next @a Message to poll, or NULL.
|
||||
|
||||
@@ -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