31 using namespace basis;
39 #define LOG(to_print) program_wide_logger::get().log(to_print, ALWAYS_PRINT)
48 virtual int execute();
58 %s: This program needs five parameters to process an ini file.\n\
59 There are two major operations, read and write. The type of operation\n\
60 should be the first parameter. The other parameters are similar for both\n\
61 operations, except for the last parameter. These are as follows:\n\
63 \tread inifile section entry defaultvalue\n\
64 This reads the \"inifile\" specified and looks for the \"section\" and\n\
65 \"entry\" name in the file. It will either return (via standard output)\n\
66 the value found there or it will return the \"defaultvalue\". No error\n\
67 will be raised if the entry is missing, but the default signals that no\n\
69 Additionally, if the entry name is the special value \"whole_section\",\n\
70 then the entire section will be read and returned as a CSV list. If the\n\
71 section is empty, then the default string is returned instead.\n\
73 \twrite inifile section entry newvalue\n\
74 This writes a new item with contents \"newvalue\" into the \"inifile\"\n\
75 in the \"section\" at the \"entry\" specified. This should always succeed\n\
76 unless the ini file is not writable (in which case an error should be\n\
77 returned). Nothing is send to standard output for a write operation.\n\
82 int ini_editor::execute()
90 if ( (operation[0] ==
'w') || (operation[0] ==
'W') ) read_op =
false;
99 if (entry.
equal_to(
"whole_section")) {
102 bool worked = ini.get_section(section, found);
103 if (!worked) program_wide_logger::get().log(value, ALWAYS_PRINT);
107 list_parsing::create_csv_line(found, temp);
108 program_wide_logger::get().log(temp, ALWAYS_PRINT);
111 bool worked = ini.get(section, entry, found);
113 if (!worked) program_wide_logger::get().log(value, ALWAYS_PRINT);
114 else program_wide_logger::get().log(found, ALWAYS_PRINT);
118 bool worked = ini.put(section, entry, value);
119 if (!worked) exit(28);
int print_instructions(bool good, const astring &program_name)
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
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.
Provides operations commonly needed on file names.
Provides a symbol_table that holds strings as the content.
#define SETUP_CONSOLE_LOGGER
< a macro that retasks the program-wide logger as a console_logger.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.