MCPcopy Create free account
hub / github.com/assimp/assimp / encodeXML

Function encodeXML

code/AssetLib/Assxml/AssxmlFileWriter.cpp:170–184  ·  view source on GitHub ↗

----------------------------------------------------------------------------------- Some chunks of text will need to be encoded for XML http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377

Source from the content-addressed store, hash-verified

168// Some chunks of text will need to be encoded for XML
169// http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377
170static std::string encodeXML(const std::string &data) {
171 std::string buffer;
172 buffer.reserve(data.size());
173 for (size_t pos = 0; pos != data.size(); ++pos) {
174 switch (data[pos]) {
175 case '&': buffer.append("&"); break;
176 case '\"': buffer.append("""); break;
177 case '\'': buffer.append("'"); break;
178 case '<': buffer.append("&lt;"); break;
179 case '>': buffer.append("&gt;"); break;
180 default: buffer.append(&data[pos], 1); break;
181 }
182 }
183 return buffer;
184}
185
186// -----------------------------------------------------------------------------------
187// Write a text model dump

Callers 1

WriteDumpFunction · 0.85

Calls 3

appendMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected