PostGIS  2.5.1dev-r@@SVN_REVISION@@
stringbuffer.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright 2002 Thamer Alharbash
22  * Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
23  *
24  **********************************************************************/
25 
26 
27 #ifndef _STRINGBUFFER_H
28 #define _STRINGBUFFER_H 1
29 
30 #include <stdlib.h>
31 #include <stdarg.h>
32 #include <string.h>
33 #include <stdio.h>
34 
35 #define STRINGBUFFER_STARTSIZE 128
36 
37 typedef struct
38 {
39  size_t capacity;
40  char *str_end;
41  char *str_start;
42 }
44 
47 extern void stringbuffer_init(stringbuffer_t *s);
49 extern void stringbuffer_destroy(stringbuffer_t *sb);
50 extern void stringbuffer_clear(stringbuffer_t *sb);
51 void stringbuffer_set(stringbuffer_t *sb, const char *s);
53 extern void stringbuffer_append(stringbuffer_t *sb, const char *s);
54 extern int stringbuffer_aprintf(stringbuffer_t *sb, const char *fmt, ...);
55 extern const char *stringbuffer_getstring(stringbuffer_t *sb);
61 
62 #endif /* _STRINGBUFFER_H */
void stringbuffer_set(stringbuffer_t *sb, const char *s)
Clear the stringbuffer_t and re-start it with the specified string.
Definition: stringbuffer.c:183
const char * stringbuffer_getstring(stringbuffer_t *sb)
Returns a reference to the internal string being managed by the stringbuffer.
Definition: stringbuffer.c:149
void stringbuffer_destroy(stringbuffer_t *sb)
Free the stringbuffer_t and all memory managed within it.
Definition: stringbuffer.c:78
void stringbuffer_copy(stringbuffer_t *sb, stringbuffer_t *src)
Copy the contents of src into dst.
Definition: stringbuffer.c:193
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:35
void stringbuffer_init(stringbuffer_t *s)
Definition: stringbuffer.c:56
def fmt
Definition: pixval.py:92
void stringbuffer_clear(stringbuffer_t *sb)
Reset the stringbuffer_t.
Definition: stringbuffer.c:90
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:65
char * str_start
Definition: stringbuffer.h:41
void stringbuffer_append(stringbuffer_t *sb, const char *s)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:134
int stringbuffer_trim_trailing_white(stringbuffer_t *s)
Trims whitespace off the end of the stringbuffer.
Definition: stringbuffer.c:268
char * s
Definition: cu_in_wkt.c:23
char * stringbuffer_getstringcopy(stringbuffer_t *sb)
Returns a newly allocated string large enough to contain the current state of the string...
Definition: stringbuffer.c:160
int stringbuffer_aprintf(stringbuffer_t *sb, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided...
Definition: stringbuffer.c:253
int stringbuffer_getlength(stringbuffer_t *sb)
Returns the length of the current string, not including the null terminator (same behavior as strlen(...
Definition: stringbuffer.c:174
char stringbuffer_lastchar(stringbuffer_t *s)
Return the last character in the buffer.
Definition: stringbuffer.c:122
void stringbuffer_release(stringbuffer_t *s)
Definition: stringbuffer.c:50
int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s)
Trims zeroes off the end of the last number in the stringbuffer.
Definition: stringbuffer.c:304