IniSection Class Reference

#include <IniFile.h>

Inheritance diagram for IniSection:

IniBase List of all members.

Public Member Functions

 IniSection (const char *u)
 IniSection (const IniParser *p)
 IniSection (const IniSection &s)
void operator= (const IniSection &s)
virtual ~IniSection ()
 IniSection (const IniParser *p, string n)
void initValue (const string &key, const string &val, const string &comment, int rb)
void initSection (const string &name, const string &comment, int rb, int wb=-2)
void initReadBy ()
void setRewriteBy (int c)
int getRewriteBy ()
int getSubSectionRewriteBy (const char *name)
void setEndComment (const char *c)
const char * getEndComment () const
bool isDirty ()
virtual void clean ()
IniSectionfindSection (const vector< string > &path, int from=0)
int findEndFromUp (const vector< string > &path, int wanted, int found=-1, int from=0)
void Dump ()
int Read (const YCPPath &p, YCPValue &out, bool rewrite)
int Dir (const YCPPath &p, YCPList &out)
int Write (const YCPPath &p, const YCPValue &v, bool rewrite)
int Delete (const YCPPath &p)
IniIterator getContainerBegin ()
IniIterator getContainerEnd ()
IniSectiongetSection (const char *name)

Private Member Functions

void reindex ()
int getMyValue (const YCPPath &p, YCPValue &out, int what, int depth)
int getValue (const YCPPath &p, YCPValue &out, int what, int depth=0)
int getSectionProp (const YCPPath &p, YCPValue &out, int what, int depth=0)
int getAll (const YCPPath &p, YCPValue &out, int depth)
YCPMap getAllDoIt ()
int myDir (YCPList &l, IniType what)
int dirHelper (const YCPPath &p, YCPList &out, int sections, int depth=0)
int setMyValue (const YCPPath &p, const YCPValue &in, int what, int depth)
int setValue (const YCPPath &p, const YCPValue &in, int what, int depth=0)
int setSectionProp (const YCPPath &p, const YCPValue &in, int what, int depth)
int setAll (const YCPPath &p, const YCPValue &in, int depth)
int setAllDoIt (const YCPMap &in)
int delValue (const YCPPath &p, int depth)
int delSection (const YCPPath &p, int depth)
void delMyValue (const string &k)
void delValue1 (IniEntryIdxIterator exi)
void delSection1 (IniSectionIdxIterator sxi)
int getValueFlat (const YCPPath &p, YCPValue &out)
int setValueFlat (const YCPPath &p, const YCPValue &in)
int delValueFlat (const YCPPath &p)
int dirValueFlat (const YCPPath &p, YCPList &l)

Private Attributes

const IniParserip
string end_comment
int rewrite_by
IniContainer container
IniEntryIndex ivalues
IniSectionIndex isections

Detailed Description

Section definition.


Constructor & Destructor Documentation

IniSection::IniSection const char *  u  )  [inline]
 

explicit uninitialized constructor

IniSection::IniSection const IniParser p  )  [inline]
 

IniSection::IniSection const IniSection s  )  [inline]
 

Must define an own copy constructor so that the indices point to the copy, not the original

virtual IniSection::~IniSection  )  [inline, virtual]
 

IniSection::IniSection const IniParser p,
string  n
[inline]
 

this is a constructor for newly added sections --> sets dirty

Parameters:
ip parser to take options from
n name of section


Member Function Documentation

void IniSection::clean  )  [virtual]
 

set all subsection and values to clean

Reimplemented from IniBase.

int IniSection::Delete const YCPPath p  ) 
 

Generic delete for values, sections.

Parameters:
p path to delete
Returns:
0: success

void IniSection::delMyValue const string &  k  )  [private]
 

deletes all values of this name we own

Parameters:
k normalized key

int IniSection::delSection const YCPPath p,
int  depth
[private]
 

Delete section on path. Deletes also all its subsections.

Parameters:
p path to delete value at
depth see getSectionProp
Returns:
0 in case of success

void IniSection::delSection1 IniSectionIdxIterator  sxi  )  [private]
 

deletes a section we own

int IniSection::delValue const YCPPath p,
int  depth
[private]
 

Delete value on path

Parameters:
p path to delete value at
depth see getSectionProp
Returns:
0 in case of success

