--- a/src/StreamRelationalWriter.h Sun Jul 22 00:08:13 2018 +0200
+++ b/src/StreamRelationalWriter.h Sun Jul 22 10:26:22 2018 +0200
@@ -23,20 +23,20 @@
types::IntegerDataTypeWriter integerWriter;
types::StringDataTypeWriter stringWriter;
vector<DataTypeWriterBase*> writers = {&booleanWriter, &integerWriter, &stringWriter};
-
+
/**
* count of columns in the current table
*/
integer_t columnCount;
-
+
/**
* types of columns in the current table
*/
- vector<integer_t> columnTypes;
+ vector<TypeId> columnTypes;
- void writeString(const string_t &stringValue, const integer_t typeId) {
+ void writeString(const string_t &stringValue, const TypeId typeId) {
for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->writeString(output, stringValue);
- throw RelpipeWriterException(L"Unsupported data type: " + typeId);
+ throw RelpipeWriterException(L"Unsupported data type: " + static_cast<integer_t>(typeId));
}
public:
@@ -45,16 +45,16 @@
output(output) {
}
- integer_t toTypeId(const string_t typeCode) override {
+ TypeId toTypeId(const string_t typeCode) override {
for (DataTypeWriterBase* writer : writers) if (writer->supports(typeCode)) return writer->getTypeId();
throw RelpipeWriterException(L"Unsupported data type: " + typeCode);
}
- string_t toTypeCode(const integer_t typeId) override {
+ string_t toTypeCode(const TypeId typeId) override {
for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->getTypeCode();
- throw RelpipeWriterException(L"Unsupported data type: " + typeId);
+ throw RelpipeWriterException(L"Unsupported data type: " + static_cast<integer_t>(typeId));
}
-
+
void startRelation(string_t name, std::vector<std::pair<string_t, TypeId> > attributes, boolean_t writeHeader) override {
string_t tableName = name;
columnCount = attributes.size();
@@ -69,14 +69,14 @@
// Write column names:
for (size_t c = 0; c < columnCount; c++) {
- wstring columnName = attributes[c].first;
+ wstring columnName = attributes[c].first;
stringWriter.writeValue(output, columnName);
}
// Write column types:
for (size_t c = 0; c < columnCount; c++) {
- integer_t typeId = static_cast<integer_t>(attributes[c].second);
- integerWriter.writeValue(output, typeId);
+ TypeId typeId = attributes[c].second;
+ integerWriter.writeValue(output, static_cast<integer_t>(typeId));
columnTypes[c] = typeId;
}
@@ -91,7 +91,7 @@
}
wstring stringValue = attributes[c];
- integer_t typeId = columnTypes[c % columnCount];
+ TypeId typeId = columnTypes[c % columnCount];
writeString(stringValue, typeId);
}
}