Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cAppConfig.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cAppConfig_H
7 #define _INC_cAppConfig_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 #include "cAppRes.h"
12 #include "../WinAPI/cRegKeyX.h"
13 #include "../Variant/cVariant.h"
15 
16 namespace GrayLib
17 {
19  {
29 
30  protected:
32 #if defined(_WIN32)
33  cStringF m_sRegistryKey;
34  // bool m_bUsePrivateProfile; // This is just for Win16 compatibility.
35  // cRegKey m_RegBase; // Maybe LOCALMACHINE or CURRENTUSER.
36 #endif
39 
40  public:
41  cAppConfigX(cStringF sProfileName, cStringF sRegistryKey = "");
42 #ifdef _MFC_VER
43  cAppConfigX(CWinApp* pApp);
44 #endif
45  ~cAppConfigX();
46 
47 #if defined(_WIN32)
48  void SetRegistryKey(const IniChar_t* pszKey);
49  HRESULT GetOpenRegKey(OUT cRegKey& regSec, const FILECHAR_t* pszSection, bool bCreate = true);
50 #endif
51  HRESULT GetOpenIni(bool bCreate = true);
52  HRESULT FlushX();
53 
54  // Read/Get
55  HRESULT EnumConfig(const IniChar_t* pszSection, OUT cArrayString<IniChar_t>& rArray);
56  cString GetConfigStr(const IniChar_t* pszSection, const IniChar_t* pszEntry, const GChar_t* pszDefault = nullptr);
57  UINT GetConfigUInt(const IniChar_t* pszSection, const IniChar_t* pszEntry, int iDefault = 0);
58  bool GetConfigVar(const IniChar_t* pszSection, const IniChar_t* pszEntry, OUT cVariant& rvVal);
59 
60  // Write
61  bool WriteConfigStr(const IniChar_t* pszSection, const IniChar_t* pszEntry, const GChar_t* pszVal);
62  bool WriteConfigInt(const IniChar_t* pszSection, const IniChar_t* pszEntry, int iVal);
63  bool WriteConfigVar(const IniChar_t* pszSection, const IniChar_t* pszEntry, const cVariant& vVal);
64  };
65 
66 #if 0
67  class GRAYLIB_LINK cAppConfig
68  : public cSingletonStatic<cAppConfig>
69  , public cAppConfigX
70  {
74  public:
75  cAppConfig()
76  : cSingletonStatic<cAppConfig>(this)
77  , cAppConfigX("") // init later ?
78  {
79  }
80  };
81 #endif
82 
83 }
84 
85 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cWinApp.h:40
Definition: cAppConfig.h:19
bool m_bIniFileModified
If we are using the m_IniFile file vs the registry then we need to write it.
Definition: cAppConfig.h:38
cIniFile m_IniFile
Cached open INI file. (if we use it)
Definition: cAppConfig.h:37
cStringF m_sProfileName
The full path to the profile specific to this app. (or just "Appname" for a m_sRegistryKey )
Definition: cAppConfig.h:31
Definition: cVariant.h:26
Definition: cArrayString.h:19
Definition: cIniFile.h:22
Definition: cSingleton.h:30
Definition: cMesh.h:22
char IniChar_t
char format even on UNICODE system! Screw M$, INI files should ALWAYS have UTF8 contents
Definition: cIniBase.h:17
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26