X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd71293400b25ff967cd032b8e1998b403003890..aed8df383fa66e3b69aecb29e34815a0a518ce1d:/include/wx/fileconf.h?ds=sidebyside diff --git a/include/wx/fileconf.h b/include/wx/fileconf.h index 97c03c8ffa..4b4d1a470d 100644 --- a/include/wx/fileconf.h +++ b/include/wx/fileconf.h @@ -16,6 +16,10 @@ #ifndef _FILECONF_H #define _FILECONF_H +#ifdef __GNUG__ +#pragma interface "fileconf.h" +#endif + // ---------------------------------------------------------------------------- // compile options // ---------------------------------------------------------------------------- @@ -30,12 +34,12 @@ // ---------------------------------------------------------------------------- /* - wxFileConfig derives from base Config and implements file based config class, + wxFileConfig derives from base Config and implements file based config class, i.e. it uses ASCII disk files to store the information. These files are - alternatively called INI, .conf or .rc in the documentation. They are + alternatively called INI, .conf or .rc in the documentation. They are organized in groups or sections, which can nest (i.e. a group contains subgroups, which contain their own subgroups &c). Each group has some - number of entries, which are "key = value" pairs. More precisely, the format + number of entries, which are "key = value" pairs. More precisely, the format is: # comments are allowed after either ';' or '#' (Win/UNIX standard) @@ -114,11 +118,19 @@ public: virtual bool GetFirstEntry(wxString& str, long& lIndex); virtual bool GetNextEntry (wxString& str, long& lIndex); + virtual uint GetNumberOfEntries(bool bRecursive = FALSE) const; + virtual uint GetNumberOfGroups(bool bRecursive = FALSE) const; + + virtual bool HasGroup(const wxString& strName) const; + virtual bool HasEntry(const wxString& strName) const; + virtual bool Read(wxString *pstr, const char *szKey, const char *szDefault = 0) const; virtual const char *Read(const char *szKey, const char *szDefault = 0) const; virtual bool Read(long *pl, const char *szKey, long lDefault) const; + virtual long Read(const char *szKey, long lDefault) const + { return wxConfig::Read(szKey, lDefault); } virtual bool Write(const char *szKey, const char *szValue); virtual bool Write(const char *szKey, long lValue); virtual bool Flush(bool bCurrentOnly = FALSE); @@ -137,12 +149,14 @@ public: { public: // ctor - LineList(const wxString& str, LineList *pNext = NULL) : m_strLine(str) - { SetNext(pNext); } - - // + LineList(const wxString& str, LineList *pNext = NULL) : m_strLine(str) + { SetNext(pNext); SetPrev(NULL); } + + // LineList *Next() const { return m_pNext; } + LineList *Prev() const { return m_pPrev; } void SetNext(LineList *pNext) { m_pNext = pNext; } + void SetPrev(LineList *pPrev) { m_pPrev = pPrev; } // void SetText(const wxString& str) { m_strLine = str; } @@ -150,13 +164,15 @@ public: private: wxString m_strLine; // line contents - LineList *m_pNext; // next node + LineList *m_pNext, // next node + *m_pPrev; // previous one }; - + // functions to work with this list LineList *LineListAppend(const wxString& str); - LineList *LineListInsert(const wxString& str, - LineList *pLine); // NULL => Append() + LineList *LineListInsert(const wxString& str, + LineList *pLine); // NULL => Prepend() + void LineListRemove(LineList *pLine); bool LineListIsEmpty(); private: @@ -184,8 +200,8 @@ private: //protected: --- if wxFileConfig::ConfigEntry is not public, functions in // ConfigGroup such as Find/AddEntry can't return "ConfigEntry *" public: - WX_DEFINE_ARRAY(ConfigEntry *, ArrayEntries); - WX_DEFINE_ARRAY(ConfigGroup *, ArrayGroups); + WX_DEFINE_SORTED_ARRAY(ConfigEntry *, ArrayEntries); + WX_DEFINE_SORTED_ARRAY(ConfigGroup *, ArrayGroups); class ConfigEntry { @@ -218,7 +234,6 @@ public: void SetLine(LineList *pLine); }; -protected: class ConfigGroup { private: @@ -229,8 +244,8 @@ protected: wxString m_strName; // group's name bool m_bDirty; // if FALSE => all subgroups are not dirty LineList *m_pLine; // pointer to our line in the linked list - int m_nLastEntry, // last here means "last added" - m_nLastGroup; // + ConfigEntry *m_pLastEntry; // last entry of this group in the local file + ConfigGroup *m_pLastGroup; // last subgroup public: // ctor @@ -265,6 +280,11 @@ protected: void SetDirty(); void SetLine(LineList *pLine); + // the new entries in this subgroup will be inserted after the last subgroup + // or, if there is none, after the last entry + void SetLastEntry(ConfigEntry *pLastEntry) { m_pLastEntry = pLastEntry; } + void SetLastGroup(ConfigGroup *pLastGroup) { m_pLastGroup = pLastGroup; } + wxString GetFullName() const; // get the last line belonging to an entry/subgroup of this group