parse.h
来自「CxxTester是一个用于C++代码的通用测试框。它支持测试库系统、有一套方法」· C头文件 代码 · 共 133 行
H
133 行
//---------------------------------------------------------------------//// COPYRIGHT(C) 1997 //// //// Parse.h //// //// this file contains the declaration of the classes Parse, ParseOut // // and CxxCall. Parse contains the test handling, ParseOut the trace //// handling. CxxCall is a helper class, which attaches the testdriver //// to the framework. ////---------------------------------------------------------------------//#ifndef Parse_h#define Parse_h 1#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include "DataMap.h"class AdaptIO;//---------------------------------------------------------------------//// macros in order to beautify some of the interface functions ////---------------------------------------------------------------------//#define DIN Parse::getInStore()[0]#define DOUT Parse::getOutStore()#define DINOUT(func) ParseOut _parseOut((func))#define DTRACE if(_parseOut.getStore()) (*(_parseOut.getStore())) #define DOPEN(r,f) Parse::readLoop((r),(f))#define DCLOSE() Parse::closeLoop()extern void yyrestart(AdaptIO*);extern void deleteBuffer();extern int yyparse(void);extern int cxxloop(int,char**);typedef void (*FuncPtr)();//---------------------------------------------------------------------//// this class keeps all informations which occur during the parsing of //// a testscript. Parse is the interface between parser and calculation ////---------------------------------------------------------------------//class Parse{ public: static int hasCallback(); // query for callback // static DataMap& getCache(); // access to ext. tests // static DataMap& getOutStore(); // access to return data // static DataMap* getInStore(); // access to input data // static DataMap* getVerStore(); // access to verify array // static AdaptIO& getIO(); // access to io device // static char* getFilterName(); // access to filter name // static void clearInStore(); // deletes input data // static void clearVerStore(); // deletes verify data // static int verData(int,DataMap&); // verifies current test // static int startEvent(); // starts callback method // static int getErrLine(); // read access to errpos // static int getErrPos(); // read access to errpos // static char* getLastOutFile(); // access to logfile // static char* getErrString(); // access to errMessage // static void setErrLine(int); // write access to errpos // static void setErrPos(int); // write access to errpos // static void setLastOutFile(char*); // write access to logfile // static void setErrString(char*); // write access to errMess // static void addToGlobals(DataMap&);// writes dsouts to global // static int readLoop(char*,char*); // read access to testcase // static int closeLoop(); // testcase evaluation // static int adjustLine(int,int); // consider win-endofline // static int parseLoop(char*,char*,int(*)()); // callback loop // private: static int (*callBack)(); // pointer to testmethod // static DataMap outStore; // resulting data // static DataMap inStore[20]; // input data // static DataMap verStore[20]; // verifying data // static DataMap cachedExts; // cached ext.tests // static time_t cacheTime; // last cache update time // static char cachedFile[C_strln]; // cached input file name // static char outFileName[C_strln]; // to specify outputfile // static char filterName[C_strln]; // to specify read block // static char errString[C_strln]; // to specify errMessage // static int verifyResult; // result of verification // static int errLine; // line with err occurence // static int errPos; // pos with err occurence // static int pState; // stores parsing state //};//---------------------------------------------------------------------//// this class supports the tracing functionality of the testframework //// and is responsible for creation and output of the trace data. ////---------------------------------------------------------------------//class ParseOut{ public: ~ParseOut(); ParseOut(char*); DataMap* getStore(); // access to locStore // static void brkTraceExec(char*); // breaks tracing at once // static void setTraceDepth(int); // tracedepth write access // static void setTraceRoot(char*); // traceroot write access // static int getTraceDepth(); // tracedepth read access // static char* getTraceRoot(); // trace root read access // static void smartDelete(DataMap*);// cleanup of tracestorage // static void smartOut(AdaptIO&,DataMap*,int);//display method // private: static int traceDepth; // local stack depth // static char traceRoot[C_strln]; // name of root method // static DataMap* topStore; // topmost stack element // static DataMap* ptrStore; // active stack element // DataMap* locStore; // local stack element //};//---------------------------------------------------------------------//// the class attaches custom testfunctions to the testframework. this //// is realized in the constructor which feeds a string->function map. ////---------------------------------------------------------------------//class CxxCall{ public: ~CxxCall(); // deletes allocated memory // CxxCall(char*,FuncPtr); // adds new function entry // static FuncPtr getFunc(char* n=0); // maps string to function // private: static DataMap* funcMap; // storage of function map // static int ctr; // CxxCall instancecounter //};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?