#include <string_table.h>
Inheritance diagram for string_table:


Public Member Functions | |
| string_table (int max_bits=7) | |
| string_table (const string_table &to_copy) | |
| virtual | ~string_table () |
| string_table & | operator= (const string_table &to_copy) |
| bool | operator== (const string_table &to_compare) const |
| bool | operator!= (const string_table &to_compare) const |
| istring | text_form () const |
| prints the contents of the table into the returned string. | |
| bool | add_spaces () const |
| void | add_spaces (bool add_them) |
| virtual int | packed_size () const |
| Estimates the space needed for the packed structure. | |
| virtual void | pack (byte_array &packed_form) const |
| Creates a packed form of the packable object in "packed_form". | |
| virtual bool | unpack (byte_array &packed_form) |
| Restores the packable from the "packed_form". | |
Static Public Member Functions | |
| static bool | is_comment (const istring &to_check) |
This is essentially a table of named strings.
Definition at line 26 of file string_table.h.
| string_table::string_table | ( | int | max_bits = 7 |
) | [inline] |
the "max_bits" specifies how wide the key space is for the strings (it works out to be 2^max_bits). the default leads to a table that will easily accomodate 128 random strings efficiently.
Definition at line 30 of file string_table.h.
| string_table::string_table | ( | const string_table & | to_copy | ) |
Definition at line 25 of file string_table.cpp.
| string_table::~string_table | ( | ) | [virtual] |
Definition at line 32 of file string_table.cpp.
| string_table & string_table::operator= | ( | const string_table & | to_copy | ) |
| bool string_table::operator== | ( | const string_table & | to_compare | ) | const |
Definition at line 61 of file string_table.cpp.
References symbol_table< contents >::find(), symbol_table< istring >::find(), symbol_table< istring >::name(), symbol_table< istring >::symbols(), and symbol_table< contents >::symbols().
| bool string_table::operator!= | ( | const string_table & | to_compare | ) | const [inline] |
Definition at line 41 of file string_table.h.
| bool string_table::is_comment | ( | const istring & | to_check | ) | [static] |
Definition at line 34 of file string_table.cpp.
References istring::begins(), and STRTAB_COMMENT_PREFIX.
Referenced by tokenizer::text_form(), and text_form().
| istring 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 45 of file string_table.cpp.
References is_comment(), symbol_table< istring >::name(), log_base::platform_ending(), and symbol_table< istring >::symbols().
Referenced by ini_parser::restate(), and test_string_table().
| bool string_table::add_spaces | ( | ) | const [inline] |
| void string_table::add_spaces | ( | bool | add_them | ) | [inline] |
Definition at line 59 of file string_table.h.
| int string_table::packed_size | ( | ) | const [virtual] |
Estimates the space needed for the packed structure.
Reimplemented from packable.
Definition at line 74 of file string_table.cpp.
References istring::length(), symbol_table< istring >::name(), symbol_table< istring >::operator[](), and symbol_table< istring >::symbols().
| void string_table::pack | ( | 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 packable.
Definition at line 84 of file string_table.cpp.
References basis::attach(), symbol_table< istring >::name(), symbol_table< istring >::operator[](), istring::pack(), and symbol_table< istring >::symbols().
Referenced by test_string_table().
| bool string_table::unpack | ( | 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 packable.
Definition at line 93 of file string_table.cpp.
References symbol_table< istring >::add(), basis::detach(), common::IS_NEW, symbol_table< istring >::name(), symbol_table< istring >::reset(), and istring::unpack().
Referenced by test_string_table().
1.5.1