📄 expr.tex
字号:
Returns the floating point value of the expression.\membersection{wxExpr::SetClientData}\label{wxexprsetclientdata}\func{void}{SetClientData}{\param{wxObject *}{data}}Associate arbitrary data with this clause. This can be useful whenreading in data for storing a pointer to the C++ object, so when anotherclause makes a reference to this clause, its C++ object can be retrieved.See \helpref{wxExpr::GetClientData}{wxexprgetclientdata}.\membersection{wxExpr::StringValue}\label{wxexprstringvalue}\constfunc{wxString}{StringValue}{\void}Returns the string value of the expression.\membersection{wxExpr::Type}\label{wxexprtype}\constfunc{wxExprType}{Type}{\void}Returns the type of the expression. {\bf wxExprType} is defined as follows:\begin{verbatim}typedef enum { wxExprNull, wxExprInteger, wxExprReal, wxExprWord, wxExprString, wxExprList} wxExprType;\end{verbatim}\membersection{wxExpr::WordValue}\label{wxexprwordvalue}\constfunc{wxString}{WordValue}{\void}Returns the word value of the expression.\membersection{wxExpr::WriteClause}\label{wxexprwriteprologclause}\func{void}{WriteClause}{\param{FILE *}{ stream}}Writes the clause to the given stream in Prolog format. Not normally needed, sincethe whole {\bf wxExprDatabase} will usually be written at once. The format is:functor, open parenthesis, list of comma-separated expressions, close parenthesis,full stop.\membersection{wxExpr::WriteExpr}\label{wxexprwriteexpr}\func{void}{WriteExpr}{\param{FILE *}{ stream}}Writes the expression (not clause) to the given stream in Prologformat. Not normally needed, since the whole {\bf wxExprDatabase} willusually be written at once. Lists are written in square bracketed,comma-delimited format.\membersection{Functions and macros}Below are miscellaneous functions and macros associated with wxExpr objects.\func{bool}{wxExprIsFunctor}{\param{wxExpr *}{expr}, \param{const wxString\&}{ functor}}Checks that the functor of {\it expr} is {\it functor}.\func{void}{wxExprCleanUp}{\void}Cleans up the wxExpr system (YACC/LEX buffers) to avoid memory-checking warnings as the program exits.\begin{verbatim}#define wxMakeInteger(x) (new wxExpr((long)x))#define wxMakeReal(x) (new wxExpr((float)x))#define wxMakeString(x) (new wxExpr(PrologString, x))#define wxMakeWord(x) (new wxExpr(PrologWord, x))#define wxMake(x) (new wxExpr(x))\end{verbatim}Macros to help make wxExpr objects.\section{\class{wxExprDatabase}}\label{wxexprdatabase}The {\bf wxExprDatabase} class represents a database, or list,of Prolog-like expressions. Instances of this class are used for reading,writing and creating data files.\wxheading{Derived from}\helpref{wxList}{wxlist}\\\helpref{wxObject}{wxobject}\wxheading{See also}\helpref{wxExpr overview}{exproverview}, \helpref{wxExpr}{wxexpr}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxExprDatabase::wxExprDatabase}\label{wxexprdatabaseconstr}\func{void}{wxExprDatabase}{\param{proioErrorHandler}{ handler = 0}}Construct a new, unhashed database, with an optional error handler. Theerror handler must be a function returning a bool and taking an integer and a stringargument. When an error occurs when reading or writing a database, this function iscalled. The error is given as the first argument (currently one of WXEXPR\_ERROR\_GENERAL,WXEXPR\_ERROR\_SYNTAX) and an error message is given as the second argument. If falseis returned by the error handler, processing of the wxExpr operation stops.Another way of handling errors is simply to call \helpref{wxExprDatabase::GetErrorCount}{wxexprdatabasegeterrorcount} afterthe operation, to check whether errors have occurred, instead of installing an error handler.If the error count is more than zero, \helpref{wxExprDatabase::Write}{wxexprdatabasewrite} and\rtfsp\helpref{wxExprDatabase::Read}{wxexprdatabaseread} will return false tothe application.For example:\begin{verbatim}bool myErrorHandler(int err, chat *msg){ if (err == WXEXPR_ERROR_SYNTAX) { wxMessageBox(msg, "Syntax error"); } return false;}wxExprDatabase database(myErrorHandler);\end{verbatim}\func{}{wxExprDatabase}{\param{wxExprType}{ type}, \param{const wxString\&}{attribute},\rtfsp\param{int}{ size = 500}, \param{proioErrorHandler}{ handler = 0}}Construct a new database hashed on a combination of the clause functor anda named attribute (often an integer identification).See above for an explanation of the error handler.\membersection{wxExprDatabase::\destruct{wxExprDatabase}}\func{}{\destruct{wxExprDatabase}}{\void}Delete the database and contents.\membersection{wxExprDatabase::Append}\label{wxexprdatabaseappend}\func{void}{Append}{\param{wxExpr* }{clause}}Append a clause to the end of the database. If the database is hashing,the functor and a user-specified attribute will be hashed upon, giving theoption of random access in addition to linear traversal of the database.\membersection{wxExprDatabase::BeginFind}\label{wxexprdatabasebeginfind}\func{void}{BeginFind}{\void}Reset the current position to the start of the database. Subsequent\rtfsp\helpref{wxExprDatabase::FindClause}{wxexprdatabasefindclause} calls will move the pointer.\membersection{wxExprDatabase::ClearDatabase}\label{wxexprdatabasecleardatabase}\func{void}{ClearDatabase}{\void}Clears the contents of the database.\membersection{wxExprDatabase::FindClause}\label{wxexprdatabasefindclause}Various ways of retrieving clauses from the database. A returnvalue of NULL indicates no (more) clauses matching the given criteria.Calling the functions repeatedly retrieves more matching clauses, if any.\func{wxExpr* }{FindClause}{\param{long}{ id}}Find a clause based on the special ``id'' attribute.\func{wxExpr* }{FindClause}{\param{const wxString\&}{ attribute}, \param{const wxString\&}{ value}}Find a clause which has the given attribute set to the given string or word value.\func{wxExpr*}{FindClause}{\param{const wxString\&}{ attribute}, \param{long}{ value}}Find a clause which has the given attribute set to the given integer value.\func{wxExpr*}{FindClause}{\param{const wxString\&}{ attribute}, \param{float}{ value}}Find a clause which has the given attribute set to the given floating point value.\membersection{wxExprDatabase::FindClauseByFunctor}\label{wxexprdatabasefindclausebyfunctor}\func{wxExpr*}{FindClauseByFunctor}{\param{const wxString\&}{ functor}}Find the next clause with the specified functor.\membersection{wxExprDatabase::GetErrorCount}\label{wxexprdatabasegeterrorcount}\constfunc{int}{GetErrorCount}{\void}Returns the number of errors encountered during the last read or write operation.\membersection{wxExprDatabase::HashFind}\label{wxexprdatabasehashfind}\constfunc{wxExpr*}{HashFind}{\param{const wxString\&}{ functor}, \param{long}{ value}}Finds the clause with the given functor and with the attribute specifiedin the database constructor having the given integer value.For example,\begin{verbatim}// Hash on a combination of functor and integer "id" attribute when reading inwxExprDatabase db(wxExprInteger, "id");// Read it indb.ReadProlog("data");// Retrieve a clause with specified functor and idwxExpr *clause = db.HashFind("node", 24);\end{verbatim}This would retrieve a clause which is written: {\tt node(id = 24, ..., )}.\func{wxExpr*}{HashFind}{\param{const wxString\&}{ functor}, \param{const wxString\&}{ value}}Finds the clause with the given functor and with the attribute specifiedin the database constructor having the given string value.\membersection{wxExprDatabase::Read}\label{wxexprdatabaseread}\func{bool}{Read}{\param{const wxString\&}{ filename}}Reads in the given file, returning true if successful.\membersection{wxExprDatabase::ReadFromString}\label{wxexprdatabasereadfromstring}\func{bool}{ReadFromString}{\param{const wxString\&}{ buffer}}Reads a Prolog database from the given string buffer, returning true ifsuccessful.\membersection{wxExprDatabase::Write}\label{wxexprdatabasewrite}\func{bool}{Write}{\param{FILE *}{stream}}\func{bool}{Write}{\param{const wxString\&}{ filename}}Writes the database as a Prolog-format file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -