1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //-----------------------------------------------------------------------------
- //
- // Copyright (c) 2005,珠海友通科技有限公司——通用型DROC
- // All rights reserved.
- //
- // 文件名称:AppSettings.h
- // 文件标识:见配置管理计划书.
- // 摘 要:
- //
- // 当前版本:0.1
- // 作 者:胡昌红
- // 完成日期:2005-3-5 16:36:02
- //
- // 取代版本:
- // 原 作 者:
- // 完成日期:
- //
- //-----------------------------------------------------------------------------
- #pragma once
- //-----------------------------------------------------------------------------
- #include "Markup.h"
- #include <vector>
- using namespace std;
- //-----------------------------------------------------------------------------
- //
- // 该类处理结构如下描述的 XML 文档中的数据.
- // 包括对 <Data key=" ", value=" " /> 结点的 添加、修改、保存.
- // 以及对其 value 值的修改.
- // 同时还包括将所有的 key、value 以 DATA 结构的方式读入向量.
- //
- // <?xml version="1.0" encoding="utf-8" ?>
- // <AppSetting>
- // <Data key="SKULL" value="SKULL" />
- // <Data key="CSPINE" value="CSPINE" />
- // ……
- // </AppSetting>
- //
- // 其中,以其他字符串替换 XML 结构的关键字 AppSetting 和 Data , 不会影响程序的运行.
- // 但是,为了保持 所有 XML 文档结构的一致性,建议不要替换.
- //
- //-----------------------------------------------------------------------------
- class CAppSettings
- {
- public:
- CAppSettings(void);
- CAppSettings(const CString &strFileName);
- virtual ~CAppSettings(void);
-
- public:
- bool Load(const CString &strFileName);
- bool GetAllDataToVector(void);
- CString operator [](const CString &strKey) const;
- CString GetValue(const CString &strKey) const;
- CString GetValueByKey(const CString &strKey) const;
- bool SetValue(const CString &strKey, const CString &strValue) const;
- bool AddItem(const CString &strKey, const CString &strValue) const;
- bool DeleteItem(const CString &strKey) const;
- bool Save(const CString &strFileName);
- public:
- typedef struct tagData
- {
- CString key;
- CString value;
- }DATA;
- vector<DATA> vecData;
- protected:
- CMarkup *m_XmlMarkup;
- };
|