/usr/include/arc/ArcConfigIni.h is in nordugrid-arc-dev 5.4.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #ifndef __GM_CONFIG_SECTIONS_H__
#define __GM_CONFIG_SECTIONS_H__
#include <fstream>
#include <string>
#include <list>
#include <arc/ArcConfigFile.h>
namespace Arc {
/// This class is used to process ini-like configuration files.
class ConfigIni {
private:
ConfigFile* fin;
bool open;
std::list<std::string> section_names;
std::string current_section;
int current_section_n;
std::list<std::string>::iterator current_section_p;
int line_number;
bool current_section_changed;
public:
/// Creates object associated with file located at filename.
/// File is kept open and is closed in destructor.
ConfigIni(const char* filename);
/// Creates object associated with already open file f.
/// Associated file will not be closed in destructor and
/// corresponding ConfigFile object must be valid during
/// whole lifetime of this object.
ConfigIni(ConfigFile& f);
/// Ordinary destructor
~ConfigIni(void);
/// Returns true if proper configuration file is associated.
operator bool(void) const { return ((fin!=NULL) && (*fin)); };
/// Specifies section name which will be processed.
/// Unspecified sections will be skipped by ReadNext() methods.
bool AddSection(const char* name);
/// Read next line of configuration from sesction(s) specified by AddSection().
/// Returns true in case of success and fills content of line into line.
bool ReadNext(std::string& line);
/// Read next line of configuration from sesction(s) specified by AddSection().
/// Returns true in case of success and fills split content of line into
/// command and value.
bool ReadNext(std::string& name,std::string& value);
/// Return name of the section to which last read line belongs.
/// This name also includes subsection name.
const char* Section(void) const { return current_section.c_str(); };
/// Returns true if last ReadNext() switched to next section.
bool SectionNew(void) const { return current_section_changed; };
/// Return number of the section to which last read line belongs.
/// Numbers are assigned in order they are passed to AddSection()
/// method starting from 0.
int SectionNum(void) const { return current_section_n; };
/// Returns name of the section to which last read line matched.
/// It is similar to Section() method but name is as specified
/// in AddSection() and hence does not contain subsection(s).
const char* SectionMatch(void) const {
if(current_section_n<0) return "";
return current_section_p->c_str();
};
/// Returns name of subsection to which last read line belongs.
const char* SubSection(void) const {
if(current_section_n<0) return "";
if(current_section.length() > current_section_p->length())
return (current_section.c_str()+current_section_p->length()+1);
return "";
};
/// Return name of subsubsection to which last read line belongs
/// relative to subsection given by name. If current subsection
/// does not match specified name then NULL is returned.
const char* SubSectionMatch(const char* name);
/// Helper method which reads keyword from string at 'line' separated by 'separator'
/// and stores it in 'str'. Each couple of characters starting from \ is
/// replaced by second character. \x## is replaced by code corresponding
/// to hexadecimal number ##.
/// If separator is set to \0 then whole line is consumed.
/// If quotes are not \0 keyword may be enclosed in specified character.
/// Returns position of first character in 'line', which is not in read keyword.
static int NextArg(const char* line,std::string &str,char separator = ' ',char quotes = '"');
/// Reads keyword from string at 'rest' and reduces 'rest' by removing keyword from it.
/// The way it processes keyword is similar to static NextArg method.
static std::string NextArg(std::string &rest,char separator = ' ',char quotes = '"');
};
} // namespace ARex
#endif // __GM_CONFIG_SECTIONS_H__
|