Rudiments
wstringbufferinlines.h
1// Copyright (c) 1999-2018 David Muse
2// See the COPYING file for more information
3
4#include <rudiments/wcharstring.h>
5#include <rudiments/charstring.h>
6#include <rudiments/wcharacter.h>
7
8inline
11
12inline
15
16inline
21
22inline
25
26inline
28 if (this!=&s) {
30 }
31 return *this;
32}
33
34inline
37
38inline
43
44inline
49
50inline
55
56inline
57const wchar_t *wstringbuffer::getString() {
59 const wchar_t *retval=(const wchar_t *)getBuffer();
60 _position(_position()-1);
61 _size(_size()-1);
62 return retval;
63}
64
65inline
69
70inline
73 return (wchar_t *)detachBuffer();
74}
75
76inline
78 return bytebuffer::getPosition()/sizeof(wchar_t);
79}
80
81inline
83 return bytebuffer::clear();
84}
85
86inline
90
91inline
94 initialsize*sizeof(wchar_t));
95}
96
97inline
98wstringbuffer *wstringbuffer::append(const wchar_t *string) {
99 return append(string,wcharstring::getLength(string));
100}
101
102inline
103wstringbuffer *wstringbuffer::append(const wchar_t *string, size_t length) {
104 return (wstringbuffer *)bytebuffer::append(string,length);
105}
106
107inline
111
112inline
116
117inline
121
122inline
126
127inline
129 return append((int64_t)number,zeropadding);
130}
131
132inline
134 return append((int64_t)number,zeropadding);
135}
136
137inline
140 append(num);
141 delete[] num;
142 return this;
143}
144
145inline
147 return append(number,1);
148}
149
150inline
152 return append(number,1);
153}
154
155inline
157 return append(number,1);
158}
159
160inline
162 return append((uint64_t)number,zeropadding);
163}
164
165inline
167 return append((uint64_t)number,zeropadding);
168}
169
170inline
173 append(num);
174 delete[] num;
175 return this;
176}
177
178inline
182
183inline
185 printf(L"%.*f",scale,number);
186 return this;
187}
188
189inline
191 uint16_t scale) {
192 printf(L"%*.*f",precision,scale,number);
193 return this;
194}
195
196inline
200
201inline
203 printf(L"%.*f",scale,number);
204 return this;
205}
206
207inline
209 uint16_t scale) {
210 printf(L"%*.*f",precision,scale,number);
211 return this;
212}
213
214inline
215ssize_t wstringbuffer::write(const wchar_t *string) {
216 return write(string,wcharstring::getLength(string));
217}
218
219inline
220ssize_t wstringbuffer::write(const wchar_t *string, size_t length) {
221 return bytebuffer::write(string,length);
222}
223
224inline
227}
228
229inline
230ssize_t wstringbuffer::write(int16_t number) {
232 return printf(L"%hd",number);
233 } else {
235 ssize_t retval=write(s);
236 delete[] s;
237 return retval;
238 }
239}
240
241inline
242ssize_t wstringbuffer::write(int32_t number) {
244 return printf(L"%d",number);
245 } else {
247 ssize_t retval=write(s);
248 delete[] s;
249 return retval;
250 }
251}
252
253inline
254ssize_t wstringbuffer::write(int64_t number) {
256 return printf(L"%lld",number);
257 } else {
259 ssize_t retval=write(s);
260 delete[] s;
261 return retval;
262 }
263}
264
265inline
266ssize_t wstringbuffer::write(uint16_t number) {
268 return printf(L"%hd",number);
269 } else {
271 ssize_t retval=write(s);
272 delete[] s;
273 return retval;
274 }
275}
276
277inline
278ssize_t wstringbuffer::write(uint32_t number) {
280 return printf(L"%d",number);
281 } else {
283 ssize_t retval=write(s);
284 delete[] s;
285 return retval;
286 }
287}
288
289inline
290ssize_t wstringbuffer::write(uint64_t number) {
292 return bytebuffer::printf(L"%lld",number);
293 } else {
295 ssize_t retval=write(s);
296 delete[] s;
297 return retval;
298 }
299}
300
301inline
304 return write(number,4);
305 } else {
307 ssize_t retval=write(s);
308 delete[] s;
309 return retval;
310 }
311}
312
313inline
314ssize_t wstringbuffer::write(float number, uint16_t scale) {
316 return printf(L"%.*f",scale,number);
317 } else {
318 wchar_t *s=wcharstring::parseNumber(number,scale);
319 ssize_t retval=write(s);
320 delete[] s;
321 return retval;
322 }
323}
324
325inline
326ssize_t wstringbuffer::write(float number, uint16_t precision, uint16_t scale) {
328 return printf(L"%*.*f",precision,scale,number);
329 } else {
331 ssize_t retval=write(s);
332 delete[] s;
333 return retval;
334 }
335}
336
337inline
340 return write(number,4);
341 } else {
343 ssize_t retval=write(s);
344 delete[] s;
345 return retval;
346 }
347}
348
349inline
350ssize_t wstringbuffer::write(double number, uint16_t scale) {
352 return printf(L"%.*f",scale,number);
353 } else {
354 wchar_t *s=wcharstring::parseNumber(number,scale);
355 ssize_t retval=write(s);
356 delete[] s;
357 return retval;
358 }
359}
360
361inline
363 uint16_t precision, uint16_t scale) {
365 return printf(L"%*.*f",precision,scale,number);
366 } else {
368 ssize_t retval=write(s);
369 delete[] s;
370 return retval;
371 }
372}
373
374inline
378
379inline
Definition avltree.h:11
Definition bytebuffer.h:13
bytebuffer & operator=(bytebuffer &v)
bool clear()
off64_t setPositionRelativeToCurrent(off64_t offset)
ssize_t write(const byte_t *data, size_t size)
off64_t getPosition()
virtual void truncate()
byte_t * detachBuffer()
off64_t setPositionRelativeToBeginning(off64_t offset)
off64_t setPositionRelativeToEnd(off64_t offset)
bytebuffer * append(const byte_t *data, size_t size)
const byte_t * getBuffer()
Definition character.h:11
virtual ssize_t printf(const char *format,...)
Definition outputinlines.h:25
static bool supportsPrintf()
static size_t getLength(const wchar_t *string)
static wchar_t * parseNumber(int16_t number)
Definition wstringbuffer.h:14
bool clear()
Definition wstringbufferinlines.h:82
wstringbuffer()
Definition wstringbufferinlines.h:9
off64_t getPosition()
Definition wstringbufferinlines.h:77
wstringbuffer & operator=(wstringbuffer &s)
Definition wstringbufferinlines.h:27
void truncate()
Definition wstringbufferinlines.h:380
off64_t setPositionRelativeToCurrent(off64_t pos)
Definition wstringbufferinlines.h:45
wchar_t * detachString()
Definition wstringbufferinlines.h:71
off64_t setPositionRelativeToBeginning(off64_t pos)
Definition wstringbufferinlines.h:39
wstringbuffer * append(const wchar_t *string)
Definition wstringbufferinlines.h:98
size_t getStringLength()
Definition wstringbufferinlines.h:66
ssize_t write(const wchar_t *string)
Definition wstringbufferinlines.h:215
off64_t setPositionRelativeToEnd(off64_t pos)
Definition wstringbufferinlines.h:51
~wstringbuffer()
Definition wstringbufferinlines.h:35
const wchar_t * getString()
Definition wstringbufferinlines.h:57