97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TWDict 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TWDict 声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _TWDICT_H_
|
|
#define _TWDICT_H_
|
|
|
|
#ifndef _TWDICTITEM_H_
|
|
#include "TWDictItem.h"
|
|
#endif
|
|
|
|
#ifndef _TPDLIST_H_
|
|
#include "TPDList.h"
|
|
#endif
|
|
|
|
#ifndef _TWDICTPATH_H_
|
|
#include "TWDictPath.h"
|
|
#endif
|
|
|
|
class GEOAPI TWDict : public TWDictItem, public TPDList<TWDictItem>
|
|
{
|
|
public:
|
|
TWDict(const TCHAR* sName = NULL, const TCHAR *sDesc = NULL);
|
|
virtual ~TWDict();
|
|
|
|
virtual int GetType() const;
|
|
|
|
virtual void operator >> (CArchive &ar);
|
|
|
|
virtual void operator << (CArchive &ar);
|
|
|
|
virtual void CopyData(const TWDictItem &src);
|
|
|
|
//没找到则添加,路径被键占用返回NULL,path内容一般会改变!
|
|
TWDict* FindOrAddDict(TWDictPath &path);
|
|
|
|
TWDict* FindOrAddDict(const CString &sPath);
|
|
|
|
bool ReadFile(const TCHAR *sFile);
|
|
|
|
bool WriteFile(const TCHAR *sFile);
|
|
|
|
//如果名称重复返回false,且外部释放pNewItem!无论是否添加成功,GetCurPData()==*pNewItem!
|
|
bool AppendItem(TWDictItem *pNewItem);
|
|
|
|
//在父路径下添加,返回false时外部释放pNewItem!
|
|
bool AppendItem(const CString &sParentPath, TWDictItem *pNewItem);
|
|
|
|
bool SetValue(const CString &sPath, int value);
|
|
|
|
bool GetValue(const CString &sPath, int &value);
|
|
|
|
bool SetValue(const CString &sPath, bool value);
|
|
|
|
bool GetValue(const CString &sPath, bool &value);
|
|
|
|
bool SetValue(const CString &sPath, char value);
|
|
|
|
bool GetValue(const CString &sPath, char &value);
|
|
|
|
bool SetValue(const CString &sPath, long value);
|
|
|
|
bool GetValue(const CString &sPath, long &value);
|
|
|
|
bool SetValue(const CString &sPath, double value);
|
|
|
|
bool GetValue(const CString &sPath, double &value);
|
|
|
|
bool SetValue(const CString &sPath, unsigned int valude);
|
|
|
|
bool GetValue(const CString &sPath, unsigned int &value);
|
|
|
|
bool SetValue(const CString &sPath, const CString& value);
|
|
|
|
bool GetValue(const CString &sPath, CString &value);
|
|
|
|
//path内容一般会改变!
|
|
TWDictItem* FindItem(TWDictPath &path);
|
|
|
|
TWDictItem* FindItem(const CString &sPath);
|
|
|
|
//没找到则添加
|
|
TWDictItem* FindOrAddItem(const CString &sPath, int type);
|
|
virtual void saveToJson(WValue &v);
|
|
virtual void loadByJson(const WValue &v);
|
|
|
|
private:
|
|
TWDictItem* DynCreateItem(int type);
|
|
};
|
|
|
|
#endif |