In this chapter are functions for manipulating with libcfg+ properties described.
#include <cfg+.h> |
void cfg_clear_property
(CFG_CONTEXT con, enum cfg_property_type type);
int cfg_add_property
(CFG_CONTEXT con, enum cfg_property_type type, char *str);
int cfg_remove_property
(CFG_CONTEXT con, enum cfg_property_type type, char *str);
Imagine one property as set of strings. Function cfg_clear_property() clears all strings of property specified by type parameter in context con. Similary, function cfg_add_property() adds string str to property specified by type parameter in context con. Behaviour of cfg_remove_property() is analogical. It removes one string from property.
Types of properties, which are passed to mentioned functions as parameter type, are described in following tables. They are divided into three types. Shared properties that affect both, comand line and configuration file. Further Command line related properties that affects only command line and finally Configuration file related properties that affect only configuration file.
Table 2-5. Shared properties
type parameter | Brief description | Description |
---|---|---|
CFG_QUOTE_PREFIX | quotation prefix | For changing quotation prefix use this type. Note, that you probably want also set quotation postfix equivalent to this prefix. By default are standart quotation characters, apostrophes (') and inverted commans ("), initialized (also for postfixes). |
CFG_QUOTE_POSTFIX | quotation postfix | For changing quotation postfix use this type. Note, that you probably want also set quotation prefix equivalent to this postfix. By default are standart quotation characters, apostrophes (') and inverted commans ("), initialized (also for prefixes). |
Here are properties for command line.
Table 2-6. Command line related properties
type parameter | Brief description | Description |
---|---|---|
CFG_LINE_STOP_STRING | command line stop string | For changing command line stop string use this type. Set this property if you want to stop parsing on specified string which occurs on command line. Error code CFG_ERROR_STOP_STR_FOUND is returned from parsing function to determine this event. By default is nothing initialized. |
CFG_LINE_SHORT_OPTION_PREFIX | command line short option prefix | For changing command line short option prefix use this type. Default value is of course single dash (-), because it is most offten used in applications. You will probably don't need to redefine this property. |
CFG_LINE_LONG_OPTION_PREFIX | command line short option prefix | For changing command line long option prefix use this type. Default value is of course double dash (--), because it is most offten used in applications. You will probably don't need to redefine this property. |
CFG_LINE_OPTION_ARG_SEPARATOR | command line option argument separator | For changing command line multi values separators use this type. Multi values separators are strings used for separation option values initialized with one argument. For example if separator is comma, one command line argument will be similar to this: --multi=val1,val2,val3. Option must have CFG_MULTI_SEPARATED flag set. By default are space, , and ; initialized. |
CFG_LINE_MULTI_VALS_SEPARATOR | command line multi values separator | For changing command line option argument separator use this type. Option argument separators are strings used to separate option and its argument. By default is = character used. For example --option=argument. Note that on command line argument can be initialized also as following string with no need of separator usage (like this: --option argument). |
Here are properties for configuration file.
Table 2-7. Configuration file related properties
type parameter | Brief description | Description |
---|---|---|
CFG_FILE_STOP_PREFIX | config file stop prefix | For changing configuration file stop string use this type. Set this property if you want to stop parsing on specified string which occurs on configration file line. Error code CFG_ERROR_STOP_STR_FOUND is returned from parsing function to determine this event. By default is nothing initialized. We recomend you set this property to [ character for determining section beginning (to stop parsing on section header). |
CFG_FILE_COMMENT_PREFIX | config file comment prefix | For changing configuration comment prefix use this type. Lines started with one of these prefixes are skipped. By default are #, ; and // initialized. |
CFG_FILE_MULTI_LINE_POSTFIX | config file multi line postfix | For changing configuration file multi line postfix use this type. Multi line postfixes are strings used to determine situation, that line continues on next line. Multi lines are are concatenated to one and that is parsed. Multui line postfixes are removed from concatenated line. By deault is backslash (\) initialized. |
CFG_FILE_OPTION_ARG_SEPARATOR | config file option argument separator | For changing configuration file multi values separators use this type. Multi values separators are strings used for separation option values initialized with one argument. For example if separator is comma one line in configuration fill will be similar to this: multi = val1,val2,val2. Option must have CFG_MULTI_SEPARATED flag set. By default are space, , and ; initialized. |
CFG_FILE_MULTI_VALS_SEPARATOR | config file multi values separator | For changing configuration file option argument separator use this type. Option argument separators are strings used to separate option and its argument. By default is = character used. For example option = argument. |