diff -r 489e52138771 -r c87e9c84f7aa src/BooleanDataType.h --- a/src/BooleanDataType.h Sat Jul 14 23:24:22 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#pragma once - -#include -#include - -#include "DataType.h" -#include "RelpipeException.h" - -using namespace std; - -namespace rp_prototype { - -class BooleanDataType : public DataType { -private: - const wstring TRUE = L"true"; - const wstring FALSE = L"false"; -public: - - BooleanDataType() : DataType(DATA_TYPE_ID_BOOLEAN, DATA_TYPE_CODE_BOOLEAN) { - } - - bool readValue(istream &input) override { - auto value = input.get(); // TODO: check failbit - if (value == 0) return false; - else if (value == 1) return true; - else throw RelpipeException(L"Unable to convert the octet to boolean", EXIT_CODE_DATA_ERROR); - } - - void writeValue(ostream &output, const bool &value) override { - output.put(value ? 1 : 0); - } - - bool toValue(const wstring &stringValue) override { - if (stringValue == TRUE) return true; - else if (stringValue == FALSE) return false; - else throw RelpipeException(L"Unable to convert the string to boolean", EXIT_CODE_DATA_ERROR); - } - - wstring toString(const bool &value) override { - return value ? TRUE : FALSE; - } - -}; - -} \ No newline at end of file