typed values instead of mere strings in the handler + check number of attributes at the end
--- a/src/SerializeHandler.h Sun Apr 17 16:39:29 2022 +0200
+++ b/src/SerializeHandler.h Tue Apr 19 21:00:07 2022 +0200
@@ -37,7 +37,7 @@
namespace tr {
namespace serialize {
-class SerializeHandler : public relpipe::reader::handlers::RelationalReaderStringHandler {
+class SerializeHandler : public relpipe::reader::handlers::RelationalReaderValueHandler {
private:
Configuration configuration;
shared_ptr<relpipe::writer::RelationalWriter> writer;
@@ -92,14 +92,14 @@
}
}
- void attribute(const relpipe::common::type::StringX& value) override {
+ void attribute(const void* value, const std::type_info& type) override {
if (recordContext.attributeIndex == 0) {
recordContext = RecordContext();
recordContext.writer.reset(relpipe::writer::Factory::create(recordContext.buffer));
recordContext.writer->startRelation(relationContext.name, relationContext.writerMetadata, true);
}
- recordContext.writer->writeAttribute(value); // TODO: typed values instead of strings
+ recordContext.writer->writeAttribute(value, type);
recordContext.attributeIndex++;
if (recordContext.attributeIndex % relationContext.readerMetadata.size() == 0) {
@@ -109,7 +109,7 @@
}
void endOfPipe() {
- // TODO: check number of attribute values
+ if (recordContext.attributeIndex != 0) throw relpipe::reader::RelpipeReaderException(L"Invalid number of attributes at the end of the pipe – incomplete record.");
}
};