void IniSection::delValue1 IniEntryIdxIterator  exi  )  [private]
 

deletes a section we own

int IniSection::delValueFlat const YCPPath p  )  [private]
 

Delete value in flat mode

int IniSection::Dir const YCPPath p,
YCPList out
 

Generic interface to SCR::Dir

int IniSection::dirHelper const YCPPath p,
YCPList out,
int  sections,
int  depth = 0
[private]
 

Recursive function to find the one section we want to dir and at last to do dir.

Parameters:
p path
out list of sections/keys
sections get sections (0) or values (!0)?
depth see getSectionProp
Returns:
0 in case of success

int IniSection::dirValueFlat const YCPPath p,
YCPList l
[private]
 

Get list of values in flat mode.

void IniSection::Dump  ) 
 

Dump a section with subsections and subvalues to stdout.

int IniSection::findEndFromUp const vector< string > &  path,
int  wanted,
int  found = -1,
int  from = 0
 

If currently parsed end-section-tag hasn't matched currently processed section by name, we need to find the best possible match by type (read_by). Hence we look for a section on current path which can be closed by found end-section-tag. Note: this function can abort if the path passed in invalid.

Parameters:
path stack of the sections
wanted read-by we want to find
found let unset, last path index that matched
from let unset, current path index
Returns:
index to path

IniSection & IniSection::findSection const vector< string > &  path,
int  from = 0
 

Gets section on a path. Recursive. Attention! This function aborts when it doesn't find the section! Use with care! (Used only by IniParser::parse_helper)

Parameters:
path path to the section
from recursion depth
Returns:
Found ini section iterator

int IniSection::getAll const YCPPath p,
YCPValue out,
int  depth
[private]
 

Get a complete subtree

Parameters:
p path : .all or .all.sec1.sec2
out output is placed here
depth Index of current path component. This function is recursive and depth marks the depth of recursion. We look for path[depth] in current "scope"
Returns:
0 in case of success

YCPMap IniSection::getAllDoIt  )  [private, virtual]
 

Gets data for this section and all its values and subsections

Reimplemented from IniBase.

IniIterator IniSection::getContainerBegin  ) 
 

IniIterator IniSection::getContainerEnd  ) 
 

const char* IniSection::getEndComment  )  const [inline]
 

int IniSection::getMyValue const YCPPath p,
YCPValue out,
int  what,
int  depth
[private]
 

Get a value (or list of them if repeat_names) in this section It would be enough to pass only k instead of p and depth, but then the error messages would not know the whole path

Parameters:
p path
out output is placed here as YCPString or YCPInteger
what 0 - value, 1 - comment, other - read-by
depth path index
Returns:
0 in case of success

int IniSection::getRewriteBy  )  [inline]
 

IniSection & IniSection::getSection const char *  name  ) 
 

Aborts if section doesn't exist! TODO gets any of multiple sections

Parameters:
name name of the section to get
Returns:
section

int IniSection::getSectionProp const YCPPath p,
YCPValue out,
int  what,
int  depth = 0
[private]
 

Get section property -- comment or read-by

Parameters:
p path to value: .section_commment.sec1.sec2.sec3
out output is placed here as YCPString or YCPInteger
what 0 - comment, 1 - rewrite_by, other - read-by
depth Index of current path component. This function is recursive and depth marks the depth of recursion. We look for path[depth] in current "scope"
Returns:
0 in case of success

int IniSection::getSubSectionRewriteBy const char *  name  ) 
 

Parameters:
name name of a section
Returns:
rewrite-by of section or -1 if the section wasn't found

int IniSection::getValue const YCPPath p,
YCPValue out,
int  what,
int  depth = 0
[private]
 

Get a value on a path

Parameters:
p path to value: .value.sec1.sec2.key
out output is placed here as YCPString or YCPInteger
what 0 - value, 1 - comment, other - read-by
depth Index of current path component. This function is recursive and depth marks the depth of recursion. We look for path[depth] in current "scope"
Returns:
0 in case of success

int IniSection::getValueFlat const YCPPath p,
YCPValue out
[private]
 

Get value in flat mode.

Parameters:
p path to value
out output
Returns:
0 in case of success

void IniSection::initReadBy  )  [inline]
 

