use result_t, added getMasterNumber(), documentation

This commit is contained in:
john30
2014-11-23 13:32:38 +01:00
parent 6e0ddb1e8b
commit ea63e9d461
2 changed files with 56 additions and 6 deletions
+12 -5
View File
@@ -20,6 +20,7 @@
#ifndef LIBEBUS_SYMBOL_H_
#define LIBEBUS_SYMBOL_H_
#include "result.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
@@ -43,7 +44,6 @@ class SymbolString
public:
/**
* @brief Creates a new unescaped empty instance.
* @param escaped whether to create an escaped instance.
*/
SymbolString() : m_unescapeState(1), m_crc(0) {}
/**
@@ -90,12 +90,12 @@ public:
* RESULT_IN_ESC if this is an unescaped instance and the symbol is escaped and the start of the escape sequence was received,
* RESULT_ERR_ESC if this is an unescaped instance and an invalid escaped sequence was detected.
*/
int push_back(const unsigned char value, const bool isEscaped, const bool updateCRC=true);
result_t push_back(const unsigned char value, const bool isEscaped, const bool updateCRC=true);
/**
* @brief Returns the number of symbols in this symbol string.
* @return the number of available symbols.
*/
size_t size() const { return m_data.size(); }
unsigned char size() const { return (unsigned char)m_data.size(); }
/**
* @brief Returns the calculated CRC.
* @return the calculated CRC.
@@ -131,14 +131,21 @@ private:
/**
* Returns whether the address is one of the 25 master addresses.
* @brief Returns whether the address is one of the 25 master addresses.
* @param addr the address to check.
* @return <code>true</code> if the specified address is a master address.
*/
bool isMaster(unsigned char addr);
/**
* Returns whether the address is a valid bus address.
* @brief Returns the number of the master if the address is a valid bus address.
* @param addr the bus address.
* @return the number of the master if the address is a valid bus address (1 to 25), or 0.
*/
unsigned char getMasterNumber(unsigned char addr);
/**
* @brief Returns whether the address is a valid bus address.
* @param addr the address to check.
* @param allowBroadcast whether to also allow @a addr to be the broadcast address (default true).
* @return <code>true</code> if the specified address is a valid bus address.