122 lines
2.6 KiB
C++
122 lines
2.6 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TGGiSlibStorage 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TGGiSlibStorage 声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _TGGISLIBSTORAGE_H_
|
|
#define _TGGISLIBSTORAGE_H_
|
|
|
|
#ifndef _TDPTRLIST_H_
|
|
#include "TDPtrList.h"
|
|
#endif
|
|
|
|
#ifndef _TACSTRING_H_
|
|
#include "TACString.h"
|
|
#endif
|
|
|
|
#ifndef _TWCSTRING_H_
|
|
#include "TWCString.h"
|
|
#endif
|
|
|
|
#if (ADS < 17)
|
|
#include "ios.h"
|
|
#endif
|
|
|
|
#if (ADS > 15)
|
|
#include <fstream>
|
|
#else
|
|
#include <fstream.h>
|
|
#endif
|
|
|
|
#include "TGGiStreamFile.h"
|
|
|
|
using namespace TchGeLib;
|
|
|
|
class GEOAPI TGGiSlibStorage
|
|
{
|
|
friend class DlgSlbMan;
|
|
public:
|
|
|
|
TGGiSlibStorage(const TCHAR *fname, const TCHAR *ext = SLD_EXT, const TCHAR *t = SLB_TITLE, int opMode = (_ios::in | _ios::out | _ios::binary));
|
|
|
|
virtual ~TGGiSlibStorage();
|
|
//拷贝第 n 个记录到磁盘文件
|
|
virtual int Copy(int n, const TCHAR *sldfile);
|
|
|
|
virtual int QuickCopy(const TCHAR *sldfile);
|
|
|
|
// 往库文件添加一个记录
|
|
virtual int Append(const TCHAR *sldfile, const TCHAR *szEntryName = NULL);
|
|
|
|
//移第 n 个记录到磁盘文件
|
|
virtual int Move(int n, const TCHAR *sldfile);
|
|
|
|
int operator !();
|
|
|
|
int Open(const TCHAR *file = NULL, int mode = (_ios::in | _ios::out | _ios::binary));
|
|
|
|
// 文件打开状态可用
|
|
//取得库文件的第 n 个记录
|
|
int GetRecord(int n, STCatalogue *rec);
|
|
|
|
//取得所有幻灯列表
|
|
int GetAll(TDPtrList<TCHAR> &res);
|
|
int GetAll(TDPtrList<STCatalogue> &res);
|
|
|
|
//取得记录的个数
|
|
int Length();
|
|
|
|
// 判断一记录在库文件里是否存在
|
|
int IsExist(const TCHAR *sldname, int *index);
|
|
|
|
// 删除库文件第 n 个记录
|
|
int Remove(int n);
|
|
int Remove(const TCHAR *sld);
|
|
|
|
//改第 n 个记录的名称
|
|
int Rename(int n, const TCHAR *sldfile);
|
|
|
|
void Close();
|
|
|
|
char * ReadItem(const TCHAR *szItemName, unsigned *nLen);
|
|
|
|
protected:
|
|
|
|
enum FileOperation
|
|
{
|
|
File_Add,
|
|
File_Del,
|
|
File_Copy,
|
|
File_Move
|
|
};
|
|
|
|
int MoveFilePtr(int n); //把文件指针移到第 n 个记录的起始
|
|
|
|
// 必须以读或写方式打开
|
|
int MainTain(const TCHAR *sldname, FileOperation opr, const TCHAR *szItem = NULL);
|
|
|
|
int MoveOrCopy(int n, const TCHAR *sldfile, FileOperation opr);
|
|
|
|
protected:
|
|
|
|
#if (ADS>15)
|
|
std::fstream _libfile;
|
|
#else
|
|
fstream _libfile;
|
|
#endif
|
|
|
|
int openMode;
|
|
|
|
TCString slbfile;
|
|
TCString libExt, itemExt;
|
|
TACString title;
|
|
TGGiStreamFile* m_pStreamFile;
|
|
};
|
|
|
|
#endif
|