src/INIWriter.h
branchv_0
changeset 11 4becf8474975
parent 8 7c85dc9a310b
equal deleted inserted replaced
10:e170ecb1dffe 11:4becf8474975
   103 		if (type == EscapingProcessor::TextType::SectionName || type == EscapingProcessor::TextType::SectionTag) quotingType = quotingForSections.findEffectiveQuotingType(value);
   103 		if (type == EscapingProcessor::TextType::SectionName || type == EscapingProcessor::TextType::SectionTag) quotingType = quotingForSections.findEffectiveQuotingType(value);
   104 		else if (type == EscapingProcessor::TextType::EntryKey || type == EscapingProcessor::TextType::EntrySubKey) quotingType = quotingForKeys.findEffectiveQuotingType(value);
   104 		else if (type == EscapingProcessor::TextType::EntryKey || type == EscapingProcessor::TextType::EntrySubKey) quotingType = quotingForKeys.findEffectiveQuotingType(value);
   105 		else if (type == EscapingProcessor::TextType::EntryValue) quotingType = quotingForValues.findEffectiveQuotingType(value);
   105 		else if (type == EscapingProcessor::TextType::EntryValue) quotingType = quotingForValues.findEffectiveQuotingType(value);
   106 		else quotingType = EscapingProcessor::QuotingType::None;
   106 		else quotingType = EscapingProcessor::QuotingType::None;
   107 
   107 
   108 		for (ConfiguredEscapingProcessor p : escapingProcessors) if (p.enbaled) result = p.processor->escape(result, type, quotingType);
   108 		for (ConfiguredEscapingProcessor p : escapingProcessors) if (p.enabled) result = p.processor->escape(result, type, quotingType);
   109 
   109 
   110 		if (quotingType == EscapingProcessor::QuotingType::Quotes) result = L"\"" + result + L"\"";
   110 		if (quotingType == EscapingProcessor::QuotingType::Quotes) result = L"\"" + result + L"\"";
   111 		else if (quotingType == EscapingProcessor::QuotingType::Apostrophes) result = L"'" + result + L"'";
   111 		else if (quotingType == EscapingProcessor::QuotingType::Apostrophes) result = L"'" + result + L"'";
   112 
   112 
   113 		return convertor.to_bytes(result);
   113 		return convertor.to_bytes(result);
   115 
   115 
   116 	class ConfiguredEscapingProcessor {
   116 	class ConfiguredEscapingProcessor {
   117 	public:
   117 	public:
   118 		std::shared_ptr<EscapingProcessor> processor;
   118 		std::shared_ptr<EscapingProcessor> processor;
   119 		const relpipe::common::type::StringX uri;
   119 		const relpipe::common::type::StringX uri;
   120 		bool enbaled;
   120 		bool enabled;
   121 
   121 
   122 		ConfiguredEscapingProcessor(std::shared_ptr<EscapingProcessor> processor, const relpipe::common::type::StringX uri, bool enbaled) : processor(processor), uri(uri), enbaled(enbaled) {
   122 		ConfiguredEscapingProcessor(std::shared_ptr<EscapingProcessor> processor, const relpipe::common::type::StringX uri, bool enabled) : processor(processor), uri(uri), enabled(enabled) {
   123 		}
   123 		}
   124 
   124 
   125 	};
   125 	};
   126 
   126 
   127 	std::vector<ConfiguredEscapingProcessor> escapingProcessors;
   127 	std::vector<ConfiguredEscapingProcessor> escapingProcessors;
   128 
   128 
   129 	bool setEscaping(const relpipe::common::type::StringX& uri, const relpipe::common::type::StringX& value) {
   129 	bool setEscaping(const relpipe::common::type::StringX& uri, const relpipe::common::type::StringX& value) {
   130 		for (ConfiguredEscapingProcessor& p : escapingProcessors) {
   130 		for (ConfiguredEscapingProcessor& p : escapingProcessors) {
   131 			if (p.uri == uri) {
   131 			if (p.uri == uri) {
   132 				p.enbaled = parseBoolean(value);
   132 				p.enabled = parseBoolean(value);
   133 				return true;
   133 				return true;
   134 			}
   134 			}
   135 		}
   135 		}
   136 		return false;
   136 		return false;
   137 	}
   137 	}