8 #ifndef BOOST_NOWIDE_DETAILS_WIDESTR_H_INCLUDED 9 #define BOOST_NOWIDE_DETAILS_WIDESTR_H_INCLUDED 10 #include <boost/nowide/convert.hpp> 24 template<
typename CharOut=
wchar_t,
typename CharIn =
char,
size_t BufferSize = 256>
28 static const size_t buffer_size = BufferSize;
29 typedef CharOut output_char;
30 typedef CharIn input_char;
36 if(other.mem_buffer_) {
38 while(other.mem_buffer_[len])
40 mem_buffer_ =
new output_char[len + 1];
41 memcpy(mem_buffer_,other.mem_buffer_,
sizeof(output_char) * (len+1));
44 memcpy(buffer_,other.buffer_,buffer_size *
sizeof(output_char));
50 std::swap(mem_buffer_,other.mem_buffer_);
51 for(
size_t i=0;i<buffer_size;i++)
52 std::swap(buffer_[i],other.buffer_[i]);
66 bool convert(input_char
const *input)
68 return convert(input,details::basic_strend(input));
70 bool convert(input_char
const *begin,input_char
const *end)
74 size_t space = get_space(
sizeof(input_char),
sizeof(output_char),end - begin) + 1;
75 if(space <= buffer_size) {
82 mem_buffer_ =
new output_char[space];
97 output_char
const *c_str()
const 106 delete [] mem_buffer_;
116 static size_t get_space(
size_t insize,
size_t outsize,
size_t in)
118 if(insize <= outsize)
120 else if(insize == 2 && outsize == 1)
122 else if(insize == 4 && outsize == 1)
127 output_char buffer_[buffer_size];
128 output_char *mem_buffer_;
basic_stackstring< wchar_t, char, 256 > wstackstring
Definition: stackstring.hpp:134
basic_stackstring< wchar_t, char, 16 > wshort_stackstring
Definition: stackstring.hpp:142
basic_stackstring< char, wchar_t, 16 > short_stackstring
Definition: stackstring.hpp:146
basic_stackstring< char, wchar_t, 256 > stackstring
Definition: stackstring.hpp:138
A class that allows to create a temporary wide or narrow UTF strings from wide or narrow UTF source...
Definition: stackstring.hpp:25
CharOut * basic_convert(CharOut *buffer, size_t buffer_size, CharIn const *source_begin, CharIn const *source_end)
Template function that converts a buffer of UTF sequences in range [source_begin,source_end) to the o...
Definition: convert.hpp:26