|  |  |  | Raptor RDF Syntax Parsing and Serializing Library Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
typedef raptor_stringbuffer; raptor_stringbuffer* raptor_new_stringbuffer (void); void raptor_free_stringbuffer (raptor_stringbuffer *stringbuffer); int raptor_stringbuffer_append_counted_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length, int do_copy); int raptor_stringbuffer_append_string (raptor_stringbuffer *stringbuffer, unsigned char *string, int do_copy); int raptor_stringbuffer_append_decimal (raptor_stringbuffer *stringbuffer, int integer); int raptor_stringbuffer_append_stringbuffer (raptor_stringbuffer *stringbuffer, raptor_stringbuffer *append); int raptor_stringbuffer_prepend_counted_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length, int do_copy); int raptor_stringbuffer_prepend_string (raptor_stringbuffer *stringbuffer, unsigned char *string, int do_copy); unsigned char * raptor_stringbuffer_as_string (raptor_stringbuffer *stringbuffer); size_t raptor_stringbuffer_length (raptor_stringbuffer *stringbuffer); int raptor_stringbuffer_copy_to_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length);
A utility class that allows easy construction of strings that grow at the end by appending new strings. Primarily used for constructing/serializing syntaxes into strings by the raptor_iostream and raptor_serializer classes.
raptor_stringbuffer* raptor_new_stringbuffer (void);
Create a new stringbuffer.
| Returns : | pointer to a raptor_stringbuffer object or NULL on failure | 
void raptor_free_stringbuffer (raptor_stringbuffer *stringbuffer);
Destroy a stringbuffer.
| 
 | stringbuffer object to destroy. | 
int raptor_stringbuffer_append_counted_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length, int do_copy);
If string is NULL or length is 0, no work is performed.
If do_copy is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.
Add a string to the stringbuffer.
| 
 | raptor stringbuffer | 
| 
 | string | 
| 
 | length of string | 
| 
 | non-0 to copy the string | 
| Returns : | non-0 on failure | 
int raptor_stringbuffer_append_string (raptor_stringbuffer *stringbuffer, unsigned char *string, int do_copy);
Add a string to the stringbuffer.
If string is NULL, no work is performed.
If do_copy is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.
| 
 | raptor stringbuffer | 
| 
 | string | 
| 
 | non-0 to copy the string | 
| Returns : | non-0 on failure | 
int raptor_stringbuffer_append_decimal (raptor_stringbuffer *stringbuffer, int integer);
Add an integer in decimal to the stringbuffer.
| 
 | raptor stringbuffer | 
| 
 | integer to format as decimal and add | 
| Returns : | non-0 on failure | 
int raptor_stringbuffer_append_stringbuffer (raptor_stringbuffer *stringbuffer, raptor_stringbuffer *append);
Add a stringbuffer to the stringbuffer.
This function removes the content from the appending stringbuffer, making it empty and appends it to the supplied stringbuffer.
| 
 | raptor_stringbuffer | 
| 
 | raptor_stringbuffer to append | 
| Returns : | non-0 on failure | 
int raptor_stringbuffer_prepend_counted_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length, int do_copy);
If do_copy is non-0, the passed-in string is copied into new memory otherwise the stringbuffer becomes the owner of the string pointer and will free it when the stringbuffer is destroyed.
Add a string to the start of the stringbuffer.
| 
 | raptor stringbuffer | 
| 
 | string | 
| 
 | length of string | 
| 
 | non-0 to copy the string | 
| Returns : | non-0 on failure | 
int raptor_stringbuffer_prepend_string (raptor_stringbuffer *stringbuffer, unsigned char *string, int do_copy);
Add a string to the start of the stringbuffer.
If do_copy is non-0, the passed-in string is copied into new memory otherwise the stringbuffer becomes the owner of the string pointer and will free it when the stringbuffer is destroyed.
| 
 | raptor stringbuffer | 
| 
 | string | 
| 
 | non-0 to copy the string | 
| Returns : | non-0 on failure | 
unsigned char * raptor_stringbuffer_as_string (raptor_stringbuffer *stringbuffer);
Return the stringbuffer as a C string.
Note: the return value is a to a shared string that the stringbuffer allocates and manages.
| 
 | raptor stringbuffer | 
| Returns : | NULL on failure or stringbuffer is empty, otherwise a pointer to a shared copy of the string. | 
size_t raptor_stringbuffer_length (raptor_stringbuffer *stringbuffer);
Return the stringbuffer length.
| 
 | raptor stringbuffer | 
| Returns : | size of stringbuffer | 
int raptor_stringbuffer_copy_to_string (raptor_stringbuffer *stringbuffer, unsigned char *string, size_t length);
Copy the stringbuffer into a string.
Copies the underlying string to a pre-allocated buffer. The output string is always '\0' terminated.
| 
 | raptor stringbuffer | 
| 
 | output string | 
| 
 | size of output string | 
| Returns : | non-0 on failure such as stringbuffer is empty, buffer is too small |