feisty meow concerns codebase  2.140
structures::string_table Class Reference

Provides a symbol_table that holds strings as the content. More...

#include <string_table.h>

Inheritance diagram for structures::string_table:
Collaboration diagram for structures::string_table:

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_tableoperator= (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_tableoperator= (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::astringname (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::astringoperator[] (int index)
 provides access to the symbol_table's contents at the "index". More...
 
const basis::astringoperator[] (int index) const
 provides a constant peek at the contents at the "index". More...
 
const basis::astringget (int index) const
 named equivalent for the bracket operator. More...
 
basis::astringuse (int index)
 named equivalent for the bracket operator. More...
 
basis::astringfind (const basis::astring &name) const
 returns the contents held for "name" or NULL_POINTER if it wasn't found. More...
 
basis::astringfind (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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ string_table() [1/2]

structures::string_table::string_table ( int  estimated_elements = 100)
inline

the "estimated_elements" specifies how many items to prepare to efficiently hold.

Definition at line 34 of file string_table.h.

◆ string_table() [2/2]

structures::string_table::string_table ( const string_table to_copy)

Definition at line 26 of file string_table.cpp.

◆ ~string_table()

structures::string_table::~string_table ( )
virtual

Definition at line 33 of file string_table.cpp.

Member Function Documentation

◆ add_spaces() [1/2]

bool structures::string_table::add_spaces ( ) const
inline

Definition at line 68 of file string_table.h.

Referenced by configuration::ini_parser::restate().

◆ add_spaces() [2/2]

void structures::string_table::add_spaces ( bool  add_them)
inline

Definition at line 69 of file string_table.h.

◆ DEFINE_CLASS_NAME()

structures::string_table::DEFINE_CLASS_NAME ( "string_table"  )

◆ equal_to()

virtual bool structures::string_table::equal_to ( const equalizable &  to_compare) const
inlinevirtual

Definition at line 46 of file string_table.h.

References operator==().

◆ is_comment()

bool structures::string_table::is_comment ( const basis::astring to_check)
static

Definition at line 35 of file string_table.cpp.

References basis::astring::begins(), and STRTAB_COMMENT_PREFIX.

Referenced by text_form().

◆ operator=()

string_table & structures::string_table::operator= ( const string_table to_copy)

Definition at line 38 of file string_table.cpp.

◆ operator==()

◆ pack()

void structures::string_table::pack ( basis::byte_array packed_form) const
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().

◆ packed_size()

int structures::string_table::packed_size ( ) const
virtual

◆ text_form() [1/2]

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

◆ text_form() [2/2]

virtual void structures::string_table::text_form ( basis::base_string state_fill) const
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().

◆ unpack()

bool structures::string_table::unpack ( basis::byte_array packed_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().


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