PostGIS  2.2.8dev-r@@SVN_REVISION@@
stringbuffer.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * Copyright 2002 Thamer Alharbash
5  * Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
6  *
7  * Redistribution and use in source and binary forms, with or
8  * without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  *
19  * The name of the author may not be used to endorse or promote
20  * products derived from this software without specific prior
21  * written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
24  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34  * THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  **********************************************************************/
37 
38 #ifndef _STRINGBUFFER_H
39 #define _STRINGBUFFER_H 1
40 
41 #include <stdlib.h>
42 #include <stdarg.h>
43 #include <string.h>
44 #include <stdio.h>
45 
46 #define STRINGBUFFER_STARTSIZE 128
47 
48 typedef struct
49 {
50  size_t capacity;
51  char *str_end;
52  char *str_start;
53 }
55 
58 extern void stringbuffer_destroy(stringbuffer_t *sb);
59 extern void stringbuffer_clear(stringbuffer_t *sb);
60 void stringbuffer_set(stringbuffer_t *sb, const char *s);
62 extern void stringbuffer_append(stringbuffer_t *sb, const char *s);
63 extern int stringbuffer_aprintf(stringbuffer_t *sb, const char *fmt, ...);
64 extern const char *stringbuffer_getstring(stringbuffer_t *sb);
70 
71 #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:176
const char * stringbuffer_getstring(stringbuffer_t *sb)
Returns a reference to the internal string being managed by the stringbuffer.
Definition: stringbuffer.c:142
void stringbuffer_destroy(stringbuffer_t *sb)
Free the stringbuffer_t and all memory managed within it.
Definition: stringbuffer.c:71
void stringbuffer_copy(stringbuffer_t *sb, stringbuffer_t *src)
Copy the contents of src into dst.
Definition: stringbuffer.c:186
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:46
def fmt
Definition: pixval.py:92
void stringbuffer_clear(stringbuffer_t *sb)
Reset the stringbuffer_t.
Definition: stringbuffer.c:83
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:55
char * str_start
Definition: stringbuffer.h:52
void stringbuffer_append(stringbuffer_t *sb, const char *s)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:127
int stringbuffer_trim_trailing_white(stringbuffer_t *s)
Trims whitespace off the end of the stringbuffer.
Definition: stringbuffer.c:261
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:153
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:246
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:167
char stringbuffer_lastchar(stringbuffer_t *s)
Return the last character in the buffer.
Definition: stringbuffer.c:115
int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s)
Trims zeroes off the end of the last number in the stringbuffer.
Definition: stringbuffer.c:297