Tezzeret  1
Tezzeret
GmCfgFile.hpp
1 #ifndef GMCFGFILE_HPP_
2 #define GMCFGFILE_HPP_
3 
4 #define MAX_APP_PATH_LN 32
5 #define MAX_GEO_CFG_PATH_LN MAX_APP_PATH_LN
6 #define MAX_GEO_DATA_PATH_LN MAX_APP_PATH_LN
7 
8 #define GM_CONFIG_OK 0
9 #define GM_CONFIG_FAIL 1
10 #define GM_CONFIG_BAD_FILE 2
11 #define GM_CONFIG_BAD_FILE_ENTRY 3
12 #define GM_CONFIG_MISSING_ENTRY 4
13 #define GM_CONFIG_NOT_FOUND 5
14 #define GM_CONFIG_INVALID_PARAMS 6
15 #define GM_CONFIG_NO_MEMORY 7
16 
17 namespace Geometrics
18 {
19  // Simple config files - string key/value
21  {
22  public:
23  GmConfigFile ();
24  ~GmConfigFile ();
25 
26  virtual int LoadConfigs () { return 0;};
27 
28 
29  #if (GEO_SDCARD == GEO_TRUE)||(GEO_USB_STORAGE == GEO_TRUE)
30  static int LoadConfigsFromFile (const char *szConfigFileName);
31 
32  static int CountLines (const char *szConfigFileName,
33  int *piLineCount);
34  static int LoadAllStrings (const char *szConfigFileName,
35  char ***pppcListOfStrings,
36  int iExtrasToAllocate,
37  int *piLineCount,
38  int *piAllocated);
39 
40  static int SaveAllStrings (const char *szConfigFileName,
41  char **pppcListOfStrings,
42  int iExtrasToAllocate,
43  int iCountStrings);
44 
45  static int GetConfigString (char *dest,
46  const char *key,
47  const char *szConfigFileName,
48  const int iBufferSize,
49  int *iCharsCopied);
50  static int SetConfigString (const char *key,
51  const char *value,
52  const char *szConfigFileName);
53 
54  /************************************************************
55  * Get SingleString and SetSingleString are for config files
56  * that only have one value, and no key, i.e. special, single
57  * use files. This is for performance purposes.
58  ***********************************************************/
59  static int GetSingleString (char *dest,
60  const char *szConfigFileName,
61  const int iBufferSize,
62  int *iCharsCopied);
63  static int SetSingleString (const char *value,
64  const char *szConfigFileName);
65  static int GetConfigInt32 (Int32 *iDest,
66  const char *szKey,
67  const char *szConfigFileName);
68  static int GetSingleInt32 (Int32 *iDest,
69  const char *szConfigFileName);
70  static int GetConfigUint32 (uint32_t *iDest,
71  const char *szKey,
72  const char *szConfigFileName);
73 
74 // static int ResetConfig ();
75 // static int SetStartupConfigFile (char *szConfigFileName);
76  static int SaveConfigsToFile (char **ppcStrings,
77  int iConfigCount,
78  char *szConfigFileName);
79  static int GetStrConfigValue(char* szKey,
80  char** ppcValue);
81  static int SetStrConfigValue(char* szKey,
82  char* szValue);
83 
84 #endif
85  static void DeleteListOfStrings (char **ppcListOfStrings,
86  int iListSize);
87 
88  protected:
89  static int SetValue (const char *strKey,
90  const char *strValue,
91  char **ppcStrings,
92  int iStringCount);
93 
94  //virtual int IsFileStorage() { return FALSE; };
95  virtual int IsDataStorage () { return FALSE; };
96 
97  };
98 }
99 #endif
Definition: GmCfgFile.hpp:21
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47