foobar2000 SDK  2015-08-03
Public Member Functions | Protected Member Functions
cfg_string

#include <cfg_var.h>

+ Inheritance diagram for cfg_string:

Public Member Functions

 cfg_string (const GUID &p_guid, const char *p_defaultval)
 
 operator const char * () const
 
const cfg_stringoperator= (const cfg_string &p_val)
 
const cfg_stringoperator= (const char *p_val)
 
- Public Member Functions inherited from cfg_var
GUID get_guid () const
 
- Public Member Functions inherited from cfg_var_reader
 cfg_var_reader (const GUID &guid)
 
 ~cfg_var_reader ()
 
- Public Member Functions inherited from cfg_var_writer
 cfg_var_writer (const GUID &guid)
 
 ~cfg_var_writer ()
 
- Public Member Functions inherited from pfc::string8_t< t_alloc >
 string8_t ()
 
 string8_t (const char *p_string)
 
 string8_t (const char *p_string, t_size p_length)
 
 string8_t (const t_self &p_string)
 
 string8_t (const string_base &p_string)
 
 string8_t (string_part_ref ref)
 
void add_string (const char *p_string, t_size p_length=~0)
 
void add_string (string_part_ref ref)
 
void add_string_ (const char *str)
 
void add_string_nc (const char *ptr, t_size len)
 
void fix_filename_chars (char def= '_', char leave=0)
 
void force_reset ()
 
t_size get_length () const throw ()
 
const char * get_ptr () const throw ()
 
void insert_chars (t_size first, const char *src, t_size count)
 
void insert_chars (t_size first, const char *src)
 
char * lock_buffer (t_size n)
 
 operator const char * () const throw ()
 
const t_selfoperator+= (const char *src)
 
const t_selfoperator+= (const string_base &src)
 
const t_selfoperator+= (const t_self &src)
 
const t_selfoperator+= (string_part_ref src)
 
const t_selfoperator= (const char *src)
 
const t_selfoperator= (const string_base &src)
 
const t_selfoperator= (const t_self &src)
 
const t_selfoperator= (string_part_ref src)
 
void prealloc (t_size p_size)
 
void remove_chars (t_size first, t_size count)
 
t_size replace_byte (char c1, char c2, t_size start=0)
 
t_size replace_char (unsigned c1, unsigned c2, t_size start=0)
 
t_size replace_nontext_chars (char p_replace= '_')
 
void set_char (unsigned offset, char c)
 
void set_string (const char *p_string, t_size p_length=~0)
 
void set_string (string_part_ref ref)
 
void set_string_ (const char *str)
 
void set_string_nc (const char *ptr, t_size len)
 
void truncate (t_size len)
 
void unlock_buffer ()
 
- Public Member Functions inherited from pfc::string_base
string_base_formatter () const
 
void add_filename (const char *fn)
 
const char * c_str () const
 
void convert_to_lower_ascii (const char *src, char replace= '?')
 
void delimit (const char *c)
 
void end_with (char c)
 
void end_with_slash ()
 
bool ends_with (char c) const
 
t_size find_first (char p_char, t_size p_start=0) const
 
t_size find_first (const char *p_string, t_size p_start=0) const
 
t_size find_last (char p_char, t_size p_start=~0) const
 
t_size find_last (const char *p_string, t_size p_start=~0) const
 
void fix_dir_separator (char c= '\\')
 
bool fix_eol (const char *append=" (...)", t_size start=0)
 
bool has_prefix (const char *prefix) const
 
bool has_prefix_i (const char *prefix) const
 
bool has_suffix (const char *suffix) const
 
bool has_suffix_i (const char *suffix) const
 
bool is_empty () const
 
bool is_valid_utf8 () const
 
char last_char () const
 
t_size length () const
 
bool limit_length (t_size length_in_chars, const char *append=" (...)")
 
 operator const char * () const
 
bool operator!= (const string_base &p_other) const
 
const string_baseoperator+= (const char *src)
 
const string_baseoperator+= (const string_base &src)
 
bool operator< (const string_base &p_other) const
 
bool operator<= (const string_base &p_other) const
 
const string_baseoperator= (const char *src)
 
const string_baseoperator= (const string_base &src)
 
bool operator== (const string_base &p_other) const
 
bool operator> (const string_base &p_other) const
 
bool operator>= (const string_base &p_other) const
 
t_size replace_string (const char *replace, const char *replaceWith, t_size start=0)
 
