41 std::string commentSeparatorForEntries = " ; "; |
41 std::string commentSeparatorForEntries = " ; "; |
42 std::string commentSeparatorStandalone = "; "; |
42 std::string commentSeparatorStandalone = "; "; |
43 |
43 |
44 relpipe::common::type::StringX hierarchySeparator = L"/"; |
44 relpipe::common::type::StringX hierarchySeparator = L"/"; |
45 bool allowSections = true; |
45 bool allowSections = true; |
|
46 |
|
47 bool skipEmpty = false; |
|
48 bool skipNull = false; |
46 |
49 |
47 bool hasContent = false; |
50 bool hasContent = false; |
48 |
51 |
49 std::vector<relpipe::common::type::StringX> currentSection; |
52 std::vector<relpipe::common::type::StringX> currentSection; |
50 |
53 |
194 else if (uri == option::CommentSeparatorForEntries) commentSeparatorForEntries = convertor.to_bytes(value); |
197 else if (uri == option::CommentSeparatorForEntries) commentSeparatorForEntries = convertor.to_bytes(value); |
195 else if (uri == option::CommentSeparatorStandalone) commentSeparatorStandalone = convertor.to_bytes(value); |
198 else if (uri == option::CommentSeparatorStandalone) commentSeparatorStandalone = convertor.to_bytes(value); |
196 else if (uri == option::KeyValueSeparator) keyValueSeparator = convertor.to_bytes(value); |
199 else if (uri == option::KeyValueSeparator) keyValueSeparator = convertor.to_bytes(value); |
197 else if (uri == option::HierarchySeparator) hierarchySeparator = value; |
200 else if (uri == option::HierarchySeparator) hierarchySeparator = value; |
198 else if (uri == option::AllowSections) allowSections = parseBoolean(value); |
201 else if (uri == option::AllowSections) allowSections = parseBoolean(value); |
|
202 else if (uri == option::SkipEmpty) skipEmpty = parseBoolean(value); |
|
203 else if (uri == option::SkipNull) skipNull = parseBoolean(value); |
199 else if (uri == option::QuotesTypeForSections) quotingForSections.type = parseQuotingType(value); |
204 else if (uri == option::QuotesTypeForSections) quotingForSections.type = parseQuotingType(value); |
200 else if (uri == option::QuotesTypeForKeys) quotingForKeys.type = parseQuotingType(value); |
205 else if (uri == option::QuotesTypeForKeys) quotingForKeys.type = parseQuotingType(value); |
201 else if (uri == option::QuotesTypeForValues) quotingForValues.type = parseQuotingType(value); |
206 else if (uri == option::QuotesTypeForValues) quotingForValues.type = parseQuotingType(value); |
202 else if (uri == option::QuotesPatternForSections) quotingForSections.pattern = value; |
207 else if (uri == option::QuotesPatternForSections) quotingForSections.pattern = value; |
203 else if (uri == option::QuotesPatternForKeys) quotingForKeys.pattern = value; |
208 else if (uri == option::QuotesPatternForKeys) quotingForKeys.pattern = value; |
241 currentSection.pop_back(); |
246 currentSection.pop_back(); |
242 output.flush(); |
247 output.flush(); |
243 } |
248 } |
244 |
249 |
245 void entry(const EntryEvent& event) { |
250 void entry(const EntryEvent& event) { |
|
251 if (skipEmpty && event.value.empty()) return; |
|
252 if (skipNull && event.value.empty()) return; // TODO: distinguish null and empty (when supported in the relpipe format) |
246 // TODO: escape/quote parts separately + configurable quoting of parts or whole + the same for sub keys |
253 // TODO: escape/quote parts separately + configurable quoting of parts or whole + the same for sub keys |
247 if (!allowSections && currentSection.size()) output << escape(getCurrentSectionFullName(), EscapingProcessor::TextType::EntryKey) << convertor.to_bytes(hierarchySeparator); |
254 if (!allowSections && currentSection.size()) output << escape(getCurrentSectionFullName(), EscapingProcessor::TextType::EntryKey) << convertor.to_bytes(hierarchySeparator); |
248 output << escape(event.key, EscapingProcessor::TextType::EntryKey); |
255 output << escape(event.key, EscapingProcessor::TextType::EntryKey); |
249 if (event.subKey.size()) output << "[" << escape(event.subKey, EscapingProcessor::TextType::EntrySubKey) << "]"; |
256 if (event.subKey.size()) output << "[" << escape(event.subKey, EscapingProcessor::TextType::EntrySubKey) << "]"; |
250 output << keyValueSeparator << escape(event.value, EscapingProcessor::TextType::EntryValue); |
257 output << keyValueSeparator << escape(event.value, EscapingProcessor::TextType::EntryValue); |