first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / configuration / table_configurator.h
1 #ifndef TABLE_CONFIGURATOR_CLASS
2 #define TABLE_CONFIGURATOR_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : table_configurator                                                *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 2001-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include "configurator.h"
19
20 #include <basis/contracts.h>
21
22 namespace configuration {
23
24 // forward.
25 class table_o_string_tables;
26
27 //! Supports the configurator interface using a collection of string tables.
28
29 class table_configurator : public virtual configurator
30 {
31 public:
32   table_configurator(treatment_of_defaults behavior = AUTO_STORE);
33     //!< Constructor just needs to know what to do for missing items.
34     /*!< Creates a table_configurator that loads and stores entries into
35     the internal collection of tables.  It will use the "behavior" regarding
36     missing entries when load() is invoked. */
37
38   table_configurator(const table_configurator &to_copy);
39
40   virtual ~table_configurator();
41
42   table_configurator &operator =(const table_configurator &to_copy);
43
44   DEFINE_CLASS_NAME("table_configurator");
45
46   virtual void sections(structures::string_array &list);
47     //!< retrieves the section names into "list".
48
49   void reset();  // clears out all contents.
50
51   virtual bool get(const basis::astring &section, const basis::astring &entry,
52           basis::astring &found);
53     //!< implements the configurator retrieval function.
54
55   virtual bool put(const basis::astring &section, const basis::astring &entry,
56           const basis::astring &to_store);
57     //!< implements the configurator storage function.
58
59   virtual bool section_exists(const basis::astring &section);
60     //!< true if the "section" is presently in the table config.
61
62   virtual bool delete_section(const basis::astring &section);
63     //!< removes the entire "section" specified.
64
65   virtual bool delete_entry(const basis::astring &section, const basis::astring &entry);
66     //!< removes the entry specified by the "section" and "entry" name.
67
68   virtual bool get_section(const basis::astring &section, structures::string_table &info);
69     //!< reads the entire table held under "section" into a table called "info".
70
71   virtual bool put_section(const basis::astring &section, const structures::string_table &info);
72     //!< writes a table called "info" into the "section" held here.
73
74 private:
75   table_o_string_tables *_real_table;
76     //!< the data structure we're actually operating on.
77 };
78
79 } //namespace.
80
81 #endif
82