void reset ()
 
t_size scan_filename () const
 
void set_string_ (const char *str)
 
void skip_trailing_char (unsigned c= ' ')
 
const char * toString () const
 
bool truncate_eol (t_size start=0)
 
void truncate_filename ()
 
void truncate_last_char ()
 
void truncate_number_suffix ()
 
void truncate_to_parent_path ()
 
- Public Member Functions inherited from pfc::string_receiver
void add_byte (char c)
 
void add_char (t_uint32 c)
 
void add_chars (t_uint32 p_char, t_size p_count)
 
void add_string_ (const char *str)
 

Protected Member Functions

void get_data_raw (stream_writer *p_stream, abort_callback &p_abort)
 
void set_data_raw (stream_reader *p_stream, t_size p_sizehint, abort_callback &p_abort)
 
- Protected Member Functions inherited from cfg_var
 cfg_var (const GUID &p_guid)
 
- Protected Member Functions inherited from pfc::string8_t< t_alloc >
const char * _get_ptr () const throw ()
 
void makespace (t_size s)
 
- Protected Member Functions inherited from pfc::string_base
 string_base ()
 
 ~string_base ()
 
- Protected Member Functions inherited from pfc::string_receiver
 string_receiver ()
 
 ~string_receiver ()
 

Additional Inherited Members

- Static Public Member Functions inherited from cfg_var_reader
static void config_read_file (stream_reader *p_stream, abort_callback &p_abort)
 
- Static Public Member Functions inherited from cfg_var_writer
static void config_write_file (stream_writer *p_stream, abort_callback &p_abort)
 
- Static Public Member Functions inherited from pfc::string8_t< t_alloc >
static void g_swap (t_self &p_item1, t_self &p_item2)
 
- Data Fields inherited from cfg_var_reader
const GUID m_guid
 
- Data Fields inherited from cfg_var_writer
const GUID m_guid
 
- Protected Attributes inherited from pfc::string8_t< t_alloc >
pfc::array_t< char, t_alloc > m_data
 
t_size used
 

Detailed Description

String config variable. Stored in the stream with int32 header containing size in bytes, followed by non-null-terminated UTF-8 data.
Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such).

Definition at line 97 of file cfg_var.h.

Constructor & Destructor Documentation

cfg_string::cfg_string ( const GUID p_guid,
const char *  p_defaultval 
)
inlineexplicit
Parameters
p_guidGUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
p_defaultvalDefault/initial value of the variable.

Definition at line 105 of file cfg_var.h.

105 : cfg_var(p_guid), pfc::string8(p_defaultval) {}
cfg_var(const GUID &p_guid)
Definition: cfg_var.h:57
string8_t< pfc::alloc_standard > string8
Definition: string_base.h:432

Member Function Documentation

void cfg_string::get_data_raw ( stream_writer p_stream,
abort_callback p_abort 
)
protectedvirtual

Retrieves state of the variable. Called only from main thread, when writing configuration file.

Parameters
p_streamStream receiving state of the variable.

Implements cfg_var_writer.

Definition at line 52 of file cfg_var.cpp.

52  {
53  p_stream->write_object(get_ptr(),length(),p_abort);
54 }
const char * get_ptr() const
Definition: string_base.h:382
t_size length() const
For compatibility with old conventions.
Definition: string_base.h:209
cfg_string::operator const char * ( ) const
inline

Definition at line 110 of file cfg_var.h.

110 {return get_ptr();}
const char * get_ptr() const
Definition: string_base.h:382
const cfg_string& cfg_string::operator= ( const cfg_string p_val)
inline

Definition at line 107 of file cfg_var.h.

107 {set_string(p_val);return *this;}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
const cfg_string& cfg_string::operator= ( const char *  p_val)
inline

Definition at line 108 of file cfg_var.h.

108 {set_string(p_val);return *this;}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
void cfg_string::set_data_raw ( stream_reader p_stream,
t_size  p_sizehint,
abort_callback p_abort 
)
protectedvirtual

Sets state of the variable. Called only from main thread, when reading configuration file.

Parameters
p_streamStream containing new state of the variable.
p_sizehintNumber of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF).

Implements cfg_var_reader.

Definition at line 56 of file cfg_var.cpp.

56  {
58  p_stream->read_string_raw(temp,p_abort);
59  set_string(temp);
60 }
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
Definition: string_base.h:436

The documentation for this class was generated from the following files: