Freeciv-3.3
|
#include "fc_prehdrs.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "fcintl.h"
#include "fcthread.h"
#include "log.h"
#include "mem.h"
#include "support.h"
#include "astring.h"
Go to the source code of this file.
Macros | |
#define | str _private_str_ |
#define | n _private_n_ |
#define | n_alloc _private_n_alloc_ |
Variables | |
static const struct astring | zero_astr = ASTRING_INIT |
static char * | astr_buffer = nullptr |
static size_t | astr_buffer_alloc = 0 |
static fc_mutex | astr_mutex |
#define n_alloc _private_n_alloc_ |
#define str _private_str_ |
Add the text to the string.
Definition at line 271 of file astring.c.
Referenced by action_prepare_ui_name(), astr_build_and_list(), astr_build_or_list(), check_for_game_over(), client_start_server(), combat_odds_to_astr(), concat_tile_activity_text(), create_races_dialog(), fileinfoname(), format_duration(), get_nearest_city_text(), get_ping_time_text(), get_science_target_text(), get_score_text(), get_timeout_label_text(), get_token_value(), get_unit_info_label_text1(), luascript_report(), mapimg_help(), move_points_text_full(), popup_info_text(), science_dialog_text(), text_happiness_cities(), text_happiness_nationality(), unit_activity_astr(), unit_description(), and update_source_label().
Add the text to the string in a new line.
Definition at line 283 of file astring.c.
Referenced by ai_level_help(), combat_odds_to_astr(), get_bulb_tooltip(), get_global_warming_tooltip(), get_government_tooltip(), get_info_label_text(), get_info_label_text_popup(), get_nuclear_winter_tooltip(), get_report_title(), get_science_goal_text(), get_spaceship_descr(), get_unit_info_label_text2(), luascript_report(), popup_info_text(), real_players_dialog_update(), science_dialog_text(), text_happiness_cities(), text_happiness_luxuries(), text_happiness_nationality(), text_happiness_units(), unit_activity_astr(), unit_description(), and unit_upkeep_astr().
Replace the spaces by line breaks when the line length is over the desired one.
Definition at line 302 of file astring.c.
Referenced by popup_info_text(), text_happiness_buildings(), and text_happiness_wonders().
Returns the astring buffer. Create it if necessary.
Definition at line 93 of file astring.c.
Referenced by astr_vadd_at().
const char * astr_build_and_list | ( | struct astring * | astr, |
const char *const * | items, | ||
size_t | number | ||
) |
Build a localized string with the given items. Items will be "and"-separated.
See also astr_build_or_list(), strvec_to_and_list().
Definition at line 351 of file astring.c.
Referenced by helptext_advance(), helptext_extra(), helptext_nation(), helptext_terrain(), helptext_unit(), popup_info_text(), role_units_translations(), setting_match_prefix(), strvec_to_and_list(), and update_source_label().
Build a localized string with the given items. Items will be "or"-separated.
See also astr_build_and_list(), strvec_to_or_list().
Definition at line 313 of file astring.c.
Referenced by cmdlevel_command(), explain_why_no_action_enabled(), helptext_unit(), illegal_action_msg(), req_text_insert(), role_units_translations(), and strvec_to_or_list().
Sets the content to the empty string.
Definition at line 201 of file astring.c.
Referenced by action_prepare_ui_name(), action_prob_explain(), astr_copy(), astr_reserve(), concat_tile_activity_text(), fileinfoname(), format_duration(), get_bulb_tooltip(), get_global_warming_tooltip(), get_government_tooltip(), get_info_label_text(), get_info_label_text_popup(), get_nearest_city_text(), get_nuclear_winter_tooltip(), get_ping_time_text(), get_report_title(), get_science_goal_text(), get_science_target_text(), get_score_text(), get_spaceship_descr(), get_timeout_label_text(), get_token_eol(), get_token_value(), get_unit_info_label_text1(), get_unit_info_label_text2(), move_points_text_full(), popup_info_text(), read_a_line(), science_dialog_text(), text_happiness_cities(), text_happiness_luxuries(), text_happiness_nationality(), text_happiness_units(), and unit_description().
Free the memory associated with astr, and return astr to same state as after astr_init().
Definition at line 148 of file astring.c.
Referenced by action_prepare_ui_name(), actions_free(), ai_level_help(), check_for_game_over(), client_start_server(), cmdlevel_command(), create_advances_list(), create_improvements_list(), create_present_supported_units_widget_list(), create_races_dialog(), do_tech_parasite_effects(), effect_list_sanity_cb(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), explain_why_no_action_enabled(), free_fileinfo_data(), get_bulb_tooltip(), get_science_goal_text(), get_unit_info_label_text2(), helptext_advance(), helptext_extra(), helptext_government(), helptext_nation(), helptext_terrain(), helptext_unit(), illegal_action_msg(), inf_close_partial(), insert_allows_single(), luascript_report(), mapimg_help(), notify_illegal_armistice_units(), units_select::paint(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_info_text(), popup_sabotage_dialog(), popup_sabotage_dialog(), real_players_dialog_update(), redraw_unit_info_label(), req_text_insert(), req_vec_change_translation(), req_vec_get_first_contradiction(), req_vec_get_first_missing_univ(), req_vec_get_first_redundant_req(), request_unit_goto(), sanity_check_ruleset_data(), save_action_auto_uflag_block(), science_dialog_text(), secfile_from_input_file(), setting_bitwise_to_str(), setting_match_prefix(), spy_steal_popup_shared(), spy_steal_shared(), text_happiness_buildings(), text_happiness_wonders(), unit_select_dialog_popup(), and update_source_label().
Initialize the struct.
Definition at line 139 of file astring.c.
Referenced by check_for_game_over(), do_tech_parasite_effects(), helptext_nation(), init_zeros(), mapimg_help(), req_to_fstring(), secfile_from_input_file(), and update_source_label().
Check that astr has enough size to hold n, and realloc to a bigger size if necessary. Here n must be big enough to include the trailing ascii-null if required. The requested n is stored in astr->n. The actual amount allocated may be larger than n, and is stored in astr->n_alloc.
Definition at line 179 of file astring.c.
Referenced by astr_build_and_list(), astr_build_or_list(), astr_clear(), astr_vadd_at(), get_token_value(), and read_a_line().
Set the text to the string.
Definition at line 251 of file astring.c.
Referenced by action_prepare_ui_name(), action_prob_explain(), action_prob_to_text(), astr_build_and_list(), astr_build_or_list(), astr_copy(), create_advances_list(), create_improvements_list(), create_races_dialog(), delegate_player_str(), fileinfoname(), get_act_sel_action_custom_text(), get_airlift_text(), get_bulb_tooltip(), get_science_goal_text(), get_tile_output_text(), get_token_entry_name(), get_token_eol(), get_token_section_name(), get_token_value(), get_token_white_char(), helptext_government(), helptext_nation(), mapimg_help(), notify_illegal_armistice_units(), players_vision_callback(), players_vision_callback(), players_war_callback(), players_war_callback(), popup_action_selection(), popup_sabotage_dialog(), popup_sabotage_dialog(), req_to_fstring(), role_units_translations(), science_dialog_text(), secfile_from_input_file(), spy_steal_popup_shared(), spy_steal_shared(), ssetv_human_readable(), text_happiness_buildings(), text_happiness_wonders(), and update_source_label().
Return the raw string to the caller, and return astr to same state as after astr_init(). Freeing the string's storage becomes the caller's responsibility.
Definition at line 163 of file astring.c.
Referenced by ai_level_help(), fc__attribute(), fc__attribute(), players_vision_callback(), players_vision_callback(), players_war_callback(), and players_war_callback().
Add the text to the string (varargs version).
Definition at line 263 of file astring.c.
Referenced by fc__attribute(), and fc__attribute().
|
inlinestatic |
Helper: add the text to the specified place in the string.
Definition at line 214 of file astring.c.
Referenced by astr_add(), astr_add_line(), astr_set(), and astr_vadd().
Free astr handling API resources
Definition at line 406 of file astring.c.
Referenced by libfreeciv_free().
Definition at line 81 of file astring.c.
Referenced by astr_buffer_free(), astr_buffer_get(), and astr_buffer_grow().
|
static |
Definition at line 82 of file astring.c.
Referenced by astr_buffer_get(), and astr_buffer_grow().
|
static |
Definition at line 84 of file astring.c.
Referenced by astr_vadd_at(), fc_astr_free(), and fc_astr_init().
|
static |
Definition at line 80 of file astring.c.
Referenced by astr_free(), astr_init(), and astr_to_str().