Crossfire Server, Branches 1.12
R18729
|
#include "global.h"
Go to the source code of this file.
Typedefs | |
typedef struct StringBuffer | StringBuffer |
Functions | |
void | stringbuffer_append_printf (StringBuffer *sb, const char *format,...) |
void | stringbuffer_append_string (StringBuffer *sb, const char *str) |
void | stringbuffer_append_stringbuffer (StringBuffer *sb, const StringBuffer *sb2) |
char * | stringbuffer_finish (StringBuffer *sb) |
sstring | stringbuffer_finish_shared (StringBuffer *sb) |
StringBuffer * | stringbuffer_new (void) |
Implements a general string buffer: it builds a string by concatenating. It allocates enough memory to hold the whole string; there is no upper limit for the total string length.
Usage is: StringBuffer *sb = stringbuffer_new(); stringbuffer_append_string(sb, "abc"); stringbuffer_append_string(sb, "def"); ... more calls to stringbuffer_append_xxx() char *str = stringbuffer_finish(sb) ... use str free(str);
No function ever fails. In case not enough memory is availabl, fatal() is called.
Definition in file stringbuffer.h.
typedef struct StringBuffer StringBuffer |
The string buffer state.
Definition at line 53 of file stringbuffer.h.
void stringbuffer_append_printf | ( | StringBuffer * | sb, |
const char * | format, | ||
... | |||
) |
Append a formatted string to a string buffer instance.
sb | The string buffer to modify. |
format | The format string to append. |
Definition at line 106 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, stringbuffer_ensure(), and vsnprintf.
Referenced by cost_string_from_value(), dump_object(), query_cost_string(), and real_money_value().
void stringbuffer_append_string | ( | StringBuffer * | sb, |
const char * | str | ||
) |
Append a string to a string buffer instance.
sb | The string buffer to modify. |
str | The string to append. |
Definition at line 97 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().
Referenced by cost_string_from_value(), dump_object(), and query_cost_string().
void stringbuffer_append_stringbuffer | ( | StringBuffer * | sb, |
const StringBuffer * | sb2 | ||
) |
Append the contents of a string buffer instance to another string buffer instance.
sb | The string buffer to modify. |
sb2 | The string buffer to append; it must be different from sb. |
Definition at line 133 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().
char* stringbuffer_finish | ( | StringBuffer * | sb | ) |
Deallocate the string buffer instance and return the string.
The passed string buffer must not be accessed afterwards.
sb | The string buffer to deallocate. |
free()
on it. Definition at line 78 of file stringbuffer.c.
References StringBuffer::buf, and StringBuffer::pos.
Referenced by add_one_item(), animate_object(), can_pay(), command_diff(), command_dump(), command_dumpbelow(), describe_shop(), dump_all_archetypes(), dump_all_objects(), examine(), free_object2(), gate_type_process(), get_payment(), insert_ob_in_map(), insert_ob_in_ob(), pick_up_object(), process_events(), remove_ob(), sell_item(), SockList_AddStringBuffer(), START_TEST(), and stringbuffer_finish_shared().
sstring stringbuffer_finish_shared | ( | StringBuffer * | sb | ) |
Deallocate the string buffer instance and return the string as a shared string.
The passed string buffer must not be accessed afterwards.
sb | The string buffer to deallocate. |
free_string()
on it. Definition at line 87 of file stringbuffer.c.
References add_string(), and stringbuffer_finish().
StringBuffer* stringbuffer_new | ( | void | ) |
Create a new string buffer.
Definition at line 64 of file stringbuffer.c.
References StringBuffer::buf, fatal(), OUT_OF_MEMORY, StringBuffer::pos, and StringBuffer::size.
Referenced by add_one_item(), animate_object(), command_diff(), command_dump(), command_dumpbelow(), cost_string_from_value(), dump_all_archetypes(), dump_all_objects(), free_object2(), gate_type_process(), insert_ob_in_map(), insert_ob_in_ob(), process_events(), query_cost_string(), remove_ob(), and START_TEST().