90 for (relpipe::reader::handlers::AttributeMetadata readerMetadata : attributes) { |
90 for (relpipe::reader::handlers::AttributeMetadata readerMetadata : attributes) { |
91 relationContext.writerMetadata.push_back({readerMetadata.getAttributeName(), writer->toTypeId(readerMetadata.getTypeName())}); |
91 relationContext.writerMetadata.push_back({readerMetadata.getAttributeName(), writer->toTypeId(readerMetadata.getTypeName())}); |
92 } |
92 } |
93 } |
93 } |
94 |
94 |
95 void attribute(const relpipe::common::type::StringX& value) override { |
95 void attribute(const void* value, const std::type_info& type) override { |
96 if (recordContext.attributeIndex == 0) { |
96 if (recordContext.attributeIndex == 0) { |
97 recordContext = RecordContext(); |
97 recordContext = RecordContext(); |
98 recordContext.writer.reset(relpipe::writer::Factory::create(recordContext.buffer)); |
98 recordContext.writer.reset(relpipe::writer::Factory::create(recordContext.buffer)); |
99 recordContext.writer->startRelation(relationContext.name, relationContext.writerMetadata, true); |
99 recordContext.writer->startRelation(relationContext.name, relationContext.writerMetadata, true); |
100 } |
100 } |
101 |
101 |
102 recordContext.writer->writeAttribute(value); // TODO: typed values instead of strings |
102 recordContext.writer->writeAttribute(value, type); |
103 recordContext.attributeIndex++; |
103 recordContext.attributeIndex++; |
104 |
104 |
105 if (recordContext.attributeIndex % relationContext.readerMetadata.size() == 0) { |
105 if (recordContext.attributeIndex % relationContext.readerMetadata.size() == 0) { |
106 writer->writeAttribute(toHex(recordContext.buffer.str())); |
106 writer->writeAttribute(toHex(recordContext.buffer.str())); |
107 recordContext.attributeIndex = 0; |
107 recordContext.attributeIndex = 0; |
108 } |
108 } |
109 } |
109 } |
110 |
110 |
111 void endOfPipe() { |
111 void endOfPipe() { |
112 // TODO: check number of attribute values |
112 if (recordContext.attributeIndex != 0) throw relpipe::reader::RelpipeReaderException(L"Invalid number of attributes at the end of the pipe – incomplete record."); |
113 } |
113 } |
114 |
114 |
115 }; |
115 }; |
116 |
116 |
117 } |
117 } |