From 8864ce55b8504e4e6e0a99515c75d59338e0d068 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 15 May 2016 17:18:57 +0200 Subject: [PATCH] fix for getline usage with newer compilers --- src/ebusd/mainloop.cpp | 6 +++--- src/lib/ebus/data.cpp | 10 +++++----- src/lib/ebus/message.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index dc07a557..097ee02c 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -199,7 +199,7 @@ string MainLoop::decodeMessage(const string& data, const bool isHttp, bool& conn bool escaped = false; char delim = ' '; - while (getline(stream, token, delim) != 0) { + while (getline(stream, token, delim)) { if (!isHttp) { if (escaped) { args.pop_back(); @@ -742,7 +742,7 @@ string MainLoop::executeFind(vector &args) } istringstream input(args[argPos]); string column; - while (getline(input, column, ',') != 0) { + while (getline(input, column, ',')) { size_t idx = columnCount; for (size_t i = 0; i < columnCount; i++) { if (strcasecmp(columnNames[i], column.c_str()) == 0) { @@ -1170,7 +1170,7 @@ string MainLoop::executeGet(vector &args, bool& connected) string query = args[argPos++]; istringstream stream(query); string token; - while (getline(stream, token, '&') != 0) { + while (getline(stream, token, '&')) { pos = token.find('='); string qname, value; if (pos != string::npos) { diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index 49d2a6ee..9980d578 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -271,7 +271,7 @@ result_t DataField::create(vector::iterator& it, divisor = parseSignedInt(divisorStr.c_str(), 10, -MAX_DIVISOR, MAX_DIVISOR, result); else { istringstream stream(divisorStr); - while (getline(stream, token, VALUE_SEPARATOR) != 0) { + while (getline(stream, token, VALUE_SEPARATOR)) { FileReader::trim(token); const char* str = token.c_str(); char* strEnd = NULL; @@ -324,7 +324,7 @@ result_t DataField::create(vector::iterator& it, bool firstType = true; istringstream stream(typeStr); - while (result == RESULT_OK && getline(stream, token, VALUE_SEPARATOR) != 0) { + while (result == RESULT_OK && getline(stream, token, VALUE_SEPARATOR)) { FileReader::trim(token); DataField* templ = templates->get(token); unsigned char length; @@ -798,7 +798,7 @@ result_t StringDataField::writeSymbols(istringstream& input, case bt_dat: if (m_length == 4 && i == 2) continue; // skip weekday in between - if (input.eof() || getline(input, token, '.') == 0) + if (input.eof() || !getline(input, token, '.')) return RESULT_ERR_EOF; // incomplete if ((m_dataType.flags & REQ) == 0 && strcmp(token.c_str(), NULL_VALUE) == 0) { value = m_dataType.replacement; @@ -829,7 +829,7 @@ result_t StringDataField::writeSymbols(istringstream& input, return RESULT_ERR_OUT_OF_RANGE; // invalid date part break; case bt_tim: - if (input.eof() || getline(input, token, LENGTH_SEPARATOR) == 0) + if (input.eof() || !getline(input, token, LENGTH_SEPARATOR)) return RESULT_ERR_EOF; // incomplete if ((m_dataType.flags & REQ) == 0 && strcmp(token.c_str(), NULL_VALUE) == 0) { value = m_dataType.replacement; @@ -1629,7 +1629,7 @@ result_t DataFieldSet::write(istringstream& input, if (m_fields.size() > 1) { if (field->isIgnored()) token.clear(); - else if (getline(input, token, separator) == 0) + else if (!getline(input, token, separator)) token.clear(); istringstream single(token); diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index d477f2fa..021cde30 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -231,7 +231,7 @@ result_t Message::create(vector::iterator& it, const vector::ite istringstream stream(str); string token; bool first = true; - while (getline(stream, token, VALUE_SEPARATOR) != 0) { + while (getline(stream, token, VALUE_SEPARATOR)) { FileReader::trim(token); unsigned char dstAddress = (unsigned char)parseInt(token.c_str(), 16, 0, 0xff, result); if (result != RESULT_OK) @@ -275,7 +275,7 @@ result_t Message::create(vector::iterator& it, const vector::ite size_t chainLength = 16; size_t chainPrefixLength = id.size(); bool first = true, lastChainLengthSpecified = false; - while (getline(stream, token, VALUE_SEPARATOR) != 0 || first) { + while (getline(stream, token, VALUE_SEPARATOR) || first) { FileReader::trim(token); token = defaultIdPrefix+token; size_t lengthPos = token.find(LENGTH_SEPARATOR); @@ -984,7 +984,7 @@ result_t splitValues(string valueList, vector& values) { istringstream stream(valueList); string str; - while (getline(stream, str, VALUE_SEPARATOR) != 0) { + while (getline(stream, str, VALUE_SEPARATOR)) { if (str.length()>0 && str[0]=='\'' && str[str.length()-1]=='\'') { str = str.substr(1, str.length()-2); } @@ -1003,7 +1003,7 @@ result_t splitValues(string valueList, vector& valueRanges) istringstream stream(valueList); string str; result_t result; - while (getline(stream, str, VALUE_SEPARATOR) != 0) { + while (getline(stream, str, VALUE_SEPARATOR)) { FileReader::trim(str); if (str.length()==0) return RESULT_ERR_INVALID_ARG; @@ -1533,7 +1533,7 @@ result_t MessageMap::addFromFile(vector::iterator& begin, const vector messages; - while (getline(stream, type, VALUE_SEPARATOR) != 0) { + while (getline(stream, type, VALUE_SEPARATOR)) { FileReader::trim(type); *restart = type; begin = restart;