feisty meow concerns codebase
2.140
|
Provides a symbol_table that holds strings as the content. More...
#include <string_table.h>
Public Member Functions | |
string_table (int estimated_elements=100) | |
the "estimated_elements" specifies how many items to prepare to efficiently hold. More... | |
string_table (const string_table &to_copy) | |
virtual | ~string_table () |
DEFINE_CLASS_NAME ("string_table") | |
string_table & | operator= (const string_table &to_copy) |
bool | operator== (const string_table &to_compare) const |
virtual bool | equal_to (const equalizable &to_compare) const |
basis::astring | text_form () const |
prints the contents of the table into the returned string. More... | |
virtual void | text_form (basis::base_string &fill) const |
Provides a text view of all the important info owned by this object. More... | |
bool | add_spaces () const |
void | add_spaces (bool add_them) |
virtual int | packed_size () const |
Estimates the space needed for the packed structure. More... | |
virtual void | pack (basis::byte_array &packed_form) const |
Creates a packed form of the packable object in "packed_form". More... | |
virtual bool | unpack (basis::byte_array &packed_form) |
Restores the packable from the "packed_form". More... | |
Public Member Functions inherited from structures::symbol_table< basis::astring > | |
symbol_table (int estimated_elements=100) | |
constructs a symbol table with sufficient size for "estimated_elements". More... | |
symbol_table (const symbol_table< basis::astring > &to_copy) | |
~symbol_table () | |
int | symbols () const |
returns the number of symbols listed in the table. More... | |
int | estimated_elements () const |
returns the number of symbols the table is optimized for. More... | |
void | rehash (int estimated_elements) |
resizes underlying table to support "estimated_elements". More... | |
void | hash_appropriately (int estimated_elements) |
Resizes the number of table slots to have space for "estimated_elements". More... | |
symbol_table & | operator= (const symbol_table< basis::astring > &to_copy) |
basis::outcome | add (const basis::astring &name, const basis::astring &storage) |
Enters a symbol name into the table along with some contents. More... | |
const basis::astring & | name (int index) const |
returns the name held at the "index". More... | |
void | names (string_set &to_fill) const |
returns the names of all the symbols currently held. More... | |
basis::astring & | operator[] (int index) |
provides access to the symbol_table's contents at the "index". More... | |
const basis::astring & | operator[] (int index) const |
provides a constant peek at the contents at the "index". More... | |
const basis::astring & | get (int index) const |
named equivalent for the bracket operator. More... | |
basis::astring & | use (int index) |
named equivalent for the bracket operator. More... | |
basis::astring * | find (const basis::astring &name) const |
returns the contents held for "name" or NULL_POINTER if it wasn't found. More... | |
basis::astring * | find (const basis::astring &name, basis::string_comparator_function *comparator) const |
Specialized search via a comparison method "comparator". More... | |
int | dep_find (const basis::astring &name) const |
Searches for a symbol by its "name". More... | |
basis::outcome | retrieve (int index, basis::astring &symbol_name, basis::astring &contains) const |
Locates the symbol at position "index" and stores it to the parameters. More... | |
basis::outcome | whack (const basis::astring &name) |
removes a symbol from the table. More... | |
basis::outcome | zap_index (int index) |
zaps the entry at the specified index. slower than whack(). More... | |
void | reset () |
Public Member Functions inherited from basis::text_formable | |
virtual const char * | class_name () const =0 |
Returns the bare name of this class as a constant character pointer. More... | |
Public Member Functions inherited from basis::equalizable | |
virtual bool | equal_to (const equalizable &s2) const =0 |
virtual bool | operator== (const equalizable &s2) const |
the virtual method for object equality. More... | |
Static Public Member Functions | |
static bool | is_comment (const basis::astring &to_check) |
Provides a symbol_table that holds strings as the content.
This is essentially a table of named strings.
Definition at line 28 of file string_table.h.
|
inline |
the "estimated_elements" specifies how many items to prepare to efficiently hold.
Definition at line 34 of file string_table.h.
structures::string_table::string_table | ( | const string_table & | to_copy | ) |
Definition at line 26 of file string_table.cpp.
|
virtual |
Definition at line 33 of file string_table.cpp.
|
inline |
Definition at line 68 of file string_table.h.
Referenced by configuration::ini_parser::restate().
|
inline |
Definition at line 69 of file string_table.h.
structures::string_table::DEFINE_CLASS_NAME | ( | "string_table" | ) |
|
inlinevirtual |
Definition at line 46 of file string_table.h.
References operator==().
|
static |
Definition at line 35 of file string_table.cpp.
References basis::astring::begins(), and STRTAB_COMMENT_PREFIX.
Referenced by text_form().
string_table & structures::string_table::operator= | ( | const string_table & | to_copy | ) |
Definition at line 38 of file string_table.cpp.
bool structures::string_table::operator== | ( | const string_table & | to_compare | ) | const |
Definition at line 61 of file string_table.cpp.
References structures::symbol_table< basis::astring >::find(), structures::symbol_table< contents >::find(), structures::symbol_table< basis::astring >::name(), structures::symbol_table< basis::astring >::symbols(), and structures::symbol_table< contents >::symbols().
Referenced by equal_to().
|
virtual |
Creates a packed form of the packable object in "packed_form".
This must append to the data in "packed_form" rather than clearing prior contents.
Implements basis::packable.
Definition at line 84 of file string_table.cpp.
References structures::attach(), structures::symbol_table< basis::astring >::name(), structures::symbol_table< basis::astring >::operator[](), basis::astring::pack(), and structures::symbol_table< basis::astring >::symbols().
|
virtual |
Estimates the space needed for the packed structure.
Implements basis::packable.
Definition at line 74 of file string_table.cpp.
References basis::astring::length(), structures::symbol_table< basis::astring >::name(), structures::symbol_table< basis::astring >::operator[](), and structures::symbol_table< basis::astring >::symbols().
astring structures::string_table::text_form | ( | ) | const |
prints the contents of the table into the returned string.
if names in the table start with the comment prefix (see above), then they will not be printed as "X=Y" but instead as just "Y".
Definition at line 46 of file string_table.cpp.
References is_comment(), structures::symbol_table< basis::astring >::name(), and structures::symbol_table< basis::astring >::symbols().
Referenced by configuration::ini_parser::restate().
|
inlinevirtual |
Provides a text view of all the important info owned by this object.
It is understood that there could be a large amount of information and that this function might take a relatively long time to complete.
Implements basis::text_formable.
Definition at line 64 of file string_table.h.
References text_form().
Referenced by text_form().
|
virtual |
Restores the packable from the "packed_form".
This object becomes the unpacked form, and therefore must lose any of its prior contents that depend on the data in "packed_form". This is up to the derived unpack function to figure out. The "packed_form" is modified by extracting all of the pieces that are used for this object; the remainder stays in "packed_form". true is returned if the unpacking was successful.
Implements basis::packable.
Definition at line 93 of file string_table.cpp.
References structures::symbol_table< basis::astring >::add(), structures::detach(), structures::symbol_table< basis::astring >::name(), structures::symbol_table< basis::astring >::reset(), and basis::astring::unpack().