ConfigFile

Dependents:   ConfigFile_TestProgram StarBoardOrangeExpansion1 StarBoardOrangeExpansion2 Drive2ChoroQ ... more

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Sun Sep 12 07:53:10 2010 +0000
Parent:
3:7250e339328c
Child:
5:56d544b8e5c6
Commit message:

Changed in this revision

ConfigFile.cpp Show annotated file Show diff for this revision Revisions of this file
ConfigFile.h Show annotated file Show diff for this revision Revisions of this file
--- a/ConfigFile.cpp	Sun Sep 12 07:37:25 2010 +0000
+++ b/ConfigFile.cpp	Sun Sep 12 07:53:10 2010 +0000
@@ -250,7 +250,7 @@
     return true;
 }
 
-bool ConfigFile::write(char *file, FileFormat ff) {
+bool ConfigFile::write(char *file, char *header, FileFormat ff) {
     /*
      * Open the target file.
      */
@@ -279,6 +279,13 @@
     }
 
     /*
+     * Write the header.
+     */
+    if (header != NULL) {
+        fprintf(fp, "%s%s", header, newline);
+    }
+
+    /*
      * Write the data.
      */
     for (int i = 0; i < MAXCONFIG; i++) {
--- a/ConfigFile.h	Sun Sep 12 07:37:25 2010 +0000
+++ b/ConfigFile.h	Sun Sep 12 07:53:10 2010 +0000
@@ -19,12 +19,12 @@
      * Create a configuration file class.
      */
     ConfigFile();
-    
+
     /**
      * Destroy a configuration file class.
      */
     ~ConfigFile();
-    
+
     /**
      * Get a value for a key.
      *
@@ -34,7 +34,7 @@
      * @return A value or NULL.
      */
     bool getValue(char *key, char *value, size_t siz);
-    
+
     /**
      * Set a set of a key and value.
      *
@@ -44,7 +44,7 @@
      * @return True if it succeed.
      */
     bool setValue(char *key, char *value);
-    
+
     /**
      * Remove a config.
      *
@@ -53,35 +53,36 @@
      * @return True if it succeed.
      */
     bool remove(char *key);
-    
+
     /**
      * Remove all config.
      *
      * @return True if it succeed.
      */
     bool removeAll(void);
-    
+
     /**
      * Read from the target file.
      *
      * @param file A target file name.
      */
     bool read(char *file);
-    
+
     typedef enum {
         UNIX,
         MAC,
         DOS
     } FileFormat;
-    
+
     /**
      * Write from the target file.
      *
-     * @param file A target file name.
+     * @param file A pointer to a file name.
+     * @param header A pointer to a header.
      * @param ff File format.
      */
-    bool write(char *file, FileFormat ff = UNIX);
-    
+    bool write(char *file, char *header = NULL, FileFormat ff = UNIX);
+
     /**
      * Output for debugging.
      *