X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f905dc575e7fecaa80da130abb82d8c4370b095..637f467a0639bf942ebeb466d056fa339bfdbdee:/include/wx/fileconf.h diff --git a/include/wx/fileconf.h b/include/wx/fileconf.h index 88ffaf9dcc..4b4d1a470d 100644 --- a/include/wx/fileconf.h +++ b/include/wx/fileconf.h @@ -16,17 +16,30 @@ #ifndef _FILECONF_H #define _FILECONF_H +#ifdef __GNUG__ +#pragma interface "fileconf.h" +#endif + +// ---------------------------------------------------------------------------- +// compile options +// ---------------------------------------------------------------------------- + +// it won't compile without it anyhow +#ifndef USE_WXCONFIG + #error "Please define USE_WXCONFIG or remove fileconf.cpp from your makefile" +#endif // USE_WXCONFIG + // ---------------------------------------------------------------------------- // wxFileConfig // ---------------------------------------------------------------------------- /* - 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) @@ -105,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); @@ -128,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; } @@ -141,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: @@ -175,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 { @@ -209,7 +234,6 @@ public: void SetLine(LineList *pLine); }; -protected: class ConfigGroup { private: @@ -220,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 @@ -256,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