MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / writeXMLStringForTextElement

Function writeXMLStringForTextElement

src/IO/WriteHelpers.h:714–742  ·  view source on GitHub ↗

Writing a string to a text node in XML (not into an attribute - otherwise you need more escaping).

Source from the content-addressed store, hash-verified

712
713/// Writing a string to a text node in XML (not into an attribute - otherwise you need more escaping).
714inline void writeXMLStringForTextElement(const char * begin, const char * end, WriteBuffer & buf)
715{
716 const char * pos = begin;
717 while (true)
718 {
719 /// NOTE Perhaps for some XML parsers, you need to escape the zero byte and some control characters.
720 const char * next_pos = find_first_symbols<'<', '&'>(pos, end);
721
722 if (next_pos == end)
723 {
724 buf.write(pos, end - pos);
725 break;
726 }
727 if (*next_pos == '<')
728 {
729 buf.write(pos, next_pos - pos);
730 ++next_pos;
731 writeCString("&lt;", buf);
732 }
733 else if (*next_pos == '&')
734 {
735 buf.write(pos, next_pos - pos);
736 ++next_pos;
737 writeCString("&amp;", buf);
738 }
739
740 pos = next_pos;
741 }
742}
743
744inline void writeXMLStringForTextElement(std::string_view s, WriteBuffer & buf)
745{

Callers 9

writePrefixMethod · 0.85
writeExceptionMethod · 0.85
serializeTextXMLMethod · 0.85
serializeTextXMLMethod · 0.85
serializeTextXMLMethod · 0.85
serializeTextXMLMethod · 0.85
serializeTextXMLMethod · 0.85
serializeTextXMLMethod · 0.85

Calls 3

writeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected