These functions all follow a general pattern:a.load( source, Regex match, String prefix ); a.save( dest, Regex match, String prefix ); a.save_changes( dest, Regex match, String prefix );
Only parameter 1. is required, but if you want to specify 3, you must also specify 2.ArgMap_opt::load( char** argv, Regex* match=0, String prefix="" ); ArgMap_opt::save( char** argv, Regex* match=0, String prefix="" ); ArgMap_env::load( char** envp, Regex* match=0, String prefix="" ); ArgMap_env::save( char** envp, Regex* match=0, String prefix="" ); ArgMap_par::load( String& filename, Regex* match=0, String prefix="" ); ArgMap_par::save( String& filename, Regex* match=0, String prefix="" ); ArgMap_stream ... see below.
Instead of fstreams, any kind of already opened input stream can be passed to the routine. For example, pass `cin' instead of `global_var_str' and it will parse input from standard input, or pass it a strstream into which you have printed a string, and it will parse a character string that's already in core. See also, information on C++ streams.#include < iostream.h > #include < fstream.h > #include "ArgMap.h" #include "ArgMap_util.h" main() { ArgMap_stream global_vars; ifstream global_var_str("/tmp/file.txt",ios::in); ArgMap_stream::load( global_var_str, fmt_xxx ); cout << "The value for COLOR is " << global_vars["COLOR"]; }
The fmt_xxx argument must be a 10 character array that specifies how to parse the input. The ten characters needed are:
fmt_type | start | pair | sep | end | trim | strip | open | close | esc | com |
---|---|---|---|---|---|---|---|---|---|---|
fmt_mime_hdr | Cna | ':' | '\n' | '\n' | ' ' | '\r' | Cna | Cna | Cna | Cna |
fmt_html_post | Cna | '=' | '&' | Cws | Cna | Cna | Cna | Cna | Cna | Cna |
fmt_duck_stat | Cna | '=' | '\n' | Cna | ' ' | '\r' | Cna | Cna | Cna | Cna |
fmt_html | '<' | '=' | ' ' | '>' | Cws | '\r' | '\"' | '\"' | Cna | Cna |
fmt_rpm | Cna | '=' | ' ' | '}' | Cws | '\r' | '(' | ')' | '\\' | Cna |
fmt_parfile | Cna | '=' | '\n' | Cna | Cws | '\r' | Cpo | Cpc | '\\' | '#' |