01: /////////////////////////////////////////////////////////////////////////////

02: //Projectname         : 

03: //Filename                : UKIniAccess.h 

04: //Classname                : CUKPuzzleCore

05: //Author                : Ulrich Kraemer [uk]

06: //Date                        : 04.04.2003

07: //Changes                : 

08: //////////////////////////////////////////////////////////////////////////////

09: 
10: #ifndef UKINIACCESS_H
11: #define UKINIACCESS_H
12: 
13: #include "afxtempl.h"
14: 
15: typedef CArray<long,long> CLongArray;
16: 
17: class CUKIniAccess
18: {
19:         public:
20:                 CUKIniAccess(LPCTSTR strFileName="");
21:                 ~CUKIniAccess();
22: 
23:                 Init(LPCTSTR strFileName);
24:                 //no deinit rquired

25: 
26:                 //Common methodes

27:                 //at the moment only read is needed

28:                 BOOL        ReadValue(LPCTSTR szSection,LPCTSTR szKey,int* pValue);
29:                 BOOL        ReadValue(LPCTSTR szSection,LPCTSTR szKey,long* pValue);
30:                 BOOL        ReadValue(LPCTSTR szSection,LPCTSTR szKey,CString& rValue);
31: 
32:                 BOOL        ReadValue(LPCTSTR szSection,LPCTSTR szKey,CLongArray& rLongArray);
33: 
34:                 int                ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,int nDefValue);
35:                 long        ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,long nDefValue);
36:                 CString        ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,LPCTSTR szDefValue);
37: 
38:         private:
39:                 CString m_strFileName;
40: };
41: 
42: inline int CUKIniAccess::ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,int nDefValue)
43: {
44:         int nVal;
45:         if (!ReadValue(szSection,szKey,&nVal))
46:                 return nDefValue;
47:         return nVal;
48: }
49: inline long CUKIniAccess::ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,long nDefValue)
50: {
51:         long nVal;
52:         if (!ReadValue(szSection,szKey,&nVal))
53:                 return nDefValue;
54:         return nVal;
55: }
56: inline CString CUKIniAccess::ReadValueDef(LPCTSTR szSection,LPCTSTR szKey,LPCTSTR szDefValue)
57: {
58:         CString strValue;
59:         if (!ReadValue(szSection,szKey,strValue))
60:                 strValue=szDefValue;
61:         return strValue;
62: }
63: 
64: #endif