This function has very special purpose, it ensures that top-section delimiter is not written when saving multiple files.

void IniSection::initSection const string &  name,
const string &  comment,
int  rb,
int  wb = -2
 

If section already exist, it is updated only in case, that it isn't dirty.

Parameters:
name section name
comment comment
rb read-by
wb rewrite-by. if -2 (default), it is not changed

void IniSection::initValue const string &  key,
const string &  val,
const string &  comment,
int  rb
 

If value doesn't exist, creates new, otherwise calls method init of the existing one.

Parameters:
key key
val value
comment comment
rb read-by

bool IniSection::isDirty  ) 
 

int IniSection::myDir YCPList l,
IniType  what
[private]
 

Get directory of this section

Parameters:
l result list
what VALUE or SECTION
Returns:
0 in case of success

void IniSection::operator= const IniSection s  )  [inline]
 

int IniSection::Read const YCPPath p,
YCPValue out,
bool  rewrite
 

Generic interface to SCR::Read

Parameters:
rewrite a #19066 hack - if rewriting is active, .st accesses rewrite_by

void IniSection::reindex  )  [private]
 

build ivalues and isections

int IniSection::setAll const YCPPath p,
const YCPValue in,
int  depth
[private]
 

Set all properties and values for a section. No recursive creation of the specified path.

Parameters:
p path where to start
in value to set
depth see getSectionProp
Returns:
0 in case of success

int IniSection::setAllDoIt const YCPMap in  )  [private, virtual]
 

Set all properties and values for a section.

Parameters:
in value to set
Returns:
0 in case of success

Reimplemented from IniBase.

void IniSection::setEndComment const char *  c  ) 
 

If there is no comment at the beginning and no values and no sections, it is better to set is as comment at the beginning. Sets also dirty flag.

Parameters:
c comment

int IniSection::setMyValue const YCPPath p,
const YCPValue in,
int  what,
int  depth
[private]
 

Set a value (or list of them if repeat_names) in this section It would be enough to pass only k instead of p and depth, but then the error messages would not know the whole path

Parameters:
p path
in value to set (YCPString or YCPInteger) (or YCPList)
what 0 -- value, 1 -- comment, other -- read-by.
depth path index
Returns:
0

void IniSection::setRewriteBy int  c  )  [inline]
 

sets dirty flag also

int IniSection::setSectionProp const YCPPath p,
const YCPValue in,
int  what,
int  depth
[private]
 

Set section comment or read-by. Creates recursively all non-existing subsections.

Parameters:
p path to set value on
in value to set (YCPString or YCPInteger)
what 0 -- comment, 1 - rewrite_by, other -- read-by.
depth see getSectionProp
Returns:
0

int IniSection::setValue const YCPPath p,
const YCPValue in,
int  what,
int  depth = 0
[private]
 

Set value on path. Creates recursively all non-existing subsections.

Parameters:
p path to set value on
in value to set (YCPString or YCPInteger)
what 0 -- value, 1 -- comment, other -- read-by.
depth see getSectionProp
Returns:
0

int IniSection::setValueFlat const YCPPath p,
const YCPValue in
[private]
 

Set value in flat mode.

Parameters:
p path to value
out input
Returns:
0 in case of success

int IniSection::Write const YCPPath p,
const YCPValue v,
bool  rewrite
 

Generic interface to SCR::Write

Parameters:
rewrite a #19066 hack - if rewriting is active, .st accesses rewrite_by


Member Data Documentation

IniContainer IniSection::container [private]
 

What entries of cvalues and csections are valid Values contained by this section Sections contained by this section

string IniSection::end_comment [private]
 

if this is global section, there may be comment at the end this is quite special case, it is impossible to change it

const IniParser* IniSection::ip [private]
 

The parser, queried about global settings But once the const is discarded to add to deleted_sections

IniSectionIndex IniSection::isections [private]
 

Index of sections

IniEntryIndex IniSection::ivalues [private]
 

Index of values

int IniSection::rewrite_by [private]
 

index to IniParser::rewrites for filename - section name mapping It appears that read_by was used for both purposes, causing bug (#19066).


The documentation for this class was generated from the following files:
Generated on Fri Jun 16 18:07:46 2006 for yast2-core by  doxygen 1.4.6