1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/base/Sysconfig.h
12
#ifndef ZYPP_BASE_SYSCONFIG_H
13
#define ZYPP_BASE_SYSCONFIG_H
17
#include "zypp/Pathname.h"
23
/** Read sysconfig file \a path_r and return <tt>(key,valye)</tt> pairs. */
24
std::map<std::string,std::string> read( const Pathname & _path );
26
/** Add or change a value in sysconfig file \a path_r.
28
* If \a key_r already exists, only the \a val_r is changed accordingly.
30
* In case \a key_r is not yet present in the file, a new entry may be created
31
* at the end of the file, using the lines in \a newcomment_r as comment
32
* block. If \a newcomment_r is not provided or empty, a new value is not
33
* created and \c false is returned.
35
* \returns \c TRUE if an entry was changed or created.
37
* \throws Exception if \a path_r can not be read or written.
39
* \note \a val_r is written as it is. The caller is responsible for escaping and
40
* enclosing in '"', in case this is needed (\see \ref writeStringVal and \ref str::escape).
42
* \note Lines in \a newcomment_r which do not already start with a '#',
43
* are prefixes with "# ".
49
* # A multiline description of
50
* # the options purpose.
55
bool write( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
56
const std::string & newcomment_r = std::string() );
58
/** Convenience to add or change a string-value in sysconfig file \a path_r.
60
* \a val_r is expected to be a plain string value, so it is propery escaped and enclosed in
61
* double quotes before it is written to the sysconfig file \a path_r.
65
bool writeStringVal( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
66
const std::string & newcomment_r = std::string() );
68
} // namespace sysconfig
72
#endif // ZYPP_BASE_SYSCONFIG_H