code style

This commit is contained in:
john30
2017-01-14 13:00:04 +01:00
parent d13b271a05
commit b3bb2e08ac
49 changed files with 1853 additions and 1858 deletions
+34 -32
View File
@@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBEBUS_DATA_H_
#define LIBEBUS_DATA_H_
#ifndef LIB_EBUS_DATA_H_
#define LIB_EBUS_DATA_H_
#include "symbol.h"
#include "result.h"
#include "filereader.h"
#include "datatype.h"
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include "symbol.h"
#include "result.h"
#include "filereader.h"
#include "datatype.h"
/** @file data.h
* Classes related to defining fields based on data types in symbols on the
@@ -93,7 +93,7 @@ public:
DataFieldTemplates* templates, DataField*& returnField,
const bool isWriteMessage,
const bool isTemplate, const bool isBroadcastOrMasterDestination,
const unsigned char maxFieldLength=MAX_POS);
const unsigned char maxFieldLength = MAX_POS);
/**
* Dump the @a string optionally embedded in @a TEXT_SEPARATOR to the output.
@@ -101,7 +101,7 @@ public:
* @param str the @a string to dump.
* @param prependFieldSeparator whether to start with a @a FIELD_SEPARATOR.
*/
static void dumpString(ostream& output, const string str, const bool prependFieldSeparator=true);
static void dumpString(ostream& output, const string str, const bool prependFieldSeparator = true);
/**
* Returns the length of this field (or contained fields) in bytes.
@@ -109,7 +109,7 @@ public:
* @param maxLength the maximum length for calculating remainder of input.
* @return the length of this field (or contained fields) in bytes.
*/
virtual unsigned char getLength(PartType partType, unsigned char maxLength=MAX_LEN) = 0;
virtual unsigned char getLength(PartType partType, unsigned char maxLength = MAX_LEN) = 0;
/**
* Derive a new @a DataField from this field.
@@ -132,7 +132,7 @@ public:
* @param fieldIndex the index of the field, or -1 for this.
* @return the field name, or the index as string if not unique or not available.
*/
virtual string getName(signed char fieldIndex=-1) { return m_name; }
virtual string getName(signed char fieldIndex = -1) { return m_name; }
/**
* Get the field comment.
@@ -169,7 +169,7 @@ public:
*/
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
unsigned int& output, const char* fieldName=NULL, signed char fieldIndex=-1) = 0;
unsigned int& output, const char* fieldName = NULL, signed char fieldIndex = -1) = 0;
/**
* Reads the value from the @a SymbolString.
@@ -188,8 +188,8 @@ public:
*/
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
ostringstream& output, OutputFormat outputFormat, signed char outputIndex=-1,
bool leadingSeparator=false, const char* fieldName=NULL, signed char fieldIndex=-1) = 0;
ostringstream& output, OutputFormat outputFormat, signed char outputIndex = -1,
bool leadingSeparator = false, const char* fieldName = NULL, signed char fieldIndex = -1) = 0;
/**
* Writes the value to the master or slave @a SymbolString.
@@ -203,7 +203,7 @@ public:
*/
virtual result_t write(istringstream& input,
const PartType partType, SymbolString& data,
unsigned char offset, char separator=UI_FIELD_SEPARATOR, unsigned char* length=NULL) = 0;
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL) = 0;
protected:
@@ -287,7 +287,7 @@ public:
PartType getPartType() const { return m_partType; }
// @copydoc
virtual unsigned char getLength(PartType partType, unsigned char maxLength=MAX_LEN);
virtual unsigned char getLength(PartType partType, unsigned char maxLength = MAX_LEN);
// @copydoc
virtual result_t derive(string name, string comment,
@@ -312,18 +312,18 @@ public:
// @copydoc
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
unsigned int& output, const char* fieldName=NULL, signed char fieldIndex=-1);
unsigned int& output, const char* fieldName = NULL, signed char fieldIndex = -1);
// @copydoc
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
ostringstream& output, OutputFormat outputFormat, signed char outputIndex=-1,
bool leadingSeparator=false, const char* fieldName=NULL, signed char fieldIndex=-1);
ostringstream& output, OutputFormat outputFormat, signed char outputIndex = -1,
bool leadingSeparator = false, const char* fieldName = NULL, signed char fieldIndex = -1);
// @copydoc
virtual result_t write(istringstream& input,
const PartType partType, SymbolString& data,
unsigned char offset, char separator=UI_FIELD_SEPARATOR, unsigned char* length=NULL);
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL);
protected:
@@ -526,11 +526,13 @@ public:
{
bool uniqueNames = true;
map<string, string> names;
for (vector<SingleDataField*>::const_iterator it=fields.begin(); it!=fields.end(); it++) {
for (vector<SingleDataField*>::const_iterator it = fields.begin(); it != fields.end(); it++) {
SingleDataField* field = *it;
if (field->isIgnored()) continue;
if (field->isIgnored()) {
continue;
}
string name = field->getName();
if (name.empty() || names.find(name)!=names.end()) {
if (name.empty() || names.find(name) != names.end()) {
uniqueNames = false;
break;
}
@@ -548,10 +550,10 @@ public:
virtual DataFieldSet* clone();
// @copydoc
virtual unsigned char getLength(PartType partType, unsigned char maxLength=MAX_LEN);
virtual unsigned char getLength(PartType partType, unsigned char maxLength = MAX_LEN);
// @copydoc
virtual string getName(signed char fieldIndex=-1);
virtual string getName(signed char fieldIndex = -1);
// @copydoc
virtual result_t derive(string name, string comment,
@@ -564,14 +566,14 @@ public:
* @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]; }
SingleDataField* operator[](const size_t index) { if (index >= m_fields.size()) { return NULL; } return m_fields[index]; }
/**
* 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]; }
const SingleDataField* operator[](const size_t index) const { if (index >= m_fields.size()) { return NULL; } return m_fields[index]; }
/**
* Returns the number of @a SingleDataFields instances in this set.
@@ -588,18 +590,18 @@ public:
// @copydoc
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
unsigned int& output, const char* fieldName=NULL, signed char fieldIndex=-1);
unsigned int& output, const char* fieldName = NULL, signed char fieldIndex = -1);
// @copydoc
virtual result_t read(const PartType partType,
SymbolString& data, unsigned char offset,
ostringstream& output, OutputFormat outputFormat, signed char outputIndex=-1,
bool leadingSeparator=false, const char* fieldName=NULL, signed char fieldIndex=-1);
ostringstream& output, OutputFormat outputFormat, signed char outputIndex = -1,
bool leadingSeparator = false, const char* fieldName = NULL, signed char fieldIndex = -1);
// @copydoc
virtual result_t write(istringstream& input,
const PartType partType, SymbolString& data,
unsigned char offset, char separator=UI_FIELD_SEPARATOR, unsigned char* length=NULL);
unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL);
private:
@@ -653,7 +655,7 @@ public:
* @return @a RESULT_OK on success, or an error code.
* Note: the caller may not free the added instance on success.
*/
result_t add(DataField* field, string name="", bool replace=false);
result_t add(DataField* field, string name = "", bool replace = false);
// @copydoc
virtual result_t addFromFile(vector<string>::iterator& begin, const vector<string>::iterator end,
@@ -675,4 +677,4 @@ private:
};
#endif // LIBEBUS_DATA_H_
#endif // LIB_EBUS_DATA_H_