Update of /cvsroot/mahogany/M/include
In directory sc8-pr-cvs1:/tmp/cvs-serv13689/include

Modified Files:
        ConfigSource.h 
Log Message:
added Copy(); fixed some bugs in creation/destruction of config sources; added support 
for using file config by default under Windows

Index: ConfigSource.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/ConfigSource.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -u -2 -r1.6 -r1.7
--- ConfigSource.h      18 Sep 2003 16:30:39 -0000      1.6
+++ ConfigSource.h      27 Sep 2003 23:10:35 -0000      1.7
@@ -101,4 +101,5 @@
 
       @param filename the name of config file or empty
+      @param default config source to be DecRef()d by caller or NULL
     */
    static ConfigSource *CreateDefault(const String& filename);
@@ -112,4 +113,5 @@
       @param config the config containing the parameters
       @param name its section name, without the trailing slash
+      @param new config source to be DecRef()d by caller or NULL
     */
    static ConfigSource *Create(const ConfigSource& config, const String& name);
@@ -119,4 +121,23 @@
 
    /**
+      Copy contents of one config source to another.
+
+      By default this function copies everything from the source config to the
+      destination one, irrecoverably overwriting the old contents of the
+      destination.
+
+      @param configDst where to copy
+      @param configSrc what to copy
+      @param pathDst path under which we write in configDst (root by default)
+      @param pathSrc path where we start from in configSrc (root by default)
+      @return true if copy was successful, false otherwise
+    */
+   static bool Copy(ConfigSource& configDst,
+                    const ConfigSource& configSrc,
+                    const String& pathDst = _T(""),
+                    const String& pathSrc = _T(""));
+
+
+   /**
       @name Object description.
     */
@@ -266,6 +287,12 @@
    /**
       Copy the given entry (maybe to another group).
-    */
-   virtual bool CopyEntry(const String& nameSrc, const String& nameDst) = 0;
+
+      @param nameSrc the full name of the entry to copy
+      @param nameDst the full name to copy to (possibly in configDst)
+      @param configDst config object to copy to, if NULL, same as this one
+    */
+   virtual bool CopyEntry(const String& nameSrc,
+                          const String& nameDst,
+                          ConfigSource *configDst = NULL) = 0;
 
    /**
@@ -293,4 +320,5 @@
 };
 
+DECLARE_AUTOPTR(ConfigSource);
 
 /**
@@ -306,14 +334,40 @@
 public:
    /**
-      Create a local config source.
+      Create the default local config.
+
+      @sa ConfigSource::CreateDefault
+
+      @param filename the name of config file or empty to use the default one
+    */
+   static ConfigSourceLocal *CreateDefault(const String& filename = _T(""));
+
+   /**
+      Create the config source associated with the given file.
+
+      Unlike CreateDefault() above, this method never uses registry. Also, the
+      file name must not be empty here.
+    */
+   static ConfigSourceLocal *CreateFile(const String& filename,
+                                 const String& name = _T(""))
+      { return new ConfigSourceLocal(CreateFileConfig(filename), name); }
 
-      If the filename parameter is empty, the default location is used.
+#ifdef OS_WIN
+   /**
+      Create the registry config source.
+
+      This shouldn't be normally used explicitly, use CreateDefault() instead.
+    */
+   static ConfigSourceLocal *CreateRegistry()
+      { return new ConfigSourceLocal(CreateRegConfig(), _T("")); }
+#endif // OS_WIN
 
-      @sa ConfigSource::CreateDefault()
 
-      @param filename the name of config file or empty
+   /**
+      Create a local config source.
+
+      @param config wxConfig object this config source is associated with
       @param name the name for the ConfigSource object
     */
-   ConfigSourceLocal(const String& filename, const String& name = _T(""));
+   ConfigSourceLocal(wxConfigBase *config, const String& name);
    virtual ~ConfigSourceLocal();
 
@@ -336,5 +390,7 @@
    virtual bool DeleteEntry(const String& name);
    virtual bool DeleteGroup(const String& name);
-   virtual bool CopyEntry(const String& nameSrc, const String& nameDst);
+   virtual bool CopyEntry(const String& nameSrc,
+                          const String& nameDst,
+                          ConfigSource *configDst);
    virtual bool RenameGroup(const String& nameOld, const String& nameNew);
 
@@ -343,4 +399,14 @@
 
 private:
+#ifdef OS_WIN
+   // create wxRegConfig we use under Windows
+   static wxConfigBase *CreateRegConfig();
+#endif // OS_WIN
+
+   // create wxFileConfig
+   static wxConfigBase *CreateFileConfig(const String& fnameLocal,
+                                         const String& fnameGlobal = _T(""));
+
+
    // the config object we use
    wxConfigBase *m_config;



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to