MCPcopy Create free account
hub / github.com/boostorg/filesystem / convert

Function convert

src/path_traits.cpp:119–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117//--------------------------------------------------------------------------------------//
118
119BOOST_FILESYSTEM_DECL
120void convert(const char* from, const char* from_end, std::wstring& to, const codecvt_type* cvt)
121{
122 if (from == from_end)
123 return;
124
125 BOOST_ASSERT(from != nullptr);
126 BOOST_ASSERT(from_end != nullptr);
127
128 if (!cvt)
129 cvt = &fs::path::codecvt();
130
131 std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK
132
133 // dynamically allocate a buffer only if source is unusually large
134 if (buf_size > default_codecvt_buf_size)
135 {
136 std::unique_ptr< wchar_t[] > buf(new wchar_t[buf_size]);
137 convert_aux(from, from_end, buf.get(), buf.get() + buf_size, to, *cvt);
138 }
139 else
140 {
141 wchar_t buf[default_codecvt_buf_size];
142 convert_aux(from, from_end, buf, buf + default_codecvt_buf_size, to, *cvt);
143 }
144}
145
146//--------------------------------------------------------------------------------------//
147// convert const wchar_t* to string //

Callers 6

operator()Method · 0.50
operator()Method · 0.50
stringMethod · 0.50
wstringMethod · 0.50
operator()Method · 0.50

Calls 2

convert_auxFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected