📄 expr.tex
字号:
\section{\class{wxExpr}}\label{wxexpr}The {\bf wxExpr} class is the building brick of expressions similar to Prologclauses, or objects. It can represent an expression of type long integer, float, string, word,or list, and lists can be nested.\wxheading{Derived from}None\wxheading{Include files}<wx/wxexpr.h>\wxheading{See also}\helpref{wxExpr overview}{exproverview}, \helpref{wxExprDatabase}{wxexprdatabase}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxExpr::wxExpr}\label{wxexprconstr}\func{}{wxExpr}{\param{const wxString\&}{functor}}Construct a new clause with this form, supplying the functor name. A clause is an objectthat will appear in the data file, with a list of attribute/value pairs.\func{}{wxExpr}{\param{wxExprType}{ type}, \param{const wxString\&}{ wordOrString = ``"}}Construct a new empty list, or a word (will be output with no quotes), or a string, depending on thevalue of {\it type}.{\it type} can be {\bf wxExprList}, {\bf wxExprWord}, or {\bf wxExprString}. If {\it type} is wxExprList,the value of {\it wordOrString} will be ignored.\func{}{wxExpr}{\param{long}{ value}}Construct an integer expression.\func{}{wxExpr}{\param{float}{ value}}Construct a floating point expression.\func{}{wxExpr}{\param{wxList* }{value}}Construct a list expression. The list's nodes' data shouldthemselves be {\bf wxExpr}s.wxExpr no longer uses the {\bf wxList} internally,so this constructor turns the list into its internalformat (assuming a non-nested list) and then deletes the suppliedlist.\membersection{wxExpr::\destruct{wxExpr}}\func{}{\destruct{wxExpr}}{\void}Destructor.\membersection{wxExpr::AddAttributeValue}\label{wxexpraddattributevalue}Use these on clauses ONLY. Note that the functions for adding stringsand words must be differentiated by function name which is whythey are missing from this group (see \helpref{wxExpr::AddAttributeValueString}{wxexpraddattributevaluestring} and\rtfsp\helpref{wxExpr::AddAttributeValueWord}{wxexpraddattributevalueword}).\func{void}{AddAttributeValue}{\param{const wxString\&}{ attribute}, \param{float }{value}}Adds an attribute and floating point value pair to the clause.\func{void}{AddAttributeValue}{\param{const wxString\&}{ attribute}, \param{long }{value}}Adds an attribute and long integer value pair to the clause.\func{void}{AddAttributeValue}{\param{const wxString\&}{ attribute}, \param{wxList* }{value}}Adds an attribute and list value pair to the clause, converting the list intointernal form and then deleting {\bf value}. Note that the list should not containnested lists (except if in internal {\bf wxExpr} form.)\func{void}{AddAttributeValue}{\param{const wxString\&}{ attribute}, \param{wxExpr* }{value}}Adds an attribute and wxExpr value pair to the clause. Do not delete\rtfsp{\it value} once this function has been called.\membersection{wxExpr::AddAttributeValueString}\label{wxexpraddattributevaluestring}\func{void}{AddAttributeValueString}{\param{const wxString\&}{ attribute}, \param{const wxString\&}{ value}}Adds an attribute and string value pair to the clause.\membersection{wxExpr::AddAttributeValueStringList}\label{wxexpraddattributevaluestringlist}\func{void}{AddAttributeValueStringList}{\param{const wxString\&}{ attribute}, \param{wxList* }{value}}Adds an attribute and string list value pair to the clause.Note that the list passed to this function is a list of strings, NOT a listof {\bf wxExpr}s; it gets turned into a list of {\bf wxExpr}sautomatically. This is a convenience function, since lists of stringsare often manipulated in C++.\membersection{wxExpr::AddAttributeValueWord}\label{wxexpraddattributevalueword}\func{void}{AddAttributeValueWord}{\param{const wxString\&}{ attribute}, \param{const wxString\&}{ value}}Adds an attribute and word value pair to the clause.\membersection{wxExpr::Append}\label{wxexprappend}\func{void}{Append}{\param{wxExpr*}{ value}}Append the {\bf value} to the end of the list. `this' must be a list.\membersection{wxExpr::Arg}\label{wxexprarg}\constfunc{wxExpr* }{Arg}{\param{wxExprType}{ type}, \param{int}{ n}}Get nth arg of the given clause (starting from 1). NULL is returned ifthe expression is not a clause, or {\it n} is invalid, or the given typedoes not match the actual type. See also \helpref{wxExpr::Nth}{wxexprnth}.\membersection{wxExpr::Insert}\label{wxexprinsert}\func{void}{Insert}{\param{wxExpr* }{value}}Insert the {\bf value} at the start of the list. `this' must be a list.\membersection{wxExpr::GetAttributeValue}\label{wxexprgetattributevalue}These functions are the easiest way to retrieve attribute values, bypassing a pointer to variable. If the attribute is present, thevariable will be filled with the appropriate value. If not, theexisting value is left alone. This style of retrieving attributesmakes it easy to set variables to default values before calling thesefunctions; no code is necessary to check whether the attribute ispresent or not.\constfunc{bool}{GetAttributeValue}{\param{const wxString\&}{ attribute}, \param{wxString\&}{ value}}Retrieve a string (or word) value.\constfunc{bool}{GetAttributeValue}{\param{const wxString\&}{ attribute}, \param{float\& }{value}}Retrieve a floating point value.\constfunc{bool}{GetAttributeValue}{\param{const wxString\&}{ attribute}, \param{int\& }{value}}Retrieve an integer value.\constfunc{bool}{GetAttributeValue}{\param{const wxString\&}{ attribute}, \param{long\& }{value}}Retrieve a long integer value.\constfunc{bool}{GetAttributeValue}{\param{const wxString\&}{ attribute}, \param{wxExpr**}{ value}}Retrieve a wxExpr pointer.\membersection{wxExpr::GetAttributeValueStringList}\label{wxexprgetattributestringlist}\constfunc{void}{GetAttributeValueStringList}{\param{const wxString\&}{attribute}, \param{wxList* }{value}}Use this on clauses ONLY. See above for comments on this style ofattribute value retrieval. This function expects to receive a pointer toa new list (created by the calling application); it will append stringsto the list if the attribute is present in the clause.\membersection{wxExpr::AttributeValue}\label{wxexprattributevalue}\constfunc{wxExpr*}{AttributeValue}{\param{const wxString\&}{ word}}Use this on clauses ONLY. Searches the clause for an attributematching {\it word}, and returns the value associated with it.\membersection{wxExpr::Copy}\label{wxexprcopy}\constfunc{wxExpr*}{Copy}{\void}Recursively copies the expression, allocating new storage space.\membersection{wxExpr::DeleteAttributeValue}\label{wxexprdeletattributevalue}\func{void}{DeleteAttributeValue}{\param{const wxString\&}{ attribute}}Use this on clauses only. Deletes the attribute and its value (if any) from theclause.\membersection{wxExpr::Functor}\label{wxexprfunctor}\constfunc{wxString}{Functor}{\void}Use this on clauses only. Returns the clause's functor (object name).\membersection{wxExpr::GetClientData}\label{wxexprgetclientdata}\constfunc{wxObject*}{GetClientData}{\void}Retrieve arbitrary data stored 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::SetClientData}{wxexprsetclientdata}.\membersection{wxExpr::GetFirst}\label{wxexprgetfirst}\constfunc{wxExpr*}{GetFirst}{\void}If this is a list expression (or clause), gets the first element in the list.See also \helpref{wxExpr::GetLast}{wxexprgetlast}, \helpref{wxExpr::GetNext}{wxexprgetnext}, \helpref{wxExpr::Nth}{wxexprnth}.\membersection{wxExpr::GetLast}\label{wxexprgetlast}\constfunc{wxExpr*}{GetLast}{\void}If this is a list expression (or clause), gets the last element in the list.See also \helpref{wxExpr::GetFirst}{wxexprgetfirst}, \helpref{wxExpr::GetNext}{wxexprgetnext}, \helpref{wxExpr::Nth}{wxexprnth}.\membersection{wxExpr::GetNext}\label{wxexprgetnext}\constfunc{wxExpr*}{GetNext}{\void}If this is a node in a list (any wxExpr may be a node in a list), gets thenext element in the list.See also \helpref{wxExpr::GetFirst}{wxexprgetfirst}, \helpref{wxExpr::GetLast}{wxexprgetlast}, \helpref{wxExpr::Nth}{wxexprnth}.\membersection{wxExpr::IntegerValue}\label{wxexprintegervalue}\constfunc{long}{IntegerValue}{\void}Returns the integer value of the expression.\membersection{wxExpr::Nth}\label{wxexprnth}\constfunc{wxExpr*}{Nth}{\param{int}{ n}}Get nth arg of the given list expression (starting from 0). NULL is returned ifthe expression is not a list expression, or {\it n} is invalid. See also \helpref{wxExpr::Arg}{wxexprarg}.Normally, you would use attribute-value pairs to add and retrieve datafrom objects (clauses) in a data file. However, if the data gets complex,you may need to store attribute values as lists, and pick them apartyourself.\membersection{wxExpr::RealValue}\label{wxexprrealvalue}\constfunc{float}{RealValue}{\void}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -