From: stephan b. <sg...@us...> - 2005-01-17 21:32:37
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17900/include/pclasses/Util Modified Files: Prefs.h Log Message: - Added some default ctors, for upcoming s11n support. - Fixed a potential mem leak in setStore(). Index: Prefs.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/Prefs.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Prefs.h 28 Dec 2004 23:02:13 -0000 1.3 +++ Prefs.h 17 Jan 2005 21:32:10 -0000 1.4 @@ -21,6 +21,8 @@ //! Entries consist of a value and a name. class Entry { public: + //! Default ctor needed for s11n... + Entry(); //! Constructs a new Entry. Entry(const std::string& name, const Variant& value) : _name(name), _value(value) {} @@ -35,7 +37,7 @@ //! Returns the value of this entry const Variant& value() { return _value; } - + //! Sets the value of this entry void setValue(const Variant& value) { _value = value; } @@ -50,11 +52,17 @@ //! Sections have a name and hold subsections and entries class Section { public: + //! Default ctor needed for s11n... + Section(); //! Constructs a new Section. - Section(const std::string& name); + explicit Section(const std::string& name); //! Destructor. - virtual ~Section(); +// dev note: stephan removed +// virtualness because this +// class has no virtual +// methods. + ~Section(); //! Returns the name of this section. const std::string& name() const {return _name;} @@ -72,6 +80,10 @@ Entry* entry(const std::string& name); //! Needs to be created with new + /** + Ownership of entry is + transfered to this object. + */ void addEntry(Entry* entry); //! removes all entries with name. @@ -80,10 +92,10 @@ //! Returns a list of subsections const std::list<Section*>& sections() const {return _sections;} - //! Finds section by name. Returns 0 if not found. + //! Finds section by name. Returns 0 if not found. Ownership does not change. Section* section(const std::string& name); - //! Needs to be created with new. + //! Needs to be created with new. This object takes ownership of section. void addSection(Section* section); //! removes all sections with name @@ -103,8 +115,18 @@ virtual void save() throw(P::IO::IOError); Section& root(); const Section& root() const; + /** + Ownership does not change by calling this + function. + */ PrefsStore* store(); const PrefsStore* store() const; + /** + Transfers ownership of store to this + object. If this object previously had a + store object associated with it, that + object IS DELETED. + */ void setStore(PrefsStore* store); private: |