66 |
66 |
67 void startDocument() override { |
67 void startDocument() override { |
68 vector<AttributeMetadata> metadata; |
68 vector<AttributeMetadata> metadata; |
69 metadata.push_back({L"section", TypeId::STRING}); |
69 metadata.push_back({L"section", TypeId::STRING}); |
70 metadata.push_back({L"key", TypeId::STRING}); |
70 metadata.push_back({L"key", TypeId::STRING}); |
|
71 metadata.push_back({L"subkey", TypeId::STRING}); |
71 metadata.push_back({L"value", TypeId::STRING}); |
72 metadata.push_back({L"value", TypeId::STRING}); |
72 writer->startRelation(configuration.relation, metadata, true); |
73 writer->startRelation(configuration.relation, metadata, true); |
73 }; |
74 }; |
74 |
75 |
75 void endDocument() override { |
76 void endDocument() override { |
82 |
83 |
83 void endSection() override { |
84 void endSection() override { |
84 currentSection.pop_back(); |
85 currentSection.pop_back(); |
85 }; |
86 }; |
86 |
87 |
87 void entry(const std::string& key, const std::string& value) override { |
88 void entry(const std::string& key, const std::string& subkey, const std::string& value) override { |
88 writer->writeAttribute(convertor.from_bytes(getCurrentSectionFullName())); |
89 writer->writeAttribute(convertor.from_bytes(getCurrentSectionFullName())); |
89 writer->writeAttribute(convertor.from_bytes(key)); |
90 writer->writeAttribute(convertor.from_bytes(key)); |
|
91 writer->writeAttribute(convertor.from_bytes(subkey)); |
90 writer->writeAttribute(convertor.from_bytes(value)); |
92 writer->writeAttribute(convertor.from_bytes(value)); |
91 }; |
93 }; |
92 |
94 |
93 // TODO: handle also comments and whitespace (to allow lossless transformation from INI and back to INI) |
95 // TODO: handle also comments and whitespace (to allow lossless transformation from INI and back to INI) |
94 // TODO: handle also subkeys (in [] brackets in the key) |
96 // TODO: make subkeys (in [] brackets in the key) optional/configurable |
95 |
97 |
96 }; |
98 }; |
97 |
99 |
98 void INICommand::process(std::istream& input, std::shared_ptr<writer::RelationalWriter> writer, Configuration& configuration) { |
100 void INICommand::process(std::istream& input, std::shared_ptr<writer::RelationalWriter> writer, Configuration& configuration) { |
99 FlatINIContentHandler handler(writer, configuration); |
101 FlatINIContentHandler handler(writer, configuration); |