+static wxString FilterInValue(const wxString& str);
+static wxString FilterOutValue(const wxString& str);
+
+static wxString FilterInEntryName(const wxString& str);
+static wxString FilterOutEntryName(const wxString& str);
+
+// get the name to use in wxFileConfig ctor
+static wxString GetAppName(const wxString& appname);
+
+// ============================================================================
+// private classes
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// "template" array types
+// ----------------------------------------------------------------------------
+
+#ifdef WXMAKINGDLL_BASE
+ WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(wxFileConfigEntry *, ArrayEntries,
+ WXDLLIMPEXP_BASE);
+ WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(wxFileConfigGroup *, ArrayGroups,
+ WXDLLIMPEXP_BASE);
+#else
+ WX_DEFINE_SORTED_ARRAY(wxFileConfigEntry *, ArrayEntries);
+ WX_DEFINE_SORTED_ARRAY(wxFileConfigGroup *, ArrayGroups);
+#endif
+
+// ----------------------------------------------------------------------------
+// wxFileConfigLineList
+// ----------------------------------------------------------------------------
+
+// we store all lines of the local config file as a linked list in memory
+class wxFileConfigLineList
+{
+public:
+ void SetNext(wxFileConfigLineList *pNext) { m_pNext = pNext; }
+ void SetPrev(wxFileConfigLineList *pPrev) { m_pPrev = pPrev; }
+
+ // ctor
+ wxFileConfigLineList(const wxString& str,
+ wxFileConfigLineList *pNext = NULL) : m_strLine(str)
+ { SetNext(pNext); SetPrev(NULL); }
+
+ // next/prev nodes in the linked list
+ wxFileConfigLineList *Next() const { return m_pNext; }
+ wxFileConfigLineList *Prev() const { return m_pPrev; }
+
+ // get/change lines text
+ void SetText(const wxString& str) { m_strLine = str; }
+ const wxString& Text() const { return m_strLine; }
+
+private:
+ wxString m_strLine; // line contents
+ wxFileConfigLineList *m_pNext, // next node
+ *m_pPrev; // previous one
+
+ DECLARE_NO_COPY_CLASS(wxFileConfigLineList)
+};
+
+// ----------------------------------------------------------------------------
+// wxFileConfigEntry: a name/value pair
+// ----------------------------------------------------------------------------
+
+class wxFileConfigEntry
+{
+private:
+ wxFileConfigGroup *m_pParent; // group that contains us
+
+ wxString m_strName, // entry name
+ m_strValue; // value
+ bool m_bDirty:1, // changed since last read?
+ m_bImmutable:1, // can be overriden locally?
+ m_bHasValue:1; // set after first call to SetValue()
+
+ int m_nLine; // used if m_pLine == NULL only
+
+ // pointer to our line in the linked list or NULL if it was found in global
+ // file (which we don't modify)
+ wxFileConfigLineList *m_pLine;
+
+public:
+ wxFileConfigEntry(wxFileConfigGroup *pParent,
+ const wxString& strName, int nLine);
+
+ // simple accessors
+ const wxString& Name() const { return m_strName; }
+ const wxString& Value() const { return m_strValue; }
+ wxFileConfigGroup *Group() const { return m_pParent; }
+ bool IsDirty() const { return m_bDirty; }
+ bool IsImmutable() const { return m_bImmutable; }
+ bool IsLocal() const { return m_pLine != 0; }
+ int Line() const { return m_nLine; }
+ wxFileConfigLineList *
+ GetLine() const { return m_pLine; }
+
+ // modify entry attributes
+ void SetValue(const wxString& strValue, bool bUser = TRUE);
+ void SetDirty();
+ void SetLine(wxFileConfigLineList *pLine);
+
+ DECLARE_NO_COPY_CLASS(wxFileConfigEntry)
+};
+
+// ----------------------------------------------------------------------------
+// wxFileConfigGroup: container of entries and other groups
+// ----------------------------------------------------------------------------
+
+class wxFileConfigGroup
+{
+private:
+ wxFileConfig *m_pConfig; // config object we belong to
+ wxFileConfigGroup *m_pParent; // parent group (NULL for root group)
+ ArrayEntries m_aEntries; // entries in this group
+ ArrayGroups m_aSubgroups; // subgroups
+ wxString m_strName; // group's name
+ bool m_bDirty; // if FALSE => all subgroups are not dirty
+ wxFileConfigLineList *m_pLine; // pointer to our line in the linked list
+ wxFileConfigEntry *m_pLastEntry; // last entry/subgroup of this group in the
+ wxFileConfigGroup *m_pLastGroup; // local file (we insert new ones after it)
+
+ // DeleteSubgroupByName helper
+ bool DeleteSubgroup(wxFileConfigGroup *pGroup);
+
+public:
+ // ctor
+ wxFileConfigGroup(wxFileConfigGroup *pParent, const wxString& strName, wxFileConfig *);
+
+ // dtor deletes all entries and subgroups also
+ ~wxFileConfigGroup();
+
+ // simple accessors
+ const wxString& Name() const { return m_strName; }
+ wxFileConfigGroup *Parent() const { return m_pParent; }
+ wxFileConfig *Config() const { return m_pConfig; }
+ bool IsDirty() const { return m_bDirty; }
+
+ const ArrayEntries& Entries() const { return m_aEntries; }
+ const ArrayGroups& Groups() const { return m_aSubgroups; }
+ bool IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); }
+
+ // find entry/subgroup (NULL if not found)
+ wxFileConfigGroup *FindSubgroup(const wxChar *szName) const;
+ wxFileConfigEntry *FindEntry (const wxChar *szName) const;
+
+ // delete entry/subgroup, return FALSE if doesn't exist
+ bool DeleteSubgroupByName(const wxChar *szName);
+ bool DeleteEntry(const wxChar *szName);
+
+ // create new entry/subgroup returning pointer to newly created element
+ wxFileConfigGroup *AddSubgroup(const wxString& strName);
+ wxFileConfigEntry *AddEntry (const wxString& strName, int nLine = wxNOT_FOUND);
+
+ // will also recursively set parent's dirty flag
+ void SetDirty();
+ void SetLine(wxFileConfigLineList *pLine);
+
+ // rename: no checks are done to ensure that the name is unique!
+ void Rename(const wxString& newName);
+
+ //
+ wxString GetFullName() const;
+
+ // get the last line belonging to an entry/subgroup of this group
+ wxFileConfigLineList *GetGroupLine(); // line which contains [group]
+ wxFileConfigLineList *GetLastEntryLine(); // after which our subgroups start
+ wxFileConfigLineList *GetLastGroupLine(); // after which the next group starts
+
+ // called by entries/subgroups when they're created/deleted
+ void SetLastEntry(wxFileConfigEntry *pEntry);
+ void SetLastGroup(wxFileConfigGroup *pGroup)
+ { m_pLastGroup = pGroup; }
+
+ DECLARE_NO_COPY_CLASS(wxFileConfigGroup)
+};