MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / convert_buffer_generic

Function convert_buffer_generic

lib/pugixml/src/pugixml.cpp:2104–2127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2102 }
2103
2104 template <typename D> PUGI__FN bool convert_buffer_generic(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, D)
2105 {
2106 const typename D::type* data = static_cast<const typename D::type*>(contents);
2107 size_t data_length = size / sizeof(typename D::type);
2108
2109 // first pass: get length in wchar_t units
2110 size_t length = D::process(data, data_length, 0, wchar_counter());
2111
2112 // allocate buffer of suitable length
2113 char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
2114 if (!buffer) return false;
2115
2116 // second pass: convert utf16 input to wchar_t
2117 wchar_writer::value_type obegin = reinterpret_cast<wchar_writer::value_type>(buffer);
2118 wchar_writer::value_type oend = D::process(data, data_length, obegin, wchar_writer());
2119
2120 assert(oend == obegin + length);
2121 *oend = 0;
2122
2123 out_buffer = buffer;
2124 out_length = length + 1;
2125
2126 return true;
2127 }
2128
2129 PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable)
2130 {

Callers 1

convert_bufferFunction · 0.85

Calls 2

utf8_counterClass · 0.85
utf8_writerClass · 0.85

Tested by

no test coverage detected