Rudiments
stringbufferinlines.h
1// Copyright (c) 1999-2018 David Muse
2// See the COPYING file for more information
3
4#include <rudiments/charstring.h>
5#include <rudiments/character.h>
6
7inline
10
11inline
14
15inline
19
20inline
23
24inline
26 if (this!=&s) {
28 }
29 return *this;
30}
31
32inline
35
36inline
40
41inline
45
46inline
50
51inline
54 const char *retval=(const char *)getBuffer();
55 _position(_position()-1);
56 _size(_size()-1);
57 return retval;
58}
59
60inline
64
65inline
68 return (char *)detachBuffer();
69}
70
71inline
75
76inline
78 return bytebuffer::clear();
79}
80
81inline
85
86inline
90
91inline
92stringbuffer *stringbuffer::append(const byte_t *string) {
93 return (stringbuffer *)bytebuffer::append(string,
94 charstring::getLength((const char *)string));
95}
96
97inline
98stringbuffer *stringbuffer::append(const byte_t *string, size_t size) {
99 return (stringbuffer *)bytebuffer::append(string,size);
100}
101
102inline
103stringbuffer *stringbuffer::append(const char *string) {
104 return (stringbuffer *)bytebuffer::
105 append(string,charstring::getLength(string));
106}
107
108inline
109stringbuffer *stringbuffer::append(const char *string, size_t length) {
110 return (stringbuffer *)bytebuffer::append(string,length);
111}
112
113inline
117
118inline
120 return append(number,1);
121}
122
123inline
125 return append(number,1);
126}
127
128inline
130 return append(number,1);
131}
132
133inline
135 return append((int64_t)number,zeropadding);
136}
137
138inline
140 return append((int64_t)number,zeropadding);
141}
142
143inline
146 append(num);
147 delete[] num;
148 return this;
149}
150
151inline
155
156inline
158 return append(number,1);
159}
160
161inline
163 return append(number,1);
164}
165
166inline
168 return append(number,1);
169}
170
171inline
173 return append((uint64_t)number,zeropadding);
174}
175
176inline
178 return append((uint64_t)number,zeropadding);
179}
180
181inline
184 append(num);
185 delete[] num;
186 return this;
187}
188
189inline
193
194inline
195stringbuffer *stringbuffer::append(float number, uint16_t scale) {
196 printf("%.*f",scale,number);
197 return this;
198}
199
200inline
202 uint16_t scale) {
203 printf("%*.*f",precision,scale,number);
204 return this;
205}
206
207inline
209 return append(number,4);
210}
211
212inline
213stringbuffer *stringbuffer::append(double number, uint16_t scale) {
214 printf("%.*f",scale,number);
215 return this;
216}
217
218inline
220 uint16_t scale) {
221 printf("%*.*f",precision,scale,number);
222 return this;
223}
224
225inline
226ssize_t stringbuffer::write(const byte_t *string) {
227 return bytebuffer::write(string,
228 charstring::getLength((const char *)string));
229}
230
231inline
232ssize_t stringbuffer::write(const byte_t *string, size_t size) {
233 return bytebuffer::write(string,size);
234}
235
236inline
237ssize_t stringbuffer::write(const char *string) {
238 return bytebuffer::write(string,charstring::getLength(string));
239}
240
241inline
242ssize_t stringbuffer::write(const char *string, size_t length) {
243 return bytebuffer::write(string,length);
244}
245
246inline
250
251inline
252ssize_t stringbuffer::write(int16_t number) {
253 return printf("%hd",number);
254}
255
256inline
257ssize_t stringbuffer::write(int32_t number) {
258 return printf("%d",number);
259}
260
261inline
262ssize_t stringbuffer::write(int64_t number) {
263 return printf("%lld",number);
264}
265
266inline
269}
270
271inline
272ssize_t stringbuffer::write(uint16_t number) {
273 return printf("%hd",number);
274}
275
276inline
277ssize_t stringbuffer::write(uint32_t number) {
278 return printf("%d",number);
279}
280
281inline
282ssize_t stringbuffer::write(uint64_t number) {
283 return bytebuffer::printf("%lld",number);
284}
285
286inline
288 return write(number,4);
289}
290
291inline
292ssize_t stringbuffer::write(float number, uint16_t scale) {
293 return printf("%.*f",scale,number);
294}
295
296inline
297ssize_t stringbuffer::write(float number, uint16_t precision, uint16_t scale) {
298 return printf("%*.*f",precision,scale,number);
299}
300
301inline
303 return write(number,4);
304}
305
306inline
307ssize_t stringbuffer::write(double number, uint16_t scale) {
308 return printf("%.*f",scale,number);
309}
310
311inline
312ssize_t stringbuffer::write(double number, uint16_t precision, uint16_t scale) {
313 return printf("%*.*f",precision,scale,number);
314}
315
316inline
320
321inline
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
static char * parseNumber(int16_t number)
static size_t getLength(const char *string)
virtual ssize_t printf(const char *format,...)
Definition outputinlines.h:25
Definition stringbuffer.h:13
size_t getStringLength()
Definition stringbufferinlines.h:61
const char * getString()
Definition stringbufferinlines.h:52
stringbuffer()
Definition stringbufferinlines.h:8
off64_t setPositionRelativeToCurrent(off64_t pos)
Definition stringbufferinlines.h:42
stringbuffer * append(const byte_t *string)
Definition stringbufferinlines.h:92
~stringbuffer()
Definition stringbufferinlines.h:33
off64_t getPosition()
Definition stringbufferinlines.h:72
ssize_t write(const byte_t *string)
Definition stringbufferinlines.h:226
stringbuffer & operator=(stringbuffer &s)
Definition stringbufferinlines.h:25
bool clear()
Definition stringbufferinlines.h:77
off64_t setPositionRelativeToBeginning(off64_t pos)
Definition stringbufferinlines.h:37
void truncate()
Definition stringbufferinlines.h:322
char * detachString()
Definition stringbufferinlines.h:66
off64_t setPositionRelativeToEnd(off64_t pos)
Definition stringbufferinlines.h:47