Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Examples

IniParser Class Reference

#include <IniParser.h>

List of all members.

Public Member Functions

 IniParser ()
 ~IniParser ()
void initFiles (const char *fn)
void initFiles (const YCPList &f)
int initMachine (const YCPMap &scr)
bool isStarted ()
int parse ()
void UpdateIfModif ()
int write ()
bool sectionNeedsEnd (int i)
string getFileName (const string &sec, int rb)
bool HaveRewrites () const
bool repeatNames () const
 accessor method

bool isFlat () const
 accessor method

string changeCase (const string &str) const

Public Attributes

set< string > deleted_sections
IniSection inifile

Private Member Functions

time_t getTimeStamp ()
int scanner_start (const char *fn)
void scanner_stop ()
int scanner_get (string &s)
int parse_helper (IniSection &ini)
int write_helper (IniSection &ini, ofstream &of, int depth)

Private Attributes

time_t timestamp
map< string, FileDescrmulti_files
string file
bool line_can_continue
bool ignore_case_regexps
bool ignore_case
bool prefer_uppercase
bool first_upper
bool no_nested_sections
bool global_values
bool repeat_names
bool comments_last
bool join_multiline
bool no_finalcomment_kill
bool read_only
bool flat
string subindent
vector< Regexlinecomments
vector< Regexcomments
vector< sectionsections
vector< paramparams
vector< IoPatternrewrites
ifstream scanner
int scanner_line
bool started
bool multiple_files
vector< string > files


Detailed Description

Contains info from scrconf file and ini file read routines.


Constructor & Destructor Documentation

IniParser::IniParser  )  [inline]
 

IniParser::~IniParser  ) 
 


Member Function Documentation

string IniParser::changeCase const string &  str  )  const
 

change case of string

Parameters:
str string to change
Returns:
changed string

string IniParser::getFileName const string &  sec,
int  rb
 

Get the file name of section. If there is a rewrite rule rb, rewrites section name to file name using the rule rb.

Parameters:
sec section name
rb index of rewrite rule
Returns:
rewritten file name

time_t IniParser::getTimeStamp  )  [private]
 

Get time stamp of file in sinble file mode.

bool IniParser::HaveRewrites  )  const [inline]
 

Using file name rewriting?

void IniParser::initFiles const YCPList f  ) 
 

Sets parser to multiple file mode and sets the glob-expressions.

Parameters:
f list of glob-expressions

void IniParser::initFiles const char *  fn  ) 
 

Sets parser to single file mode and sets the file name to read.

Parameters:
fn file name of ini file

int IniParser::initMachine const YCPMap scr  ) 
 

Sets flags and regular expressions.

Parameters:
scr control script
Returns:
0 if successful

bool IniParser::isFlat  )  const [inline]
 

accessor method

bool IniParser::isStarted  )  [inline]
 

int IniParser::parse  ) 
 

Parse the ini files. Parser must be started before this function is called.

int IniParser::parse_helper IniSection ini  )  [private]
 

Parse one ini file and build a structure of IniSection.

bool IniParser::repeatNames  )  const [inline]
 

accessor method

int IniParser::scanner_get string &  s  )  [private]
 

get line from ini file.

int IniParser::scanner_start const char *  fn  )  [private]
 

Open ini file.

void IniParser::scanner_stop  )  [private]
 

Close ini file.

bool IniParser::sectionNeedsEnd int  i  )  [inline]
 

Does a section have end-mark defined?

Parameters:
i index of section rule
Returns:
true if yes

void IniParser::UpdateIfModif  ) 
 

Check the ini files and in case some of them changed externally, reload it.

int IniParser::write  ) 
 

Write changed ini files on disk

int IniParser::write_helper IniSection ini,
ofstream &  of,
int  depth
[private]
 

Write one ini file.


Member Data Documentation

vector<Regex> IniParser::comments [private]
 

Regular expressions for comments over part of the line.

bool IniParser::comments_last [private]
 

lines are parsed for comments after they are parsed for values

set<string> IniParser::deleted_sections
 

If Write (.s.section_name, nil) was called in multiple files mode, than the file section_name has to be removed at the end. But as we have file name rewrite rules, section_name needn't be file name. Hence it is necessary to convert section_name to file name before inserting to deleted_sections.
Note: Write (.s.section_name, nil); Write (.v.section_name.k, "v"); means that section is deleted at first and created again later. In this case file isn't removed!

string IniParser::file [private]
 

File name of the ini file -- single file mode only.

vector<string> IniParser::files [private]
 

Vector of globe-expressions.

bool IniParser::first_upper [private]
 

if ignore case, outputs first upper and other lower If not first_upper, nor prefer_uppercase is set, keys and values are saved in lower case.

bool IniParser::flat [private]
 

ini file sections are created in flat-mode

bool IniParser::global_values [private]
 

values at the top level(not in section) are allowed

bool IniParser::ignore_case [private]
 

ignore case in keys and section names

bool IniParser::ignore_case_regexps [private]
 

ignore case in regexps

IniSection IniParser::inifile
 

Toplevel ini section.

bool IniParser::join_multiline [private]
 

multiline values are connected into one

bool IniParser::line_can_continue [private]
 

if there is \ at the end of line, next line is appended to the current one

vector<Regex> IniParser::linecomments [private]
 

Regular expression for comments over whole line.

map<string,FileDescr> IniParser::multi_files [private]
 

Times of last modification of read files, used in multiple files mode.

bool IniParser::multiple_files [private]
 

Multiple files mode or single file mode?

bool IniParser::no_finalcomment_kill [private]
 

do not kill empty lines at final comment at the end of top-level section

bool IniParser::no_nested_sections [private]
 

nested sections are not allowed

vector<param> IniParser::params [private]
 

Regular expressions for parameters (keys/values).

bool IniParser::prefer_uppercase [private]
 

if ignore case, prefer upper case when saving

bool IniParser::read_only [private]
 

read-only

bool IniParser::repeat_names [private]
 

more values or sections of the same name are allowed

vector<IoPattern> IniParser::rewrites [private]
 

Regular expressions for rewrite rules.

ifstream IniParser::scanner [private]
 

opened file for scanner

int IniParser::scanner_line [private]
 

line number of scanned file

vector<section> IniParser::sections [private]
 

Regular expressions for sections.

bool IniParser::started [private]
 

set to true in initMachine (after internal parsing structures are initialized, when IniParser is ready to work).

string IniParser::subindent [private]
 

this string is printed before each line in subsections

time_t IniParser::timestamp [private]
 

Time of last modification of file, used in single file mode.


The documentation for this class was generated from the following files:
Generated on Fri Nov 9 18:15:24 2007 for yast2-core by doxygen 1.3.6