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