Crossfire Server, Branch 1.12  R12190
Typedefs | Functions
stringbuffer.h File Reference

Implements a general string buffer: it builds a string by concatenating. More...

#include "global.h"
Include dependency graph for stringbuffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct StringBuffer StringBuffer
 The string buffer state.

Functions

void stringbuffer_append_printf (StringBuffer *sb, const char *format,...)
 Append a formatted string to a string buffer instance.
void stringbuffer_append_string (StringBuffer *sb, const char *str)
 Append a string to a string buffer instance.
void stringbuffer_append_stringbuffer (StringBuffer *sb, const StringBuffer *sb2)
 Append the contents of a string buffer instance to another string buffer instance.
char * stringbuffer_finish (StringBuffer *sb)
 Deallocate the string buffer instance and return the string.
sstring stringbuffer_finish_shared (StringBuffer *sb)
 Deallocate the string buffer instance and return the string as a shared string.
StringBufferstringbuffer_new (void)
 Create a new string buffer.

Detailed Description

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 Documentation

typedef struct StringBuffer StringBuffer

The string buffer state.

Definition at line 53 of file stringbuffer.h.


Function Documentation

void stringbuffer_append_printf ( StringBuffer sb,
const char *  format,
  ... 
)

Append a formatted string to a string buffer instance.

Parameters:
sbThe string buffer to modify.
formatThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void stringbuffer_append_string ( StringBuffer sb,
const char *  str 
)

Append a string to a string buffer instance.

Parameters:
sbThe string buffer to modify.
strThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

Append the contents of a string buffer instance to another string buffer instance.

Parameters:
sbThe string buffer to modify.
sb2The 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().

Here is the call graph for this function:

Deallocate the string buffer instance and return the string.

The passed string buffer must not be accessed afterwards.

Parameters:
sbThe string buffer to deallocate.
Returns:
The result string; to free it, call 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().

Here is the caller graph for this function:

Deallocate the string buffer instance and return the string as a shared string.

The passed string buffer must not be accessed afterwards.

Parameters:
sbThe string buffer to deallocate.
Returns:
The result shared string; to free it, call free_string() on it.

Definition at line 87 of file stringbuffer.c.

References add_string(), and stringbuffer_finish().

Here is the call graph for this function:

Create a new string buffer.

Returns:
The newly allocated 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().

Here is the call graph for this function:

Here is the caller graph for this function: