yast2-core
|
#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 §ion) |
int | write_helper (IniSection &ini, ofstream &of, int depth) |
Private Attributes | |
time_t | timestamp |
map< string, FileDescr > | multi_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< Regex > | linecomments |
vector< Regex > | comments |
vector< section > | sections |
vector< param > | params |
vector< IoPattern > | rewrites |
ifstream | scanner |
string | scanner_file |
int | scanner_line |
bool | started |
bool | multiple_files |
vector< string > | files |
const SCRAgent & | agent |
Contains info from scrconf file and ini file read routines.
|
inline |
IniParser::~IniParser | ( | ) |
string IniParser::changeCase | ( | const string & | str | ) | const |
change case of string
str | string to change |
References first_upper, ignore_case, prefer_uppercase, and str.
Referenced by IniSection::delSection(), IniSection::delValue(), IniSection::delValueFlat(), IniSection::dirHelper(), IniSection::findEndFromUp(), IniSection::findSection(), IniSection::getAll(), IniSection::getMyValue(), IniSection::getSectionProp(), IniSection::getValue(), IniSection::getValueFlat(), IniSection::initSection(), IniSection::initValue(), IniSection::reindex(), IniSection::setAll(), IniSection::setMyValue(), IniSection::setSectionProp(), IniSection::setValue(), and IniSection::setValueFlat().
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.
sec | section name |
rb | index of rewrite rule |
References file, rewrites, and y2debug.
Referenced by IniSection::setAllDoIt(), IniAgent::Write(), and write().
|
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().
|
inline |
Using file name rewriting?
References rewrites.
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.
fn | file 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.
f | list of glob-expressions |
References files, multiple_files, YCPList::size(), YCPList::value(), and y2error.
int IniParser::initMachine | ( | const YCPMap & | scr | ) |
Sets flags and regular expressions.
scr | control script |
References section::begin, param::begin, comments, comments_last, COMPARE_OPTION, Regex::compile(), section::end, param::end, section::end_valid, first_upper, flat, getBeginEndType(), getParamsType(), global_values, ignore_case, ignore_case_regexps, YCPElement::isNull(), join_multiline, param::line, line_can_continue, linecomments, param::multiline_valid, multiple_files, no_finalcomment_kill, no_nested_sections, IoPattern::out, params, prefer_uppercase, read_only, repeat_names, rewrites, IoPattern::rx, sections, shell_quoted_value, started, subindent, YCPMap::value(), YCPList::value(), y2error, and ycperror.
Referenced by IniAgent::otherCommand().
|
inline |
accessor method
References flat.
Referenced by IniSection::Delete(), IniSection::Dir(), IniSection::Read(), and IniSection::Write().
|
inline |
References started.
Referenced by IniAgent::Dir(), IniAgent::Read(), IniAgent::Write(), and IniAgent::~IniAgent().
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().
|
private |
Parse one ini file and build a structure of IniSection.
References comment, comments, comments_last, IniBase::getName(), IniBase::getReadBy(), global_values, IniSection::initSection(), IniSection::initValue(), join_multiline, linecomments, RegexMatch::matches, no_finalcomment_kill, no_nested_sections, onlySpaces(), params, RegexMatch::rest, scanner_error, scanner_get(), sectionNeedsEnd(), sections, IniSection::setEndComment(), shell_quoted_value, and YaST::agent_ini::unquote().
Referenced by parse().
|
inline |
accessor method
References repeat_names.
Referenced by IniSection::getMyValue(), IniSection::getSectionProp(), IniSection::initSection(), IniSection::initValue(), IniSection::setMyValue(), IniSection::setSectionProp(), and IniAgent::Write().
|
private |
get line from ini file.
References stringutil::getline(), line_can_continue, scanner, and scanner_line.
Referenced by parse_helper().
|
private |
Open ini file.
References agent, scanner, scanner_file, scanner_line, and SCRAgent::targetPath().
Referenced by parse().
|
inline |
Does a section have end-mark defined?
i | index of section rule |
References sections.
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 | ( | ) |
Write changed ini files on disk
References deleted_sections, file, files, getFileName(), IniBase::getName(), IniSection::getRewriteBy(), getTimeStamp(), IniSection::initReadBy(), IniSection::isDirty(), multi_files, multiple_files, read_only, SECTION, timestamp, UpdateIfModif(), write_file(), y2debug, and y2error.
Referenced by IniAgent::Write(), and IniAgent::~IniAgent().
|
private |
Write one ini file.
References agent, PathInfo::assert_dir(), Pathname::dirname(), IniSection::isPrivate(), SCRAgent::targetPath(), write_helper(), and y2error.
Referenced by write().
|
private |
Write one ini file.
References IniBase::clean(), IniSection::clean(), format(), IniBase::getComment(), IniSection::getContainerBegin(), IniSection::getContainerEnd(), IniSection::getEndComment(), IniBase::getName(), IniBase::getReadBy(), IniEntry::getValue(), params, YaST::agent_ini::quote(), SECTION, sections, shell_quoted_value, and subindent.
Referenced by write_file().
|
private |
Needed to get target path
Referenced by getTimeStamp(), parse(), scanner_start(), and write_file().
|
private |
Regular expressions for comments over part of the line.
Referenced by initMachine(), and parse_helper().
|
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().
|
private |
File name of the ini file – single file mode only.
Referenced by getFileName(), getTimeStamp(), initFiles(), parse(), UpdateIfModif(), and write().
|
private |
Vector of globe-expressions.
Referenced by initFiles(), parse(), and write().
|
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().
|
private |
ini file sections are created in flat-mode
Referenced by initMachine(), and isFlat().
|
private |
values at the top level(not in section) are allowed
Referenced by initMachine(), and parse_helper().
|
private |
ignore case in keys and section names
Referenced by changeCase(), and initMachine().
|
private |
ignore case in regexps
Referenced by initMachine().
IniSection IniParser::inifile |
Toplevel ini section.
Referenced by IniAgent::Dir(), IniAgent::Read(), and IniAgent::Write().
|
private |
multiline values are connected into one
Referenced by initMachine(), and parse_helper().
|
private |
if there is \ at the end of line, next line is appended to the current one
Referenced by initMachine(), and scanner_get().
|
private |
Regular expression for comments over whole line.
Referenced by initMachine(), and parse_helper().
|
private |
|
private |
Multiple files mode or single file mode?
Referenced by getTimeStamp(), initFiles(), initMachine(), parse(), UpdateIfModif(), and write().
|
private |
do not kill empty lines at final comment at the end of top-level section
Referenced by initMachine(), and parse_helper().
|
private |
nested sections are not allowed
Referenced by initMachine(), and parse_helper().
|
private |
Regular expressions for parameters (keys/values).
Referenced by initMachine(), parse_helper(), and write_helper().
|
private |
if ignore case, prefer upper case when saving
Referenced by changeCase(), and initMachine().
|
private |
read-only
Referenced by initMachine(), UpdateIfModif(), and write().
|
private |
more values or sections of the same name are allowed
Referenced by initMachine(), repeatNames(), and UpdateIfModif().
|
private |
Regular expressions for rewrite rules.
Referenced by getFileName(), HaveRewrites(), initMachine(), and parse().
|
private |
opened file for scanner
Referenced by scanner_get(), scanner_start(), and scanner_stop().
|
private |
name of scanned file
Referenced by scanner_start().
|
private |
line number of scanned file
Referenced by scanner_get(), and scanner_start().
|
private |
Regular expressions for sections.
Referenced by initMachine(), parse_helper(), sectionNeedsEnd(), and write_helper().
|
private |
assume that value is shell string - quoted on write, unquoted on read
Referenced by initMachine(), parse_helper(), and write_helper().
|
private |
set to true in initMachine (after internal parsing structures are initialized, when IniParser is ready to work).
Referenced by initMachine(), and isStarted().
|
private |
this string is printed before each line in subsections
Referenced by initMachine(), and write_helper().
|
private |
Time of last modification of file, used in single file mode.
Referenced by parse(), UpdateIfModif(), and write().