33 #include "dcmtk/config/osconfig.h" 34 #include "dcmtk/ofstd/ofstring.h" 35 #include "dcmtk/ofstd/ofstack.h" 36 #include "dcmtk/ofstd/ofstream.h" 38 #define INCLUDE_CSTDIO 39 #include "dcmtk/ofstd/ofstdinc.h" 66 #define OFConfigFile_MaxLevel 2 67 #define OFConfigFile_CommentChar '#' 125 OFBool
less(
const char *c)
const 166 void print(STD_NAMESPACE ostream& out,
unsigned int level);
201 , maxLevel_(maxLevel)
230 if ((level <= maxLevel_) && array_ && array_[level])
return array_[level]->getKeyword();
else return NULL;
239 if ((level <= maxLevel_) && array_ && array_[level])
return array_[level]->getValue();
else return NULL;
247 OFBool section_valid(
unsigned int level)
const;
285 void next_section(
unsigned int level);
355 unsigned int maxLevel = OFConfigFile_MaxLevel,
356 char commentChar = OFConfigFile_CommentChar,
357 OFBool orderedMode = OFFalse);
366 void loadFile(FILE *infile);
373 const char *get_keyword(
unsigned int level);
379 const char *get_value();
391 OFBool get_bool_value(OFBool defaultvalue);
400 return cursor_.section_valid(level);
414 cursor_.set_section(level, key, anchor_);
427 cursor_.first_section(level, anchor_);
440 cursor_.next_section(level);
449 void restore_cursor();
461 const char *key2=NULL,
462 const char *key3=NULL);
469 const char *get_entry(
const char *key0);
474 void print(STD_NAMESPACE ostream& out);
484 char read_char(FILE *infile);
491 char read_keywordchar(FILE *infile);
499 void read_entry(FILE *infile);
505 void store_char(
char c);
OFConfigFileNode(const char *keyword)
constructor.
OFConfigFileNodePtr * array_
the cursor is an array of pointers to OFConfigFileNode objects
unsigned int maxLevel_
depth of tree, i.e. number of entries in array_
const char * getKeyword(unsigned int level) const
return keyword as C string.
const char * getValue() const
return current value as C string
this class maintains one configuration file entry (key-value pair) and the links that comprise the co...
OFStack< OFConfigFileCursor > stack_
stack of cursor positions that can be saved and restored
char * buffer_
buffer during file read
long bufsize_
buffer size during file read
OFConfigFileNode * getBrother() const
return pointer to next object in tree on same level
OFBool section_valid(unsigned int level) const
checks if the cursor points to a valid entry in the config data tree up to the the specified level...
structure used by class OFConfigFile to store a cursor pointing to the currently selected section and...
void print(STD_NAMESPACE ostream &out, unsigned int level)
print the content of this node to an output stream
OFBool operator<(const OFConfigFileCursor &) const
dummy comparison operator, needed by MSVC5 with STL.
OFString value_
configuration value
char commentChar_
character starting comment lines
const char * getValue(unsigned int level) const
return value as C string Precondition is that section_valid(level) return true.
OFBool less(const char *c) const
check if keyword compares "<" to given string
OFBool match(const char *c) const
check if keyword matches given string
void setValue(const char *c)
set value from C string
OFString keyword_
configuration keyword
class for reading and evaluating configuration files.
~OFConfigFileCursor()
destructor
unsigned int maxLevel_
depth of tree, i.e. number of entries in array_
void setSon(OFConfigFileNode *son)
set pointer to next object in tree on lower level
const char * getKeyword() const
return keyword as C string
void first_section(unsigned int level)
sets cursor to the first entry at the given level (without changing the cursor position at higher lev...
OFConfigFileCursor cursor_
current cursor position
OFBool operator==(const OFConfigFileCursor &) const
dummy comparison operator, needed by MSVC5 with STL.
OFConfigFileNode & operator=(const OFConfigFileNode &arg)
private undefined copy assignment operator
int isnewline_
flag indicating whether newline during file read
OFConfigFileNode * getSon() const
return pointer to next object in tree on lower level
OFBool orderedMode_
mode flag for reading configuration file.
~OFConfigFileNode()
destructor, recursively deletes whole tree
size_t bufptr_
index into buffer during file read
void set_section(unsigned int level, const char *key)
sets cursor to the entry with keyword "key" at the given level.
a simple string class that implements a subset of std::string.
void setBrother(OFConfigFileNode *brother)
set pointer to next object in tree on same level
OFConfigFileNode * anchor_
anchor to data tree
int crfound_
flag indicating whether CR was read during file read
const char * c_str() const
returns a pointer to the initial element of an array of length size()+1 whose first size() elements e...
void next_section(unsigned int level)
sets cursor to the next entry at the given level (without changing the cursor position at higher leve...
OFConfigFileNode * brother_
pointer to next object in tree on same level
OFConfigFileNode * son_
pointer to next object in tree on lower level
OFConfigFileCursor(unsigned int maxLevel)
default constructor