This base class models an application. More...
#include <application.h>


Public Member Functions | |
| application (const string &appid) | |
| void | init (int argc, char **argv) |
| virtual int | main (void) |
Public Attributes | |
| value | argv |
| value | env |
| value | rsrc |
| value | opt |
| string | creator |
This base class models an application.
Provides housekeeping tasks for an application, including:
On startup, the file rsrc:grace.runoptions.xml is loaded into the opt value and rsrc:resources.xml is loaded into the rsrc value object.
| application::application | ( | const string & | appid | ) |
Default constructor.
Loads resources, initializes.
| appid | the application-id [tld.domain.foo.app] |
References creator, string::cutat(), env, file::openread(), file::openwrite(), and string::strstr().

| void application::init | ( | int | argc, | |
| char ** | argv | |||
| ) |
Second stage initialization.
Parses commandline arguments according to the rules found in the "rsrc:grace.runoptions.xml" file. Arguments and flags defined in this rule file are filed with their proper (long format) key in the argv[] value object inside the application object. Unaccounted or extra arguments are stored as unkeyed items inside argv["*"][].
| argc | argument count | |
| argv | argument array |
The layout of the a runoptions file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<grace.runoptions>
<grace.option id="-h">
<grace.long>--help</grace.long>
</grace.option>
<grace.option id="-d">
<grace.long>--debug</grace.long>
</grace.option>
<grace.option id="--help">
<grace.argc>0</grace.argc>
<grace.help>Show help information</grace.help>
</grace.option>
<grace.option id="--debug">
<grace.argc>1</grace.argc>
<grace.default>0</grace.default>
</grace.option>
</grace.runoptions>
Options with a 'short' commandline flag as their key, as a rule, only contain a reference to their long counterpart.
| int application::main | ( | void | ) | [virtual] |
The main loop.
Represents the application's main loop, a concrete subclass should implement the actual application's main loop here.
Reimplemented in cgi, and daemon.
References file::printf().

1.6.1