Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
astring.h File Reference
#include <string.h>
#include "support.h"

Go to the source code of this file.

Data Structures

struct  astring
 

Macros

#define str   _private_str_
 
#define n   _private_n_
 
#define n_alloc   _private_n_alloc_
 
#define ASTRING_INIT   { NULL, 0, 0 }
 

Functions

void astr_init (struct astring *astr) fc__attribute((nonnull(1)))
 
void astr_free (struct astring *astr) fc__attribute((nonnull(1)))
 
static const charastr_str (const struct astring *astr) fc__attribute((nonnull(1)))
 
static size_t astr_len (const struct astring *astr) fc__attribute((nonnull(1)))
 
static size_t astr_size (const struct astring *astr) fc__attribute((nonnull(1)))
 
static size_t astr_capacity (const struct astring *astr) fc__attribute((nonnull(1)))
 
static bool astr_empty (const struct astring *astr) fc__attribute((nonnull(1)))
 
charastr_to_str (struct astring *astr) fc__attribute((nonnull(1)))
 
void astr_reserve (struct astring *astr, size_t size) fc__attribute((nonnull(1)))
 
void astr_clear (struct astring *astr) fc__attribute((nonnull(1)))
 
void astr_set (struct astring *astr, const char *format,...) fc__attribute((__format__(__printf__
 
void fc__attribute ((nonnull(1, 2)))
 
void astr_vadd (struct astring *astr, const char *format, va_list ap) fc__attribute((nonnull(1
 
void void astr_add (struct astring *astr, const char *format,...) fc__attribute((__format__(__printf__
 
void astr_add_line (struct astring *astr, const char *format,...) fc__attribute((__format__(__printf__
 
void astr_break_lines (struct astring *astr, size_t desired_len) fc__attribute((nonnull(1)))
 
const charastr_build_or_list (struct astring *astr, const char *const *items, size_t number)
 
const charastr_build_and_list (struct astring *astr, const char *const *items, size_t number)
 
void astr_copy (struct astring *dest, const struct astring *src) fc__attribute((nonnull(1
 
void void fc_astr_init (void)
 
void fc_astr_free (void)
 

Macro Definition Documentation

◆ ASTRING_INIT

#define ASTRING_INIT   { NULL, 0, 0 }

Definition at line 44 of file astring.h.

◆ n

Definition at line 33 of file astring.h.

◆ n_alloc

#define n_alloc   _private_n_alloc_

Definition at line 34 of file astring.h.

◆ str

#define str   _private_str_

Definition at line 32 of file astring.h.

Function Documentation

◆ astr_add()

void void astr_add ( struct astring astr,
const char format,
  ... 
)

◆ astr_add_line()

void astr_add_line ( struct astring astr,
const char format,
  ... 
)

◆ astr_break_lines()

void astr_break_lines ( struct astring astr,
size_t  desired_len 
)

Replace the spaces by line breaks when the line length is over the desired one.

Definition at line 318 of file astring.c.

Referenced by popup_info_text(), text_happiness_buildings(), and text_happiness_wonders().

◆ astr_build_and_list()

const char * astr_build_and_list ( struct astring astr,
const char *const items,
size_t  number 
)

◆ astr_build_or_list()

const char * astr_build_or_list ( struct astring astr,
const char *const items,
size_t  number 
)

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 329 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().

◆ astr_capacity()

static size_t astr_capacity ( const struct astring astr)
inlinestatic

Returns the real size requested for the string.

Definition at line 117 of file astring.h.

Referenced by get_token_value(), and read_a_line().

◆ astr_clear()

void astr_clear ( struct astring astr)

◆ astr_copy()

void astr_copy ( struct astring dest,
const struct astring src 
)

◆ astr_empty()

static bool astr_empty ( const struct astring astr)
inlinestatic

Returns whether the string is empty or not.

Definition at line 125 of file astring.h.

Referenced by ai_level_help(), astr_copy(), have_line(), and inf_log_str().

◆ astr_free()

void astr_free ( struct astring astr)

Free the memory associated with astr, and return astr to same state as after astr_init().

Definition at line 153 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().

◆ astr_init()

void astr_init ( struct astring astr)

◆ astr_len()

static size_t astr_len ( const struct astring astr)
inlinestatic

Returns the length of the string.

Definition at line 101 of file astring.h.

Referenced by astr_add(), astr_add_line(), astr_vadd(), at_eol(), check_include(), get_token_value(), mapimg_help(), and read_a_line().

◆ astr_reserve()

void astr_reserve ( struct astring astr,
size_t  n 
)

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 183 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().

◆ astr_set()

void astr_set ( struct astring astr,
const char format,
  ... 
)

◆ astr_size()

static size_t astr_size ( const struct astring astr)
inlinestatic

Returns the current size requested for the string.

Definition at line 109 of file astring.h.

◆ astr_str()

static const char * astr_str ( const struct astring astr)
inlinestatic

Returns the string.

Definition at line 93 of file astring.h.

Referenced by action_prepare_ui_name(), action_prob_explain(), action_prob_to_text(), ai_level_help(), check_for_game_over(), check_include(), client_start_server(), concat_tile_activity_text(), create_advances_list(), create_improvements_list(), create_present_supported_units_widget_list(), create_races_dialog(), delegate_player_str(), do_tech_parasite_effects(), fileinfoname(), format_duration(), get_act_sel_action_custom_text(), get_airlift_text(), 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_tile_output_text(), get_timeout_label_text(), get_token_entry_name(), get_token_eol(), get_token_section_name(), get_token_value(), get_token_white_char(), get_unit_info_label_text1(), get_unit_info_label_text2(), helptext_government(), helptext_nation(), helptext_unit(), illegal_action_msg(), inf_log_str(), inf_token(), luascript_report(), mapimg_help(), move_points_text_full(), notify_illegal_armistice_units(), units_select::paint(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_info_text(), popup_sabotage_dialog(), popup_sabotage_dialog(), read_a_line(), real_players_dialog_update(), redraw_unit_info_label(), req_text_insert(), req_to_fstring(), request_unit_goto(), science_dialog_text(), secfile_from_input_file(), setting_bitwise_to_str(), spy_steal_popup_shared(), spy_steal_shared(), ssetv_human_readable(), text_happiness_buildings(), text_happiness_cities(), text_happiness_luxuries(), text_happiness_nationality(), text_happiness_units(), text_happiness_wonders(), unit_description(), unit_select_dialog_popup(), and update_source_label().

◆ astr_to_str()

char * astr_to_str ( struct astring astr)

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 167 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().

◆ astr_vadd()

void astr_vadd ( struct astring astr,
const char format,
va_list  ap 
)

◆ fc__attribute()

void fc__attribute ( (nonnull(1, 2))  )

◆ fc_astr_free()

void fc_astr_free ( void  )

Free astr handling API resources

Definition at line 422 of file astring.c.

Referenced by libfreeciv_free().

◆ fc_astr_init()

void void fc_astr_init ( void  )

Initialize astr API

Definition at line 414 of file astring.c.

Referenced by libfreeciv_init().