13 class RelationalWriter { |
13 class RelationalWriter { |
14 public: |
14 public: |
15 |
15 |
16 virtual ~RelationalWriter() = default; |
16 virtual ~RelationalWriter() = default; |
17 |
17 |
|
18 /** |
|
19 * @param typeCode string type code as defined in Specification |
|
20 * @return numeric id of given type |
|
21 * @throws RelpipeWriterException on unsupported typeCode |
|
22 */ |
18 virtual TypeId toTypeId(const string_t typeCode) = 0; |
23 virtual TypeId toTypeId(const string_t typeCode) = 0; |
19 |
24 |
|
25 /** |
|
26 * @param typeId numeric type id as defined in Specification |
|
27 * @return string code of given type |
|
28 * @throws RelpipeWriterException on unsupported typeId |
|
29 */ |
20 virtual string_t toTypeCode(const TypeId typeId) = 0; |
30 virtual string_t toTypeCode(const TypeId typeId) = 0; |
21 |
31 |
|
32 /** |
|
33 * @param name name of the relation (table) |
|
34 * @param attributes list of attributes (columns) containing their names and types |
|
35 * @param writeHeader header might be omitted – when appending new records to a stream alreaready containing the header |
|
36 */ |
22 virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes, boolean_t writeHeader) = 0; |
37 virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes, boolean_t writeHeader) = 0; |
23 |
38 |
|
39 /** |
|
40 * Writes a single attribute. |
|
41 * @param value string representation of value of given attribute type as defined in Specification |
|
42 */ |
24 virtual void writeAttribute(const string_t& value) = 0; |
43 virtual void writeAttribute(const string_t& value) = 0; |
25 |
44 |
26 // TODO: fluent interface? |
45 // TODO: fluent interface? |
27 // TODO: << operator? |
46 // TODO: << operator? |
28 // TODO: write bitmap + attribute: |
47 // TODO: write bitmap + attribute: |
29 // virtual void writeBitmap(...) = 0; |
48 // virtual void writeBitmap(...) = 0; |
30 // virtual void writeAttribute(string_t attribute) = 0; |
49 // virtual void writeAttribute(string_t attribute) = 0; |
31 |
50 |
|
51 /** |
|
52 * Writes a single attribute. |
|
53 * @param value raw pointer to the value in format of given attribute type as defined in Specification |
|
54 * @param type used as a safety mechanism to avoid wrong pointer interpretation; |
|
55 * should be called in this way: writeAttribute(&value, typeid(value)); |
|
56 * if the type does not match, the RelpipeWriterException is thrown |
|
57 */ |
32 virtual void writeAttribute(const void* value, const std::type_info& type) = 0; |
58 virtual void writeAttribute(const void* value, const std::type_info& type) = 0; |
33 |
59 |
34 }; |
60 }; |
35 |
61 |
36 } |
62 } |