yast2-core
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
IniParser Class Reference

#include <IniParser.h>

Public Member Functions

 IniParser (const SCRAgent &agent_)
 
 ~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) const
 
bool HaveRewrites () const
 
bool repeatNames () const
 accessor method More...
 
bool isFlat () const
 accessor method More...
 
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_file (const string &filename, IniSection &section)
 
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
 
bool shell_quoted_value
 
string subindent
 
vector< Regexlinecomments
 
vector< Regexcomments
 
vector< sectionsections
 
vector< paramparams
 
vector< IoPatternrewrites
 
ifstream scanner
 
string scanner_file
 
int scanner_line
 
bool started
 
bool multiple_files
 
vector< string > files
 
const SCRAgentagent
 

Detailed Description

Contains info from scrconf file and ini file read routines.

Constructor & Destructor Documentation

IniParser::IniParser ( const SCRAgent agent_)
inline
IniParser::~IniParser ( )

Member Function Documentation

string IniParser::changeCase ( const string &  str) const
string IniParser::getFileName ( const string &  sec,
int  rb 
) const

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

Parameters
secsection name
rbindex of rewrite rule
Returns
rewritten file name

References file, rewrites, and y2debug.

Referenced by IniSection::setAllDoIt(), IniAgent::Write(), and write().

time_t IniParser::getTimeStamp ( )
private

Get time stamp of file in sinble file mode.

References agent, file, multiple_files, SCRAgent::targetPath(), and y2error.

Referenced by parse(), UpdateIfModif(), and write().

bool IniParser::HaveRewrites ( ) const
inline

Using file name rewriting?

Referenced by IniAgent::Read(), and IniAgent::Write().

void IniParser::initFiles ( const char *  fn)

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

Parameters
fnfile name of ini file

References file, and multiple_files.

Referenced by IniAgent::otherCommand().

void IniParser::initFiles ( const YCPList f)

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

Parameters
flist of glob-expressions

References files, multiple_files, YCPList::size(), YCPList::value(), and y2error.

int IniParser::initMachine ( const YCPMap scr)
bool IniParser::isFlat ( ) const
inline

accessor method

References flat.

Referenced by IniSection::Delete(), IniSection::Dir(), IniSection::Read(), and IniSection::Write().

bool IniParser::isStarted ( )
inline
int IniParser::parse ( )

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

References agent, file, files, getTimeStamp(), multi_files, multiple_files, parse_helper(), rewrites, scanner_start(), scanner_stop(), SCRAgent::targetPath(), timestamp, y2debug, and y2error.

Referenced by IniAgent::otherCommand(), and UpdateIfModif().

int IniParser::parse_helper ( IniSection ini)
private
bool IniParser::repeatNames ( ) const
inline
int IniParser::scanner_get ( string &  s)
private

get line from ini file.

References stringutil::getline(), line_can_continue, scanner, and scanner_line.

Referenced by parse_helper().

int IniParser::scanner_start ( const char *  fn)
private

Open ini file.

References agent, scanner, scanner_file, scanner_line, and SCRAgent::targetPath().

Referenced by parse().

void IniParser::scanner_stop ( )
private

Close ini file.

References scanner.

Referenced by parse().

bool IniParser::sectionNeedsEnd ( int  i)
inline

Does a section have end-mark defined?

Parameters
iindex of section rule
Returns
true if yes

Referenced by parse_helper().

void IniParser::UpdateIfModif ( )

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

References file, getTimeStamp(), multiple_files, parse(), read_only, repeat_names, timestamp, y2debug, and y2warning.

Referenced by IniAgent::Dir(), IniAgent::Read(), and write().

int IniParser::write ( )
int IniParser::write_file ( const string &  filename,
IniSection section 
)
private
int IniParser::write_helper ( IniSection ini,
ofstream &  of,
int  depth 
)
private

Member Data Documentation

const SCRAgent& IniParser::agent
private

Needed to get target path

Referenced by getTimeStamp(), parse(), scanner_start(), and write_file().

vector<Regex> IniParser::comments
private

Regular expressions for comments over part of the line.

Referenced by initMachine(), and parse_helper().

bool IniParser::comments_last
private

lines are parsed for comments after they are parsed for values

Referenced by initMachine(), and parse_helper().

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!

Referenced by IniAgent::Write(), and write().

string IniParser::file
private

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

Referenced by getFileName(), getTimeStamp(), initFiles(), parse(), UpdateIfModif(), and write().

vector<string> IniParser::files
private

Vector of globe-expressions.

Referenced by initFiles(), parse(), and write().

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.

Referenced by changeCase(), and initMachine().

bool IniParser::flat
private

ini file sections are created in flat-mode

Referenced by initMachine(), and isFlat().

bool IniParser::global_values
private

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

Referenced by initMachine(), and parse_helper().

bool IniParser::ignore_case
private

ignore case in keys and section names

Referenced by changeCase(), and initMachine().

bool IniParser::ignore_case_regexps
private

ignore case in regexps

Referenced by initMachine().

IniSection IniParser::inifile

Toplevel ini section.

Referenced by IniAgent::Dir(), IniAgent::Read(), and IniAgent::Write().

bool IniParser::join_multiline
private

multiline values are connected into one

Referenced by initMachine(), and parse_helper().

bool IniParser::line_can_continue
private

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

Referenced by initMachine(), and scanner_get().

vector<Regex> IniParser::linecomments
private

Regular expression for comments over whole line.

Referenced by initMachine(), and parse_helper().

map<string,FileDescr> IniParser::multi_files
private

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

Referenced by parse(), and write().

bool IniParser::multiple_files
private

Multiple files mode or single file mode?

Referenced by getTimeStamp(), initFiles(), initMachine(), parse(), UpdateIfModif(), and write().

bool IniParser::no_finalcomment_kill
private

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

Referenced by initMachine(), and parse_helper().

bool IniParser::no_nested_sections
private

nested sections are not allowed

Referenced by initMachine(), and parse_helper().

vector<param> IniParser::params
private

Regular expressions for parameters (keys/values).

Referenced by initMachine(), parse_helper(), and write_helper().

bool IniParser::prefer_uppercase
private

if ignore case, prefer upper case when saving

Referenced by changeCase(), and initMachine().

bool IniParser::read_only
private

read-only

Referenced by initMachine(), UpdateIfModif(), and write().

bool IniParser::repeat_names
private

more values or sections of the same name are allowed

Referenced by initMachine(), repeatNames(), and UpdateIfModif().

vector<IoPattern> IniParser::rewrites
private

Regular expressions for rewrite rules.

Referenced by getFileName(), initMachine(), and parse().

ifstream IniParser::scanner
private

opened file for scanner

Referenced by scanner_get(), scanner_start(), and scanner_stop().

string IniParser::scanner_file
private

name of scanned file

Referenced by scanner_start().

int IniParser::scanner_line
private

line number of scanned file

Referenced by scanner_get(), and scanner_start().

vector<section> IniParser::sections
private

Regular expressions for sections.

Referenced by initMachine(), parse_helper(), and write_helper().

bool IniParser::shell_quoted_value
private

assume that value is shell string - quoted on write, unquoted on read

Referenced by initMachine(), parse_helper(), and write_helper().

bool IniParser::started
private

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

Referenced by initMachine(), and isStarted().

string IniParser::subindent
private

this string is printed before each line in subsections

Referenced by initMachine(), and write_helper().

time_t IniParser::timestamp
private

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

Referenced by parse(), UpdateIfModif(), and write().


The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.8.8