-
Notifications
You must be signed in to change notification settings - Fork 0
/
BCGXMLSettings.h
executable file
·157 lines (129 loc) · 4.78 KB
/
BCGXMLSettings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//////////////////////////////////////////////////////////////////////
// Calques 3D - a 3D Dynamic Geometry Learning Environment
// Copyright (c) 1997-2007 Nicolas Van Labeke
//////////////////////////////////////////////////////////////////////
// This file is part of Calques 3D.
//
// Calques 3D is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Calques 3D is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Calques 3D; if not, write to The Free Software Foundation, Inc.,
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//////////////////////////////////////////////////////////////////////
/// @file BCGXMLSettings.h
/// @brief interface for the CBCGXMLSettings and CBCGXMLNode classes.
///
///
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BCGXMLSETTINGS_H__290A1AF4_79E3_402D_BD32_7C8A4F8BBBE4__INCLUDED_)
#define AFX_BCGXMLSETTINGS_H__290A1AF4_79E3_402D_BD32_7C8A4F8BBBE4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXTEMPL_H__
#include "afxtempl.h"
#endif
#include "BCGPRegistry.h"
#define BCGXMLSETTINGS_PRIVATE 1
/////////////////////////////////////////////////////////////////////////////
/// CBCGXMLNode
/////////////////////////////////////////////////////////////////////////////
class CBCGXMLNode : public CObject
{
friend class CBCGXMLSettings;
public:
CBCGXMLNode()
{
m_pParent = NULL;
}
~CBCGXMLNode()
{
while (!m_lstChildren.IsEmpty ())
{
delete m_lstChildren.RemoveHead ();
}
}
CList<CBCGXMLNode*, CBCGXMLNode*> m_lstChildren;
CBCGXMLNode* m_pParent;
CString m_strName;
CString m_strValue;
CBCGXMLNode* FindChild (LPCTSTR lpszName) const
{
for (POSITION pos = m_lstChildren.GetHeadPosition (); pos != NULL;)
{
CBCGXMLNode* pNode = m_lstChildren.GetNext (pos);
ASSERT_VALID (pNode);
if (pNode->m_strName == lpszName)
{
return pNode;
}
}
return NULL;
}
void AddChild (CBCGXMLNode* pNode)
{
m_lstChildren.AddTail (pNode);
pNode->m_pParent = this;
}
int WriteToBuffer (CString& strBuffer, int iOffset);
BOOL ReadFromBuffer (CString& strBuffer);
};
/////////////////////////////////////////////////////////////////////////////
/// CBCGXMLSettings
/////////////////////////////////////////////////////////////////////////////
class CBCGXMLSettings : public CBCGPRegistry
{
DECLARE_DYNCREATE(CBCGXMLSettings)
public:
CBCGXMLSettings();
virtual ~CBCGXMLSettings();
// Attributes:
protected:
static CBCGXMLNode m_Local; // "LOCAL_MACHINE"
static CBCGXMLNode m_User; // "CURRENT_USER"
CBCGXMLNode* m_pCurrNode;
// Operations
public:
virtual CBCGXMLNode* GetTree () const;
static BOOL WriteXMLToFile (BOOL bIsLocalMachine, LPCTSTR lpszFileName);
static BOOL ReadXMLFromFile (BOOL bIsLocalMachine, LPCTSTR lpszFileName);
virtual BOOL ReadKeyValues(CStringArray& Values);
virtual BOOL VerifyKey (LPCTSTR pszPath);
virtual BOOL VerifyValue (LPCTSTR pszValue);
virtual BOOL CreateKey (LPCTSTR pszPath);
virtual BOOL Open (LPCTSTR pszPath);
virtual void Close();
virtual BOOL DeleteValue (LPCTSTR pszValue);
virtual BOOL DeleteKey (LPCTSTR pszPath, BOOL bAdmin = FALSE);
virtual BOOL Write (LPCTSTR pszKey, int iVal);
virtual BOOL Write (LPCTSTR pszKey, DWORD dwVal);
virtual BOOL Write (LPCTSTR pszKey, LPCTSTR pszVal);
virtual BOOL Write (LPCTSTR pszKey, CWordArray& wcArray);
virtual BOOL Write (LPCTSTR pszKey, const CRect& rect);
virtual BOOL Write (LPCTSTR pszKey, LPPOINT& lpPoint);
virtual BOOL Write (LPCTSTR pszKey, LPBYTE pData, UINT nBytes);
virtual BOOL Write (LPCTSTR pszKey, CObject& obj);
virtual BOOL Write (LPCTSTR pszKey, CObject* pObj);
virtual BOOL Read (LPCTSTR pszKey, int& iVal);
virtual BOOL Read (LPCTSTR pszKey, DWORD& dwVal);
virtual BOOL Read (LPCTSTR pszKey, CString& sVal);
virtual BOOL Read (LPCTSTR pszKey, CWordArray& wcArray);
virtual BOOL Read (LPCTSTR pszKey, LPPOINT& lpPoint);
virtual BOOL Read (LPCTSTR pszKey, CRect& rect);
virtual BOOL Read (LPCTSTR pszKey, BYTE** ppData, UINT* pBytes);
virtual BOOL Read (LPCTSTR pszKey, CObject& obj);
virtual BOOL Read (LPCTSTR pszKey, CObject*& pObj);
virtual BOOL ReadSubKeys(CStringArray& SubKeys);
protected:
BOOL WriteTag (LPCTSTR pszKey, LPCTSTR lpszBuffer);
LPCTSTR ReadTag (LPCTSTR pszKey) const;
};
#endif // !defined(AFX_BCGXMLSETTINGS_H__290A1AF4_79E3_402D_BD32_7C8A4F8BBBE4__INCLUDED_)