Crossfire Server, Trunk
R22047
|
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) |
void | stringbuffer_delete (StringBuffer *sb) |
char * | stringbuffer_finish (StringBuffer *sb) |
sstring | stringbuffer_finish_shared (StringBuffer *sb) |
size_t | stringbuffer_length (StringBuffer *sb) |
StringBuffer * | stringbuffer_new (void) |
void | stringbuffer_trim_whitespace (StringBuffer *sb) |
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 33 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 104 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, StringBuffer::size, stringbuffer_ensure(), and vsnprintf.
Referenced by artifact_describe(), artifact_msg(), command_bowmode(), cost_approx_str(), cost_string_from_value(), describe_attacktype(), describe_god(), describe_item(), describe_monster(), describe_resistance(), describe_spellpath_attenuation(), doWrite(), FAST_SAVE_DOUBLE(), FAST_SAVE_LONG(), knowledge_alchemy_can_use_item(), knowledge_alchemy_detail(), knowledge_alchemy_summary(), knowledge_god_add(), knowledge_god_summary(), knowledge_message_detail(), knowledge_message_summary(), knowledge_monster_detail(), knowledge_monster_summary(), make_formula_book(), mon_desc(), mon_info_msg(), monster_format_say(), object_dump(), perceive_self(), power_crystal_describe(), power_crystal_type_apply(), real_money_value(), ring_desc(), save_object_in_sb(), spellpath_msg(), START_TEST(), stringbuffer_append_ordinal(), MessageWriter::write(), FaceWriter::write(), AnimationWriter::write(), FacesetWriter::write(), write_map_parameters_to_string(), writeItem(), Utils::writeLinkedChar(), writeRecipe(), and Utils::writeStringArray().
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 95 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().
Referenced by add_capacity(), ADD_STRINGLINE_ENTRY(), artifact_describe(), artifact_msg(), command_bowmode(), cost_approx_str(), cost_string_from_value(), describe_attacktype(), describe_god(), describe_item(), describe_monster(), describe_resistance(), describe_spellpath_attenuation(), do_spellpath_msg(), doWrite(), examine(), get_ob_diff(), get_string_move_type(), knowledge_alchemy_can_use_item(), knowledge_item_can_be_used_alchemy(), load_quests_from_file(), QuestManager::loadQuestFile(), make_formula_book(), mon_info_msg(), msgfile_msg(), object_dump(), object_set_msg(), perceive_self(), power_crystal_describe(), power_crystal_type_apply(), ring_desc(), save_object_in_sb(), spellbook_type_apply(), spellbook_type_describe(), spellpath_msg(), START_TEST(), stringbuffer_append_ordinal(), stringbuffer_append_spelldesc(), tailor_readable_ob(), MessageWriter::write(), TreasureWriter::write(), FaceWriter::write(), AnimationWriter::write(), writeItem(), and writeRecipe().
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 131 of file stringbuffer.c.
References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().
Referenced by artifact_describe(), artifact_msg(), describe_god(), and mon_info_msg().
void stringbuffer_delete | ( | StringBuffer * | sb | ) |
Totally delete a string buffer.
sb | String to delete, pointer becomes invalid after the call. |
Definition at line 71 of file stringbuffer.c.
References StringBuffer::buf.
Referenced by artifact_msg(), assets_pack(), cost_approx_str(), god_info_msg(), mon_info_msg(), and spellpath_msg().
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 76 of file stringbuffer.c.
References StringBuffer::buf, and StringBuffer::pos.
Referenced by add_one_item(), animate_object(), artifact_describe(), CREArtifactPanel::artifactChanged(), assets_pack(), cfapi_object_describe(), command_bowmode(), command_diff(), command_dump(), common_ob_describe(), cost_approx_str(), cost_string_from_value(), describe_god(), do_dump(), dump_abilities(), dump_all_archetypes(), dump_gods(), examine(), gate_type_process(), generate_random_map(), knowledge_do_display(), knowledge_item_can_be_used_alchemy(), knowledge_process_incremental(), knowledge_show(), knowledge_show_monster_detail(), load_quests_from_file(), QuestManager::loadQuestFile(), make_formula_book(), monster_npc_say(), object_dump_all(), object_free(), object_insert_in_map(), object_insert_in_ob(), object_remove(), perceive_self(), place_exits(), place_special_exit(), power_crystal_describe(), power_crystal_type_apply(), process_events(), query_base_name(), query_short_name(), Archetypes::recursive_update(), save_object(), CRERandomMapPanel::setItem(), CREArchetypePanel::setItem(), CREArtifactPanel::setItem(), SockList_AddStringBuffer(), spellbook_type_apply(), spellbook_type_describe(), START_TEST(), CREMapInformationManager::storeCache(), stringbuffer_finish_shared(), tailor_readable_ob(), and EditMonstersDialog::write().
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 85 of file stringbuffer.c.
References add_string(), and stringbuffer_finish().
Referenced by knowledge_god_add(), make_formula_book(), mon_info_msg(), monster_do_talk_npc(), and object_set_msg().
size_t stringbuffer_length | ( | StringBuffer * | sb | ) |
Return the current length of the buffer.
sb | The string buffer to check. |
Definition at line 162 of file stringbuffer.c.
References StringBuffer::pos.
Referenced by artifact_describe(), artifact_msg(), assets_pack(), describe_god(), do_spellpath_msg(), god_info_msg(), mon_info_msg(), ring_desc(), and EditMonstersDialog::write().
StringBuffer* stringbuffer_new | ( | void | ) |
Create a new string buffer.
Definition at line 57 of file stringbuffer.c.
References StringBuffer::buf, fatal(), OUT_OF_MEMORY, StringBuffer::pos, and StringBuffer::size.
Referenced by add_one_item(), animate_object(), artifact_describe(), artifact_msg(), assets_pack(), command_bowmode(), command_diff(), command_dump(), cost_approx_str(), cost_string_from_value(), describe_attacktype(), describe_god(), describe_item(), describe_monster(), describe_resistance(), describe_spellpath_attenuation(), do_dump(), dump_all_archetypes(), examine(), gate_type_process(), god_info_msg(), knowledge_alchemy_can_use_item(), knowledge_do_display(), knowledge_god_add(), knowledge_process_incremental(), knowledge_show(), knowledge_show_monster_detail(), load_quests_from_file(), QuestManager::loadQuestFile(), make_formula_book(), mon_desc(), mon_info_msg(), monster_format_say(), msgfile_msg(), object_dump_all(), object_free(), object_insert_in_map(), object_insert_in_ob(), object_remove(), object_set_msg(), perceive_self(), power_crystal_describe(), power_crystal_type_apply(), process_events(), Archetypes::recursive_update(), ring_desc(), save_object(), CREArtifactPanel::setItem(), CREArchetypePanel::setItem(), spellbook_type_apply(), spellbook_type_describe(), spellpath_msg(), START_TEST(), EditMonstersDialog::write(), and write_map_parameters_to_string().
void stringbuffer_trim_whitespace | ( | StringBuffer * | sb | ) |
Trim trailing whitespace from a stringbuffer.
sb | The stringbuffer. |
Definition at line 166 of file stringbuffer.c.
References StringBuffer::buf, and StringBuffer::pos.
Referenced by examine(), and spellbook_type_apply().