![]() |
XRootD
|
#include <XrdOucGatherConf.hh>
Public Types | |
enum | Level { full_lines = 0 , trim_lines , only_body , trim_body } |
Public Member Functions | |
XrdOucGatherConf (const char **&want, XrdSysError *errP=0) | |
XrdOucGatherConf (const char *want, XrdSysError *errP=0) | |
~XrdOucGatherConf () | |
void | EchoLine () |
void | EchoOrder (bool doBefore) |
int | Gather (const char *cfname, Level lvl, const char *parms=0) |
char * | GetLine () |
char * | GetToken (char **rest=0, int lowcase=0) |
bool | hasData () |
const char * | LastLine () |
void | MsgE (const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0, const char *txt6=0) |
void | MsgfE (const char *fmt,...) |
void | MsgfW (const char *fmt,...) |
void | MsgW (const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0, const char *txt6=0) |
void | RetToken () |
void | Tabs (int x=1) |
bool | useData (const char *data) |
Definition at line 35 of file XrdOucGatherConf.hh.
Gather information from a config file.
cfname | Path to the configuration file. |
lvl | Indicates how the gathered directives are to be saved: full_lines - the full directive line, including newline. trim_lines - Like full_lines but the prefix (i.e.characters the dot) are discarded. Useful only when gathering a single prefix. only_body Saves the body of each wanted directive as a space separated string blob. trim_body Like only_body but also includes the directive characters after the dot. Useful only when gathering a single prefix. |
parms | Optional pointer to initial configuration parameters. These may be present for plugins. |
Enumerator | |
---|---|
full_lines | Complete lines. |
trim_lines | Prefix trimmed lines. |
only_body | Only directive bodies as a string blob. |
trim_body | Prefix trimmed lines as a string blob. |
Definition at line 84 of file XrdOucGatherConf.hh.
XrdOucGatherConf::XrdOucGatherConf | ( | const char * | want, |
XrdSysError * | errP = 0 |
||
) |
Constructor #1
want | A space separated list of directive prefixes (i.e. end with a dot) and actual directives that should be gathered. |
errP | Optional pointer to an error object. When supplied, gathered lines are echoed. Additionally, error messages are issued. supplied XrdSysError object or using std::cerr using a |
Definition at line 70 of file XrdOucGatherConf.cc.
References XrdOucString::c_str(), XrdOucString::endswith(), XrdOucString::length(), and XrdOucGatherConfData::Match.
XrdOucGatherConf::XrdOucGatherConf | ( | const char **& | want, |
XrdSysError * | errP = 0 |
||
) |
Constructor #2
want | A vector of strings of directive prefixes (i.e. end with a dot) and actual directives that should be gathered. The end of the vector is indicated by a nil pointer (e,g, const char *want[] = {"x.c", "y.", 0}; |
errP | Optional pointer to an error object. When supplied, gathered lines are echoed. Additionally, error messages are issued. supplied XrdSysError object or using std::cerr using a |
Definition at line 86 of file XrdOucGatherConf.cc.
References XrdOucGatherConfData::Match.
XrdOucGatherConf::~XrdOucGatherConf | ( | ) |
Definition at line 103 of file XrdOucGatherConf.cc.
References XrdOucGatherConfData::gBuff, XrdOucGatherConfData::Match, and XrdOucTList::next.
void XrdOucGatherConf::EchoLine | ( | ) |
Echo the last line retrieved using GetLine() using proper framing.
@notes 1) An exception is thrown if a XrdSysError object was not supplied.
Definition at line 119 of file XrdOucGatherConf.cc.
References XrdOucString::c_str(), XrdOucGatherConfData::eDest, XrdOucString::length(), XrdOucGatherConfData::lline, and XrdSysError::Say().
void XrdOucGatherConf::EchoOrder | ( | bool | doBefore | ) |
Specift the order in which the last line is displayed vs a message.
@paramn doBefore - When true, the line is displayed before the message. When false, it is displayed after the message (default).
@notes 1) This call is only relevant to calls to MsgE(), MsgW(), MsgfE(), and MsgfW.
Definition at line 136 of file XrdOucGatherConf.cc.
References XrdOucGatherConfData::echobfr.
int XrdOucGatherConf::Gather | ( | const char * | cfname, |
Level | lvl, | ||
const char * | parms = 0 |
||
) |
Definition at line 145 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::Attach(), XrdOucString::c_str(), XrdCms::Config, XrdOucGatherConfData::eDest, XrdSysError::Emsg(), full_lines, XrdOucGatherConfData::gBuff, XrdOucString::length(), XrdOucGatherConfData::Match, XrdOucTList::next, only_body, open(), XrdOucString::resize(), XrdOucTList::text, XrdOucGatherConfData::Tokenizer, trim(), trim_body, and trim_lines.
Referenced by StatsFileSystem::Config(), and XrdOfsgetPrepare().
char * XrdOucGatherConf::GetLine | ( | ) |
Sequence to the next line in the configuration file.
@notes 1) You must call GetLine() before calling GetToken().
Definition at line 247 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::GetLine(), XrdOucGatherConfData::lline, and XrdOucGatherConfData::Tokenizer.
Referenced by StatsFileSystem::Config(), and XrdOfsgetPrepare().
char * XrdOucGatherConf::GetToken | ( | char ** | rest = 0 , |
int | lowcase = 0 |
||
) |
Get the next blank-delimited token in the record returned by Getline().
rest | - Address of a char pointer. When specified, a pointer to the first non-blank character after the returned token. |
lowcasee | - When 1, all characters are converted to lower case. When 0, the default, the characters are not changed. |
Definition at line 263 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::GetToken(), and XrdOucGatherConfData::Tokenizer.
Referenced by StatsFileSystem::Config(), and XrdOfsgetPrepare().
bool XrdOucGatherConf::hasData | ( | ) |
Check if data is present.
Definition at line 272 of file XrdOucGatherConf.cc.
References XrdOucGatherConfData::gBuff.
const char * XrdOucGatherConf::LastLine | ( | ) |
Get the last line.
Definition at line 281 of file XrdOucGatherConf.cc.
References XrdOucString::c_str(), XrdOucString::capacity(), and XrdOucGatherConfData::lline.
void XrdOucGatherConf::MsgE | ( | const char * | txt1, |
const char * | txt2 = 0 , |
||
const char * | txt3 = 0 , |
||
const char * | txt4 = 0 , |
||
const char * | txt5 = 0 , |
||
const char * | txt6 = 0 |
||
) |
Display a space delimited error/warning message.
txt1,txt2,txt3,txt4,txt5,txt6 | the message components formatted as "txt1 [txt2] [txt3] [txt4] [txt5] [txt6]" |
@notes 1) This methods throws an exception if a XrdSysError object was not passed to the constructor. 2) The last line returned by this object will be displayed either before or after the message (see EchoOrder()). 3) Messages are truncated at 2048 bytes. 4} Use MsgE for errors. The text is prefixed by "Config mistake:" Use MsgW for warnings. The text is prefixed by "Config warning:"
Definition at line 291 of file XrdOucGatherConf.cc.
void XrdOucGatherConf::MsgfE | ( | const char * | fmt, |
... | |||
) |
Display a formated error/warning message using variable args (i.e. vprintf).
fmt | the message formatting template (i.e. printf format). |
... | the arguments that should be used with the template. The formatted message is truncated at 2048 bytes. |
@notes 1) This methods throws an exception if a XrdSysError object was not passed to the constructor. 2) The last line returned by this object will be displayed either before or after the message (see EchoOrder()). 3) Messages are truncated at 2048 bytes. 4} Use MsgfE for errors. The text is prefixed by "Config mistake:" Use MsgfW for warnings. The text is prefixed by "Config warning:"
Definition at line 360 of file XrdOucGatherConf.cc.
void XrdOucGatherConf::MsgfW | ( | const char * | fmt, |
... | |||
) |
Definition at line 379 of file XrdOucGatherConf.cc.
void XrdOucGatherConf::MsgW | ( | const char * | txt1, |
const char * | txt2 = 0 , |
||
const char * | txt3 = 0 , |
||
const char * | txt4 = 0 , |
||
const char * | txt5 = 0 , |
||
const char * | txt6 = 0 |
||
) |
Definition at line 312 of file XrdOucGatherConf.cc.
void XrdOucGatherConf::RetToken | ( | ) |
Backups the token scanner just prior to the last returned token.
@notes 1) Only one backup is allowed. Calling RetToken() more than once without an intervening GetToken() call results in undefined behaviour. 2) This call is useful for backing up due to an overscan.
Definition at line 417 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::RetToken(), and XrdOucGatherConfData::Tokenizer.
void XrdOucGatherConf::Tabs | ( | int | x = 1 | ) |
Specify how tag characters should be handled.
x | - When 0, tabs are converted to spaces. When 1, tabs are untouched (the default). |
Definition at line 426 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::Tabs(), and XrdOucGatherConfData::Tokenizer.
bool XrdOucGatherConf::useData | ( | const char * | data | ) |
Attempt to use pre-existing data.
data | - Pointer to null terminated pre-existing data. |
Definition at line 435 of file XrdOucGatherConf.cc.
References XrdOucTokenizer::Attach(), XrdOucGatherConfData::gBuff, and XrdOucGatherConfData::Tokenizer.
Referenced by XrdOfsgetPrepare().