22 #include "../algorithms/sorts.h"
25 using namespace basis;
34 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
45 value_record(
const astring &name = astring::empty_string(),
46 const astring &description = astring::empty_string(),
47 const astring &location = astring::empty_string())
48 : _name(name), _descrip(description), _location(location) {}
53 class system_values_lookup_list :
public int_hash<value_record>
60 value_record *text_find(
const astring &name,
int &value) {
63 for (
int i = 0; i < cids.
elements(); i++) {
64 int current_id = cids[i];
65 value_record *curr = find(current_id);
70 if (curr->_name == name) {
82 system_values::system_values(
const astring §ion_tag)
83 : _tag(new
astring(section_tag)),
84 _list(new system_values_lookup_list),
85 _file(new
astring(DEFAULT_MANIFEST))
104 *_file = manifest_file;
105 return open_values();
114 bool system_values::open_values()
121 bool got_section = ini.get_section(*_tag, full_section);
122 if (!got_section)
return false;
123 for (
int i = 0; i < full_section.
symbols(); i++) {
126 list_parsing::parse_csv_line(full_section.
name(i), items);
131 value_record *entry =
new value_record(items[0], items[2], items[3]);
132 int value = items[1].convert(0);
133 _list->add(value, entry);
139 #define SV_EOL parser_bits::platform_eol_to_chars()
147 if (!_tag->
equal_to(
"DEFINE_OUTCOME")) {
156 astring to_return(
"values for ");
159 for (
int i = 0; i < cids.
elements(); i++) {
160 int current_id = cids[i];
161 value_record *curr = _list->find(current_id);
166 to_return +=
a_sprintf(
"%d: ", current_id);
167 to_return += curr->_name +
" \"" + curr->_descrip +
"\" from "
177 value_record *found = _list->find(value);
178 if (!found)
return false;
179 symbolic_name = found->_name;
180 description = found->_descrip;
181 file_location = found->_location;
188 value_record *found = _list->text_find(symbolic_name, value);
189 if (!found)
return false;
190 description = found->_descrip;
191 file_location = found->_location;
201 value = _list->ids()[index];
202 return lookup(value, symbolic_name, description, file_location);
a_sprintf is a specialization of astring that provides printf style support.
contents * access()
A non-constant access of the underlying C-array. BE REALLY CAREFUL.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
bool equal_to(const char *that) const
returns true if "that" is equal to this.
Supports a configurator-based interface on text initialization files.
@ APPLICATION_DIRECTORY
config files live with application.
bool use_other_manifest(const basis::astring &manifest_file)
supports using a different manifest file than the default.
bool get(int index, basis::astring &symbolic_name, int &value, basis::astring &description, basis::astring &file_location)
accesses the "index"th item in the list.
static const char * EVENT_VALUES()
values that define event objects used in the program.
bool lookup(int value, basis::astring &symbolic_name, basis::astring &description, basis::astring &file_location)
locates a "value" and finds its name, description and location.
static const char * FILTER_VALUES()
values that define filters used in logging.
virtual basis::astring text_form() const
shows all items in the table.
int elements() const
returns how many items are listed for the types of values specified.
static const char * DEFAULT_MANIFEST
the default manifest file.
static const char * OUTCOME_VALUES()
values that define the outcomes of operations.
A hash table for storing integers.
A simple object that wraps a templated set of ints.
int elements() const
Returns the number of elements in this set.
An array of strings with some additional helpful methods.
Provides a symbol_table that holds strings as the content.
const basis::astring & name(int index) const
returns the name held at the "index".
int symbols() const
returns the number of symbols listed in the table.
#define NULL_POINTER
The value representing a pointer to nothing.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
#define bounds_return(value, low, high, to_return)
Verifies that "value" is between "low" and "high", inclusive.
void shell_sort(type v[], int n, bool reverse=false)
shell sort algorithm.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
A dynamic container class that holds any kind of object via pointers.