From: Arvin Schnell Date: Mon, 16 Feb 2015 10:52:44 +0000 (+0100) Subject: - allow to rename AsciiFile and SysconigFile X-Git-Tag: v0.2.6~1^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f66ce5fb0a38b72c1432aaadad6473b3f4ea841;p=thirdparty%2Fsnapper.git - allow to rename AsciiFile and SysconigFile --- diff --git a/snapper/AsciiFile.cc b/snapper/AsciiFile.cc index 750e68c1..f08a8d17 100644 --- a/snapper/AsciiFile.cc +++ b/snapper/AsciiFile.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) [2004-2013] Novell, Inc. + * Copyright (c) [2004-2015] Novell, Inc. * * All Rights Reserved. * @@ -197,6 +197,13 @@ AsciiFile::save() } + void + SysconfigFile::setValue(const string& key, const char* value) + { + setValue(key, string(value)); + } + + void SysconfigFile::setValue(const string& key, const string& value) { diff --git a/snapper/AsciiFile.h b/snapper/AsciiFile.h index 3f67dbb2..2d6df7a6 100644 --- a/snapper/AsciiFile.h +++ b/snapper/AsciiFile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2004-2013] Novell, Inc. + * Copyright (c) [2004-2015] Novell, Inc. * * All Rights Reserved. * @@ -67,6 +67,8 @@ namespace snapper string name() const { return Name_C; } + void setName(const string& name) { AsciiFile::Name_C = name; } + void reload(); bool save(); @@ -80,13 +82,14 @@ namespace snapper protected: - const string Name_C; - const bool remove_empty; - vector Lines_C; - }; + private: + string Name_C; + bool remove_empty; + + }; class SysconfigFile : protected AsciiFile @@ -103,6 +106,8 @@ namespace snapper SysconfigFile(const string& name) : AsciiFile(name), modified(false) {} virtual ~SysconfigFile() { if (modified) save(); } + void setName(const string& name) { AsciiFile::setName(name); } + void save(); virtual void checkKey(const string& key) const; @@ -110,6 +115,7 @@ namespace snapper virtual void setValue(const string& key, bool value); bool getValue(const string& key, bool& value) const; + virtual void setValue(const string& key, const char* value); virtual void setValue(const string& key, const string& value); bool getValue(const string& key, string& value) const;