# HG changeset patch # User František Kučera # Date 1531089815 -7200 # Node ID 1a574113da2097aad745160e5bfbf98cfdc597cb # Parent 6e3494943c91592df81642f488c5cfa9f14b6d65 separate 'src' and 'include' (public interface) diff -r 6e3494943c91 -r 1a574113da20 DataTypeWriter.cpp --- a/DataTypeWriter.cpp Sun Jul 08 01:40:38 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -#include "DataTypeWriter.h" - -namespace relpipe { -namespace writer { - -template string_t DataTypeWriter::readString(std::istream &input) { - return toString(readValue(input)); -}; - -template void DataTypeWriter::writeString(std::ostream& output, const string_t &stringValue) { - writeValue(output, toValue(stringValue)); -}; - -} -} diff -r 6e3494943c91 -r 1a574113da20 DataTypeWriter.h --- a/DataTypeWriter.h Sun Jul 08 01:40:38 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#pragma once - -#include "DataTypeWriterBase.h" - -namespace relpipe { -namespace writer { - -template class DataTypeWriter : public DataTypeWriterBase { -public: - - DataTypeWriter(const integer_t typeId, const string_t typeCode) : DataTypeWriterBase(typeId, typeCode) { - } - - virtual ~DataTypeWriter() { - }; - - virtual T readValue(std::istream& input) = 0; - - virtual string_t readString(std::istream &input); - - virtual void writeValue(std::ostream& output, const T& value) = 0; - - virtual void writeString(std::ostream& output, const string_t &stringValue); - - virtual T toValue(const string_t &stringValue) = 0; - virtual string_t toString(const T& value) = 0; - -}; - -} -} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 DataTypeWriterBase.cpp --- a/DataTypeWriterBase.cpp Sun Jul 08 01:40:38 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#include -#include "DataTypeWriterBase.h" - -namespace relpipe { -namespace writer { - -bool DataTypeWriterBase::supports(const integer_t &dataType) { - return dataType == typeId; -} - -bool DataTypeWriterBase::supports(const string_t &dataType) { - return dataType == typeCode; -} - -integer_t DataTypeWriterBase::getTypeId() { - return typeId; -} - -string_t DataTypeWriterBase::getTypeCode() { - return typeCode; -} - -} -} diff -r 6e3494943c91 -r 1a574113da20 DataTypeWriterBase.h --- a/DataTypeWriterBase.h Sun Jul 08 01:40:38 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -#pragma once - -#include -#include "common.h" - -namespace relpipe { -namespace writer { - -/** - * This class contains common features that are independent from particular data type (generic/template type) - */ -class DataTypeWriterBase { -private: - const integer_t typeId; - const string_t typeCode; -public: - - DataTypeWriterBase(const integer_t typeId, const string_t typeCode) : - typeId(typeId), typeCode(typeCode) { - } - - virtual ~DataTypeWriterBase() { - }; - - virtual string_t readString(std::istream &input) = 0; - - virtual void writeString(std::ostream& output, const string_t &stringValue) = 0; - - /** - * @param dataType data type code as defined in DDP L0 - * @return whether this class supports conversions of this type - */ - virtual bool supports(const integer_t &dataType); - - /** - * @param dataType data type name as defined in DDP L0 - * @return whether this class supports conversions of this type - */ - virtual bool supports(const string_t &dataType); - - integer_t getTypeId(); - - string_t getTypeCode(); -}; - -} -} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 common.h --- a/common.h Sun Jul 08 01:40:38 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#pragma once - -#include -#include - -namespace relpipe { -namespace writer { - -using octet_t = uint8_t; -using integer_t = uint64_t; -using boolean_t = bool; -using string_t = std::wstring; - -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 string_t DATA_TYPE_CODE_BOOLEAN = L"boolean"; -const string_t DATA_TYPE_CODE_INTEGER = L"integer"; -const string_t DATA_TYPE_CODE_STRING = L"string"; - - -/** - * With respect for the tradition and computer pioneers, we use same numbers as in ASCII texts: - * - * 1C FS ␜ File Separator - * 1D GS ␝ Group Separator - * 1E RS ␞ Record Separator - * 1F US ␟ Unit Separator - * - */ -const integer_t DATA_PART_START = 0x1D; -const integer_t DATA_PART_ROW = 0x1E; - -} -} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 include/DataTypeWriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/DataTypeWriter.h Mon Jul 09 00:43:35 2018 +0200 @@ -0,0 +1,31 @@ +#pragma once + +#include "DataTypeWriterBase.h" + +namespace relpipe { +namespace writer { + +template class DataTypeWriter : public DataTypeWriterBase { +public: + + DataTypeWriter(const integer_t typeId, const string_t typeCode) : DataTypeWriterBase(typeId, typeCode) { + } + + virtual ~DataTypeWriter() { + }; + + virtual T readValue(std::istream& input) = 0; + + virtual string_t readString(std::istream &input); + + virtual void writeValue(std::ostream& output, const T& value) = 0; + + virtual void writeString(std::ostream& output, const string_t &stringValue); + + virtual T toValue(const string_t &stringValue) = 0; + virtual string_t toString(const T& value) = 0; + +}; + +} +} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 include/DataTypeWriterBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/DataTypeWriterBase.h Mon Jul 09 00:43:35 2018 +0200 @@ -0,0 +1,47 @@ +#pragma once + +#include +#include "common.h" + +namespace relpipe { +namespace writer { + +/** + * This class contains common features that are independent from particular data type (generic/template type) + */ +class DataTypeWriterBase { +private: + const integer_t typeId; + const string_t typeCode; +public: + + DataTypeWriterBase(const integer_t typeId, const string_t typeCode) : + typeId(typeId), typeCode(typeCode) { + } + + virtual ~DataTypeWriterBase() { + }; + + virtual string_t readString(std::istream &input) = 0; + + virtual void writeString(std::ostream& output, const string_t &stringValue) = 0; + + /** + * @param dataType data type code as defined in DDP L0 + * @return whether this class supports conversions of this type + */ + virtual bool supports(const integer_t &dataType); + + /** + * @param dataType data type name as defined in DDP L0 + * @return whether this class supports conversions of this type + */ + virtual bool supports(const string_t &dataType); + + integer_t getTypeId(); + + string_t getTypeCode(); +}; + +} +} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 include/common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/common.h Mon Jul 09 00:43:35 2018 +0200 @@ -0,0 +1,36 @@ +#pragma once + +#include +#include + +namespace relpipe { +namespace writer { + +using octet_t = uint8_t; +using integer_t = uint64_t; +using boolean_t = bool; +using string_t = std::wstring; + +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 string_t DATA_TYPE_CODE_BOOLEAN = L"boolean"; +const string_t DATA_TYPE_CODE_INTEGER = L"integer"; +const string_t DATA_TYPE_CODE_STRING = L"string"; + + +/** + * With respect for the tradition and computer pioneers, we use same numbers as in ASCII texts: + * + * 1C FS ␜ File Separator + * 1D GS ␝ Group Separator + * 1E RS ␞ Record Separator + * 1F US ␟ Unit Separator + * + */ +const integer_t DATA_PART_START = 0x1D; +const integer_t DATA_PART_ROW = 0x1E; + +} +} \ No newline at end of file diff -r 6e3494943c91 -r 1a574113da20 nbproject/Makefile-Debug.mk --- a/nbproject/Makefile-Debug.mk Sun Jul 08 01:40:38 2018 +0200 +++ b/nbproject/Makefile-Debug.mk Mon Jul 09 00:43:35 2018 +0200 @@ -35,8 +35,8 @@ # Object Files OBJECTFILES= \ - ${OBJECTDIR}/DataTypeWriter.o \ - ${OBJECTDIR}/DataTypeWriterBase.o + ${OBJECTDIR}/src/DataTypeWriter.o \ + ${OBJECTDIR}/src/DataTypeWriterBase.o # C Compiler Flags @@ -63,15 +63,15 @@ ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/librelpipe-lib-writer.cpp.${CND_DLIB_EXT} ${OBJECTFILES} ${LDLIBSOPTIONS} -shared -fPIC -${OBJECTDIR}/DataTypeWriter.o: DataTypeWriter.cpp - ${MKDIR} -p ${OBJECTDIR} +${OBJECTDIR}/src/DataTypeWriter.o: src/DataTypeWriter.cpp + ${MKDIR} -p ${OBJECTDIR}/src ${RM} "$@.d" - $(COMPILE.cc) -g -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DataTypeWriter.o DataTypeWriter.cpp + $(COMPILE.cc) -g -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/DataTypeWriter.o src/DataTypeWriter.cpp -${OBJECTDIR}/DataTypeWriterBase.o: DataTypeWriterBase.cpp - ${MKDIR} -p ${OBJECTDIR} +${OBJECTDIR}/src/DataTypeWriterBase.o: src/DataTypeWriterBase.cpp + ${MKDIR} -p ${OBJECTDIR}/src ${RM} "$@.d" - $(COMPILE.cc) -g -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DataTypeWriterBase.o DataTypeWriterBase.cpp + $(COMPILE.cc) -g -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/DataTypeWriterBase.o src/DataTypeWriterBase.cpp # Subprojects .build-subprojects: diff -r 6e3494943c91 -r 1a574113da20 nbproject/Makefile-Release.mk --- a/nbproject/Makefile-Release.mk Sun Jul 08 01:40:38 2018 +0200 +++ b/nbproject/Makefile-Release.mk Mon Jul 09 00:43:35 2018 +0200 @@ -35,8 +35,8 @@ # Object Files OBJECTFILES= \ - ${OBJECTDIR}/DataTypeWriter.o \ - ${OBJECTDIR}/DataTypeWriterBase.o + ${OBJECTDIR}/src/DataTypeWriter.o \ + ${OBJECTDIR}/src/DataTypeWriterBase.o # C Compiler Flags @@ -63,15 +63,15 @@ ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/librelpipe-lib-writer.cpp.${CND_DLIB_EXT} ${OBJECTFILES} ${LDLIBSOPTIONS} -shared -fPIC -${OBJECTDIR}/DataTypeWriter.o: DataTypeWriter.cpp - ${MKDIR} -p ${OBJECTDIR} +${OBJECTDIR}/src/DataTypeWriter.o: src/DataTypeWriter.cpp + ${MKDIR} -p ${OBJECTDIR}/src ${RM} "$@.d" - $(COMPILE.cc) -O2 -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DataTypeWriter.o DataTypeWriter.cpp + $(COMPILE.cc) -O2 -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/DataTypeWriter.o src/DataTypeWriter.cpp -${OBJECTDIR}/DataTypeWriterBase.o: DataTypeWriterBase.cpp - ${MKDIR} -p ${OBJECTDIR} +${OBJECTDIR}/src/DataTypeWriterBase.o: src/DataTypeWriterBase.cpp + ${MKDIR} -p ${OBJECTDIR}/src ${RM} "$@.d" - $(COMPILE.cc) -O2 -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DataTypeWriterBase.o DataTypeWriterBase.cpp + $(COMPILE.cc) -O2 -fPIC -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/DataTypeWriterBase.o src/DataTypeWriterBase.cpp # Subprojects .build-subprojects: diff -r 6e3494943c91 -r 1a574113da20 nbproject/configurations.xml --- a/nbproject/configurations.xml Sun Jul 08 01:40:38 2018 +0200 +++ b/nbproject/configurations.xml Mon Jul 09 00:43:35 2018 +0200 @@ -4,9 +4,9 @@ - DataTypeWriter.h - DataTypeWriterBase.h - common.h + include/DataTypeWriter.h + include/DataTypeWriterBase.h + include/common.h - DataTypeWriter.cpp - DataTypeWriterBase.cpp + src/DataTypeWriter.cpp + src/DataTypeWriterBase.cpp - + - + - + - + - + @@ -71,15 +71,15 @@ 5 - + - + - + - + - + diff -r 6e3494943c91 -r 1a574113da20 src/DataTypeWriter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/DataTypeWriter.cpp Mon Jul 09 00:43:35 2018 +0200 @@ -0,0 +1,15 @@ +#include "../include/DataTypeWriter.h" + +namespace relpipe { +namespace writer { + +template string_t DataTypeWriter::readString(std::istream &input) { + return toString(readValue(input)); +}; + +template void DataTypeWriter::writeString(std::ostream& output, const string_t &stringValue) { + writeValue(output, toValue(stringValue)); +}; + +} +} diff -r 6e3494943c91 -r 1a574113da20 src/DataTypeWriterBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/DataTypeWriterBase.cpp Mon Jul 09 00:43:35 2018 +0200 @@ -0,0 +1,24 @@ +#include +#include "../include/DataTypeWriterBase.h" + +namespace relpipe { +namespace writer { + +bool DataTypeWriterBase::supports(const integer_t &dataType) { + return dataType == typeId; +} + +bool DataTypeWriterBase::supports(const string_t &dataType) { + return dataType == typeCode; +} + +integer_t DataTypeWriterBase::getTypeId() { + return typeId; +} + +string_t DataTypeWriterBase::getTypeCode() { + return typeCode; +} + +} +}