code style, documentation

This commit is contained in:
john30
2018-05-10 13:01:21 +02:00
parent 90baf8c295
commit 1eb3518145
5 changed files with 19 additions and 14 deletions
+7 -6
View File
@@ -1166,18 +1166,19 @@ void BusHandler::messageCompleted() {
} else { } else {
string data = output.str(); string data = output.str();
if (m_answer && dstAddress == (master ? m_ownMasterAddress : m_ownSlaveAddress)) { if (m_answer && dstAddress == (master ? m_ownMasterAddress : m_ownSlaveAddress)) {
logNotice(lf_update, "%s %s self-update %s %s QQ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), srcAddress, logNotice(lf_update, "%s %s self-update %s %s QQ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(),
data.c_str()); // TODO store in database of internal variables srcAddress, data.c_str()); // TODO store in database of internal variables
} else if (message->getDstAddress() == SYN) { // any destination } else if (message->getDstAddress() == SYN) { // any destination
if (message->getSrcAddress() == SYN) { // any destination and any source if (message->getSrcAddress() == SYN) { // any destination and any source
logNotice(lf_update, "%s %s %s %s QQ=%2.2x ZZ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), srcAddress, logNotice(lf_update, "%s %s %s %s QQ=%2.2x ZZ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(),
dstAddress, data.c_str()); srcAddress, dstAddress, data.c_str());
} else { } else {
logNotice(lf_update, "%s %s %s %s ZZ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), dstAddress, logNotice(lf_update, "%s %s %s %s ZZ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), dstAddress,
data.c_str()); data.c_str());
} }
} else if (message->getSrcAddress() == SYN) { // any source } else if (message->getSrcAddress() == SYN) { // any source
logNotice(lf_update, "%s %s %s %s QQ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), srcAddress, data.c_str()); logNotice(lf_update, "%s %s %s %s QQ=%2.2x: %s", prefix, mode, circuit.c_str(), name.c_str(), srcAddress,
data.c_str());
} else { } else {
logNotice(lf_update, "%s %s %s %s: %s", prefix, mode, circuit.c_str(), name.c_str(), data.c_str()); logNotice(lf_update, "%s %s %s %s: %s", prefix, mode, circuit.c_str(), name.c_str(), data.c_str());
} }
+2 -1
View File
@@ -722,7 +722,7 @@ class LoadableDataFieldSet : public DataFieldSet, public MappedFileReader {
/** /**
* Constructs a new instance. * Constructs a new instance.
* @param name the field name. * @param name the field name.
* @param fields the @a vector of @a SingleDataField instances part of this set. * @param templates the @a DataFieldTemplates instance to use.
*/ */
LoadableDataFieldSet(const string& name, DataFieldTemplates* templates) LoadableDataFieldSet(const string& name, DataFieldTemplates* templates)
: DataFieldSet(name, vector<const SingleDataField*>()), MappedFileReader(false), m_templates(templates) { : DataFieldSet(name, vector<const SingleDataField*>()), MappedFileReader(false), m_templates(templates) {
@@ -736,6 +736,7 @@ class LoadableDataFieldSet : public DataFieldSet, public MappedFileReader {
vector< map<string, string> >* subRows, string* errorDescription, bool replace) override; vector< map<string, string> >* subRows, string* errorDescription, bool replace) override;
private: private:
/** the @a DataFieldTemplates instance to use. */
DataFieldTemplates* m_templates; DataFieldTemplates* m_templates;
}; };
+2
View File
@@ -195,6 +195,7 @@ class Message : public AttributedItem {
/** /**
* Create a new scan @a Message instance. * Create a new scan @a Message instance.
* @param broadcast true for broadcast scan message, false for scan message to be sent to a slave address. * @param broadcast true for broadcast scan message, false for scan message to be sent to a slave address.
* @param deleteData whether to delete the @a DataField during @a Message destruction.
* @return the new scan @a Message instance. * @return the new scan @a Message instance.
*/ */
static Message* createScanMessage(bool broadcast = false, bool deleteData = true); static Message* createScanMessage(bool broadcast = false, bool deleteData = true);
@@ -1217,6 +1218,7 @@ class MessageMap : public MappedFileReader {
* Construct a new instance. * Construct a new instance.
* @param addAll whether to add all messages, even if duplicate. * @param addAll whether to add all messages, even if duplicate.
* @param preferLanguage the preferred language to use, or empty. * @param preferLanguage the preferred language to use, or empty.
* @param deleteData whether to delete the scan message @a DataField during @a Message destruction.
*/ */
explicit MessageMap(bool addAll = false, const string& preferLanguage = "", bool deleteData = true) explicit MessageMap(bool addAll = false, const string& preferLanguage = "", bool deleteData = true)
: MappedFileReader::MappedFileReader(true), : MappedFileReader::MappedFileReader(true),
+6 -6
View File
@@ -183,30 +183,30 @@ bool HttpClient::request(const string& method, const string& uri, const string&
struct tm t; struct tm t;
pos += strlen("\r\nLast-Modified: ") + 5; pos += strlen("\r\nLast-Modified: ") + 5;
char* strEnd = nullptr; char* strEnd = nullptr;
t.tm_mday = (int)strtol(hdrs + pos, &strEnd, 10); t.tm_mday = static_cast<int>(strtol(hdrs + pos, &strEnd, 10));
if (strEnd != hdrs + pos + 2 || t.tm_mday < 1 || t.tm_mday > 31) { if (strEnd != hdrs + pos + 2 || t.tm_mday < 1 || t.tm_mday > 31) {
t.tm_mday = -1; t.tm_mday = -1;
} }
t.tm_mon = indexToMonth[((hdrs[pos+4]&0x10)>>1) | (hdrs[pos+5]&0x17)] - 1; t.tm_mon = indexToMonth[((hdrs[pos+4]&0x10)>>1) | (hdrs[pos+5]&0x17)] - 1;
strEnd = nullptr; strEnd = nullptr;
t.tm_year = (int)strtol(hdrs + pos + 7, &strEnd, 10); t.tm_year = static_cast<int>(strtol(hdrs + pos + 7, &strEnd, 10));
if (strEnd != hdrs + pos + 11 || t.tm_year < 1970 || t.tm_year >= 3000) { if (strEnd != hdrs + pos + 11 || t.tm_year < 1970 || t.tm_year >= 3000) {
t.tm_year = -1; t.tm_year = -1;
} else { } else {
t.tm_year -= 1900; t.tm_year -= 1900;
} }
strEnd = nullptr; strEnd = nullptr;
t.tm_hour = (int)strtol(hdrs + pos + 12, &strEnd, 10); t.tm_hour = static_cast<int>(strtol(hdrs + pos + 12, &strEnd, 10));
if (strEnd != hdrs + pos + 14 || t.tm_hour > 23) { if (strEnd != hdrs + pos + 14 || t.tm_hour > 23) {
t.tm_hour = -1; t.tm_hour = -1;
} }
strEnd = nullptr; strEnd = nullptr;
t.tm_min = (int)strtol(hdrs + pos + 15, &strEnd, 10); t.tm_min = static_cast<int>(strtol(hdrs + pos + 15, &strEnd, 10));
if (strEnd != hdrs + pos + 17 || t.tm_min > 59) { if (strEnd != hdrs + pos + 17 || t.tm_min > 59) {
t.tm_min = -1; t.tm_min = -1;
} }
strEnd = nullptr; strEnd = nullptr;
t.tm_sec = (int)strtol(hdrs + pos + 18, &strEnd, 10); t.tm_sec = static_cast<int>(strtol(hdrs + pos + 18, &strEnd, 10));
if (strEnd != hdrs + pos + 20 || t.tm_sec > 59) { if (strEnd != hdrs + pos + 20 || t.tm_sec > 59) {
t.tm_sec = -1; t.tm_sec = -1;
} }
@@ -234,7 +234,7 @@ bool HttpClient::request(const string& method, const string& uri, const string&
size_t HttpClient::readUntil(const string& delim, const size_t length, string* result) { size_t HttpClient::readUntil(const string& delim, const size_t length, string* result) {
if (!m_buffer) { if (!m_buffer) {
m_buffer = (char*)malloc(1024); m_buffer = reinterpret_cast<char*>(malloc(1024));
if (!m_buffer) { if (!m_buffer) {
return string::npos; return string::npos;
} }
+2 -1
View File
@@ -30,7 +30,7 @@ typedef struct sockaddr_in socketaddress;
namespace ebusd { namespace ebusd {
/** \file lib/utils/http.h */ /** \file lib/utils/httpclient.h */
using std::string; using std::string;
using std::ifstream; using std::ifstream;
@@ -115,6 +115,7 @@ class HttpClient {
/** /**
* Execute an arbitrary request. * Execute an arbitrary request.
* @param method the method string.
* @param uri the URI string. * @param uri the URI string.
* @param body the optional body to send. * @param body the optional body to send.
* @param response the response body from the server (or the HTTP header on error). * @param response the response body from the server (or the HTTP header on error).