src/StreamRelationalReader.h
branchv_0
changeset 19 3e1308e7606d
parent 18 e11f1ad20826
child 21 abd3e7f26584
equal deleted inserted replaced
18:e11f1ad20826 19:3e1308e7606d
    65 	void read(std::istream &input, std::function<void(const string_t&, const void *, const std::type_info&) > handler, const TypeId typeId) {
    65 	void read(std::istream &input, std::function<void(const string_t&, const void *, const std::type_info&) > handler, const TypeId typeId) {
    66 		for (DataTypeReaderBase* reader : readers) if (reader->supports(typeId)) return reader->read(input, handler);
    66 		for (DataTypeReaderBase* reader : readers) if (reader->supports(typeId)) return reader->read(input, handler);
    67 		throw RelpipeReaderException(L"Unsupported data type: " + (int) typeId);
    67 		throw RelpipeReaderException(L"Unsupported data type: " + (int) typeId);
    68 	}
    68 	}
    69 
    69 
       
    70 	void endOfPipe() {
       
    71 		for (int i = 0; i < stringHandlers.size(); i++) stringHandlers[i]->endOfPipe();
       
    72 		for (int i = 0; i < valueHandlers.size(); i++) valueHandlers[i]->endOfPipe();
       
    73 	}
       
    74 
    70 public:
    75 public:
    71 
    76 
    72 	StreamRelationalReader(std::istream &input) :
    77 	StreamRelationalReader(std::istream &input) :
    73 	input(input) {
    78 	input(input) {
    74 	}
    79 	}
    98 					if (dataPart == DATA_PART_ROW) {
   103 					if (dataPart == DATA_PART_ROW) {
    99 						// last part was row
   104 						// last part was row
   100 						// input was fully read
   105 						// input was fully read
   101 						// we are finished
   106 						// we are finished
   102 						// TODO: printCachedData(output); ???
   107 						// TODO: printCachedData(output); ???
       
   108 						endOfPipe();
   103 						return;
   109 						return;
   104 					} else if (dataPart == DATA_PART_START) {
   110 					} else if (dataPart == DATA_PART_START) {
   105 						// Empty relation might be weird but it is valid data.
   111 						// Empty relation might be weird but it is valid data.
   106 						// Actually, it is not so weird as it looks.
   112 						// Actually, it is not so weird as it looks.
   107 						// fwprintf(stderr, L"Warning: The table has no rows. Weird… but OK.\n");
   113 						// fwprintf(stderr, L"Warning: The table has no rows. Weird… but OK.\n");
       
   114 						endOfPipe();
   108 						return;
   115 						return;
   109 					} else {
   116 					} else {
   110 						// in current format, there is no other data part
   117 						// in current format, there is no other data part
   111 						// so this will never happen
   118 						// so this will never happen
   112 						// but maybe later…
   119 						// but maybe later…