# HG changeset patch # User František Kučera # Date 1532209589 -7200 # Node ID e7234dd45166090b91460c9e0377a5b13ee4de24 # Parent 640e88aedf8f2a5321109c63ac469b20a9401bf1 use TypeId enum instead of numeric constants diff -r 640e88aedf8f -r e7234dd45166 include/RelationalWriter.h --- a/include/RelationalWriter.h Sat Jul 21 23:01:47 2018 +0200 +++ b/include/RelationalWriter.h Sat Jul 21 23:46:29 2018 +0200 @@ -4,7 +4,8 @@ #include #include -#include "../include/typedefs.h" +#include "typedefs.h" +#include "TypeId.h" namespace relpipe { namespace writer { @@ -18,7 +19,7 @@ virtual string_t toTypeCode(const integer_t typeId) = 0; - virtual void startRelation(string_t name, std::vector> attributes, boolean_t writeHeader) = 0; + virtual void startRelation(string_t name, std::vector> attributes, boolean_t writeHeader) = 0; virtual void writeRecord(std::vector attributes) = 0; diff -r 640e88aedf8f -r e7234dd45166 include/TypeId.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/TypeId.h Sat Jul 21 23:46:29 2018 +0200 @@ -0,0 +1,13 @@ +#pragma once + +namespace relpipe { +namespace writer { + +enum class TypeId { + BOOLEAN = 1, + INTEGER = 2, + STRING = 3, +}; + +} +} \ No newline at end of file diff -r 640e88aedf8f -r e7234dd45166 nbproject/configurations.xml --- a/nbproject/configurations.xml Sat Jul 21 23:01:47 2018 +0200 +++ b/nbproject/configurations.xml Sat Jul 21 23:46:29 2018 +0200 @@ -12,6 +12,7 @@ include/RelpipeWriterException.h src/StreamRelationalWriter.h src/types/StringDataTypeWriter.h + include/TypeId.h src/format.h include/typedefs.h @@ -50,6 +51,8 @@ + + @@ -93,6 +96,8 @@ + + diff -r 640e88aedf8f -r e7234dd45166 src/StreamRelationalWriter.h --- a/src/StreamRelationalWriter.h Sat Jul 21 23:01:47 2018 +0200 +++ b/src/StreamRelationalWriter.h Sat Jul 21 23:46:29 2018 +0200 @@ -6,6 +6,7 @@ #include "../include/typedefs.h" #include "../include/RelationalWriter.h" +#include "../include/TypeId.h" #include "format.h" #include "DataTypeWriterBase.h" #include "types/BooleanDataTypeWriter.h" @@ -54,7 +55,7 @@ throw RelpipeWriterException(L"Unsupported data type: " + typeId); } - void startRelation(string_t name, std::vector > attributes, boolean_t writeHeader) override { + void startRelation(string_t name, std::vector > attributes, boolean_t writeHeader) override { string_t tableName = name; columnCount = attributes.size(); @@ -74,8 +75,7 @@ // Write column types: for (size_t c = 0; c < columnCount; c++) { - wstring typeCode = attributes[c].second; - integer_t typeId = toTypeId(typeCode); + integer_t typeId = static_cast(attributes[c].second); integerWriter.writeValue(output, typeId); columnTypes[c] = typeId; } diff -r 640e88aedf8f -r e7234dd45166 src/format.h --- a/src/format.h Sat Jul 21 23:01:47 2018 +0200 +++ b/src/format.h Sat Jul 21 23:46:29 2018 +0200 @@ -3,12 +3,14 @@ #include #include +#include "../include/TypeId.h" + namespace relpipe { namespace writer { -const integer_t DATA_TYPE_ID_BOOLEAN = 1; -const integer_t DATA_TYPE_ID_INTEGER = 2; -const integer_t DATA_TYPE_ID_STRING = 3; +const integer_t DATA_TYPE_ID_BOOLEAN = static_cast(TypeId::BOOLEAN); +const integer_t DATA_TYPE_ID_INTEGER = static_cast(TypeId::INTEGER); +const integer_t DATA_TYPE_ID_STRING = static_cast(TypeId::STRING); const string_t DATA_TYPE_CODE_BOOLEAN = L"boolean"; const string_t DATA_TYPE_CODE_INTEGER = L"integer"; diff -r 640e88aedf8f -r e7234dd45166 src/types/BooleanDataTypeWriter.h --- a/src/types/BooleanDataTypeWriter.h Sat Jul 21 23:01:47 2018 +0200 +++ b/src/types/BooleanDataTypeWriter.h Sat Jul 21 23:46:29 2018 +0200 @@ -15,7 +15,7 @@ class BooleanDataTypeWriter : public DataTypeWriter { private: - const string_t TRUE = L"true"; + const string_t TRUE = L"true"; const string_t FALSE = L"false"; public: @@ -36,4 +36,4 @@ } } -} \ No newline at end of file +}