datamap.h
来自「CxxTester是一个用于C++代码的通用测试框。它支持测试库系统、有一套方法」· C头文件 代码 · 共 145 行
H
145 行
//---------------------------------------------------------------------//// COPYRIGHT(C) 2002 //// DataMap.h //// //// this file contains the declaration of the classes StoreCv, StoreEl //// and DataMap.the classes are used for encoding and decoding standard //// C++ datatypes in a container with string oriented access methods. ////---------------------------------------------------------------------//#ifndef DataMap_h#define DataMap_h 1#include "ATree.h"#define EOS "\n"#define LOCK() ;#define UNLOCK() ;class DataMap;class AdaptIO;//---------------------------------------------------------------------//// maximal and initial length of names in a DataMap object ////---------------------------------------------------------------------//#define C_strln 500#define C_iniln 40#define DS_NUL 0#define DS_INT 1#define DS_DBL 2#define DS_STR 3class StoreCv;//---------------------------------------------------------------------//// helper class for DataMap ////---------------------------------------------------------------------//class StoreEl: public LOCAL_DAT{ friend class DataMap; public: ~StoreEl(); // used for memory cleanup // StoreEl(char*,int); // constructor for int element // StoreEl(char*,double); // constructor for double element // StoreEl(char*,const char*); // constructor for string element // void setMark(); // activates verify mark // void clearMark(); // deletes verify mark // int getMark(); // access to verify mark // void setType(int); // reseting the elementary type // void setData(void*,int); // reseting the elements value // int getType() const; // read access to elementary type // int getLen() const; // read access to the data size // char *getName() const; // read access to elements name // void *getData() const; // read access to elements value // StoreEl *getNext() const; // read access to the next element // void setNext(StoreEl*); // write access to next element // void *operator new(size_t); // allocation of new Element // void operator delete(void*,size_t); // deletion of an element // private: static StoreEl* start; // end of current memory block // static StoreEl* end; // start of current memory block // static StoreEl* list; // allocated memory blocks // static int ctr; // counter of instantiated objects // int type; // elements type // int currln; // actual value for data // StoreEl *next; // pointer to next element // char inimem[C_iniln]; // initial storage for data // char ininame[C_iniln]; // initial storage for name // char *name; // elements name // char *data; // elements data in binary format // char mark; // for verify optimization //};//---------------------------------------------------------------------//// container class for StoreEl ////---------------------------------------------------------------------//class DataMap: public AVL_TREE{ public: DataMap(); // inits empty container // ~DataMap(); // frees containers mem // DataMap(const StoreCv&); // inits selective elements // StoreCv operator [] (char*); // elementary access // DataMap& operator = (const DataMap&); // complete assignment // DataMap& operator = (const StoreCv&); // partial assignment // void clear(); // erasing of contents // int differ(AdaptIO&,DataMap&,int); // compare two DataMaps // char* getName() const; // returning of ds name // void setName(char*); // definition of name // int getType(char*) const; // containerelements type // public: void appElem(StoreEl*); // internal appending // int hasPrefix(char*) const; // searches similar prenames// StoreEl *getData(char* = 0) const; // complete, partial access // int compare(LOCAL_DAT*, LOCAL_DAT*) const; // used for sorting // private: char name[C_strln]; // global datastore name // StoreEl *start; // first stored element // StoreEl *end; // last stored element //};//---------------------------------------------------------------------//// interface class to DataMap data ////---------------------------------------------------------------------//class StoreCv{ public: StoreCv(DataMap*,char*); // used for element access // ~StoreCv(); // used for unlock handling // operator int(); // conversion to int // operator double(); // conversion to double // operator char*(); // conversion to string // int getType() const; // read access to storage // char* getName() const; // read access to name // DataMap* getData() const; // read access to contents // StoreCv& operator = (int); // writes int to contents // StoreCv& operator = (double); // writes double to contents // StoreCv& operator = (const char*); // writes string to contents // StoreCv& operator = (const unsigned short*); // writes unicode // StoreCv& operator = (const DataMap&); // writes DataMap to cont. // StoreCv& operator = (const StoreCv&); // writes substore to cont. // StoreCv operator [] (char*); // structured access // StoreCv operator [] (int); // indexed access // private: char name[C_strln]; // name of selected element // DataMap *contents; // pointer to data container //};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?