Itasca C++ Interface
|
Interface to the main command processing class. More...
#include <iparse.h>
Classes | |
class | IMark |
Opaque position indicator class. Do not attempt to use directly for anything. More... | |
Public Types | |
enum | RetCode { rcOK , rcMiss , rcBad , rcRange , rcExtra } |
Possible return codes for isXXX() functions. More... | |
Public Member Functions | |
virtual | ~IParse () |
Virtual destructor. | |
virtual bool | interactiveSource () const =0 |
Returns TRUE if the input source for the command being processed was interactive. | |
virtual void | tagLastInputForSmartUndo (const QString &label, uint64 maxLevel, const QString &undoCommand)=0 |
virtual int | getTokenIndex (IMark *p=nullptr) const =0 |
virtual int | getLineNumber (IMark *p=nullptr) const =0 |
virtual IVect2 | getTokenExtent (IMark *p=nullptr) const =0 |
virtual ITextOutput * | getITextOutput ()=0 |
Returns an ITextIO interface associated with this parser. | |
virtual const ITextInput * | getITextInput () const =0 |
Returns an ITextInput interface associated with this parser. | |
virtual ITextInput * | getITextInput ()=0 |
Returns an ITextInput interface associated with this parser. | |
virtual const QList< InputLine > & | getOriginalInput () const =0 |
Returns the original strings used to generate the set of command tokens. | |
virtual IParse * | createTemporaryParse (const QString &)=0 |
A method to return a temporary IParse Object that must be deleted. | |
virtual IMark * | createMark (int pos=0) const =0 |
virtual IMark * | createMarkCopy (IMark *p=nullptr) const =0 |
virtual void | increment (IMark *p=nullptr) const =0 |
Increments the provided or internal mark. | |
virtual void | decrement (IMark *p=nullptr) const =0 |
Decrements the provided or internal mark. | |
virtual void | setMark (IMark *pNew, IMark *p=nullptr) const =0 |
Sets the internal position indicator to p. | |
virtual IString | getToken (IMark *p=nullptr) const =0 |
virtual bool | isToken (IMark *p=nullptr) const =0 |
virtual void | checkError (RetCode rc, IMark *p=nullptr) const =0 |
virtual bool | checkError (bool b, IMark *p=nullptr) const =0 |
virtual void | addHelp (const IString &s) const =0 |
Adds a QString representing a token type to the help list. Multiple matching Strings are filtered. | |
virtual bool | isHelp (IMark *p=nullptr) const =0 |
Returns TRUE if the token matches one of the help_tokens. | |
virtual RetCode | isString (QString *ps=nullptr, IMark *p=nullptr, bool encodeBackslash=true) const =0 |
virtual RetCode | isBool (bool *pb=nullptr, IMark *p=nullptr, bool implicitOn=false) const =0 |
virtual RetCode | isInt (int *pi=nullptr, IMark *p=nullptr, int iMin=limits< int >::min(), int iMax=limits< int >::max()) const =0 |
virtual RetCode | isLong (qint64 *pl=nullptr, IMark *p=nullptr, qint64 lMin=limits< qint64 >::min(), qint64 lMax=limits< qint64 >::max()) const =0 |
virtual RetCode | isUInt (uint32 *pu=nullptr, IMark *p=nullptr, uint32 uMin=0, uint32 uMax=limits< uint32 >::max()) const =0 |
virtual RetCode | isULong (uint64 *pu=nullptr, IMark *p=nullptr, uint64 uMin=0, uint64 uMax=limits< uint64 >::max()) const =0 |
virtual RetCode | isName (QString *ps=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isDouble (double *pd=nullptr, IMark *p=nullptr, double dMin=limits< double >::lowest(), double dMax=limits< double >::max()) const =0 |
virtual RetCode | isKeyword (const IString &key, uint32 *pPos=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isMultiKeyword (const IString &key, std::vector< uint32 > *pPos, IMark *p=nullptr) const =0 |
virtual RetCode | isDVect2 (DVect2 *pv=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isDVect3 (DVect3 *pv=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isDVect (DVect *pv=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isSymTensor (SymTensor *pv=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isVariant (int type, QVariant *pv=nullptr, IMark *p=nullptr, uint32 len=0) const =0 |
virtual RetCode | isVariant (QVariant *pv=nullptr, IMark *p=nullptr) const =0 |
virtual RetCode | isFilename (QString *ps=nullptr, const IString &def_ext={}, bool openForRead=false, IMark *p=nullptr) const =0 |
virtual IString | toString (IMark *p=nullptr) const =0 |
virtual bool | toBool (IMark *p=nullptr, bool implicitOn=false) const =0 |
virtual int | toInt (IMark *p=nullptr, int iMin=limits< int >::min(), int iMax=limits< int >::max()) const =0 |
virtual qint64 | toLong (IMark *p=nullptr, qint64 lMin=limits< qint64 >::min(), qint64 lMax=limits< qint64 >::max()) const =0 |
virtual uint32 | toUInt (IMark *p=nullptr, uint32 uMin=0, uint32 uMax=limits< uint32 >::max()) const =0 |
virtual uint64 | toULong (IMark *p=nullptr, uint64 uMin=0, uint64 uMax=limits< uint64 >::max()) const =0 |
virtual IString | toName (IMark *p=nullptr) const =0 |
virtual double | toDouble (IMark *p=nullptr, double dMin=-limits< double >::max(), double dMax=limits< double >::max()) const =0 |
virtual uint32 | toKeyword (const IString &key, IMark *p=nullptr) const =0 |
virtual DVect | toDVect (IMark *p=0) const =0 |
virtual DVect2 | toDVect2 (IMark *p=nullptr) const =0 |
virtual DVect3 | toDVect3 (IMark *p=nullptr) const =0 |
virtual SymTensor | toSymTensor (IMark *p=nullptr) const =0 |
virtual QVariant | toVariant (int type, IMark *p=nullptr, uint32 len=0) const =0 |
virtual QVariant | toVariant (IMark *p=nullptr) const =0 |
virtual IString | toFilename (const IString &def_ext={}, bool openForRead=false, IMark *p=nullptr) const =0 |
virtual int | isStringCharStart (QChar c) const =0 |
virtual int | isStringCharEnd (QChar c) const =0 |
virtual QStringList | getSkipList () const =0 |
Returns the original skip list parsed from the input line. | |
virtual bool | checkSkipPre (QStringList *skipList, QChar c, IMark *p=nullptr) const =0 |
virtual bool | checkSkipPost (QStringList *skipList, QChar c, IMark *p=nullptr) const =0 |
virtual void | addSkipPre (QStringList *skipList, QChar c, IMark *p=nullptr) const =0 |
Adds a character to the end of the skip string BEFORE the current token. | |
virtual void | addSkipPost (QStringList *skipList, QChar c, IMark *p=nullptr) const =0 |
Adds a character to the start of the skip string AFTER the current token. | |
virtual bool | findKeyword (const QString &keyword, IMark *pFound, IMark *pStart=nullptr) const =0 |
virtual void | stripTokens (IMark *mBegin, IMark *mEnd, IMark *p=nullptr)=0 |
virtual bool | activateHelp (bool b)=0 |
Turne help on/off. | |
virtual bool | hasHelpToken () const =0 |
Return a boolean indicating whether or not a help token is in the token list. | |
virtual void | destroy ()=0 |
Interface to the main command processing class.
This is an interface to the main command processing class. Specifically, this class takes command string and tokenizes them, allowing them to be interpreted as commands.
The class IParse::IMark is used to indication a position in the token list. This class is completely opaque, you must use member function of IParse to create and modify them. In particular - do not do "*im1 = *im2;" where both im1 and im2 are pointers to IParse::IMark. This will compile and execute, but not produce the results you want. I was unable to get this to give a compile time error ;(.
An IParse object contains an internal position indicator that is used by default if one is not specified in the command. All functions that accept an IMark assume (without checking) that the IMark was created by the same IParse it was being used in.
There are four broad categores of functions
isXXX() (Check conversion functions) check to see if a token can be interpreted in a certain way, and return an IParse::RetCode to indicate success or failure. If successful, they will fill a pointer to the object (if given) and increment the IParse::IMark position indicator.
toXXX() (Automatic throw routines) directly converts to the indicated type and returns the value, throwing an Exception if the token was unable to be interpreted.
IParse::IMark manipulation functions create, check, and modify the position of IParse::IMark objects.
General utility functions.
Functions getTokenIndex, getLineNumber and getTokenExtent return information on the original location of the token on the input line. Note that if the token was created as the result of macro expansion, the information indicates the macro it came from.
Possible return codes for isXXX() functions.
Throws an exception (or not) based on rc assuming it was the result of trying to process the token p. If rc==rcOK does nothing.
|
pure virtual |
Checks the skipped delimiter exists after the mark token in the skip string AFTER the token marker. Returns TRUE if found, and REMOVES THAT CHARACTER from the skipList.
|
pure virtual |
Checks the skipped delimiter exists before the mark token in the skip string BEFORE the token marker. Returns TRUE if found, and REMOVES THAT CHARACTER from the skipList.
|
pure virtual |
Creates an IMark indicating the pos token (base 0), or end() if token does not exist.
MUST BE DELETED BY CALLER
Creates an IMark that indicates the same position as p, or the internal indicator if p is not given.
MUST BE DELETED BY CALLER
|
pure virtual |
Returns TRUE if a keyword match is found in any token at or after pStart. pStart=nullptr means the internal position indicator. Fill pFound (if non-zero) with the location found.
|
pure virtual |
Returns the continuation line (starting at 0) the token came from.
The end mark indicator returns the line of the last valid token, or 0 if no valid tokens currently exist.
Returns the token present at the given mark - does not increment p.
Does NOT check that p represents a valid token!
|
pure virtual |
Gives the minimum and maximum character index of the token in the original string, on the appropriate line. The end mark indicator returns one past the last valid token ans beginning and end, or (0,0) if no valid tokens currently exist.
|
pure virtual |
Returns the placement of the token on the command (base 0), over all continuation lines. The end IMark indicator (not valid) is given as the size of the current token list.
|
pure virtual |
Checks if token is a boolean. If successful, it will fill the boolean pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a double. If successful, it will fill the double pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a DVect. If successful, it will fill the DVect pointer to the object (if given) and increment the IParse::IMark position indicator three steps.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a DVect3. If successful, it will fill the DVetc3 pointer to the object (if given) and increment the IParse::IMark position indicator three steps.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a valid file path. If successful, it will fill the Qstring pointer to the object (if given) and increment the IParse::IMark position indicator.
def_ext can contain multiple extensions, delimited by spaces.
Will always return an absolution file path.
If openForRead is true, will check for all default extensions and in both input and current directory for a valid file, and return the one found.
"inputdir" and "localdir" can be specified after the file name to force the file to be in the input directory or the current working directory, respectively.
If no extension is given, will use def_ext to provide an extension (if present).
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a signed 32-bit integer. If successful, it will fill the int pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Given a string that contains a list of comma delimited keywords, checks if the token is a valid word in the list. If successful, it will fill the uint32 pointer to the position of the keyword in the keyword list. The position in the string list starts at 1. and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired. A leading '-' indicator means the option is hidden/deprecated. The '-' isn't necessary normally and it won't show up in a help query. In testing mode the '-' is necessary for a match. For example: "fred,-george,mary lemon" has three possible return positions (1-3). "george" is hidden/deprecated. Either "mary" or "lemon" will match the third position.
|
pure virtual |
Checks if token is a signed 64-bit long. If successful, it will fill the long pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a string. If successful, it will fill the string pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Determines if c is a string delimiter token, indicating the end of a string token.
Returns 0 if it is not, a positive integer is the index (base 1) of the delimiter character.
This can be used to find a matching end delimiter using isStringCharBegin().
Note that beginning and ending string delimiters do not have to be the same, but most commonly are.
|
pure virtual |
Determines if c is a string delimiter token, indicating the start of a string token.
Returns 0 if it is not, a positive integer is the index (base 1) of the delimiter character.
This can be used to find a matching end delimiter using isStringCharEnd().
Note that beginning and ending string delimiters do not have to be the same, but most commonly are.
|
pure virtual |
Checks if token is a SymTensor. If successful, it will fill the SymTensor pointer to the object (if given) and increment the IParse::IMark position indicator 6 steps.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks to make sure that p represents a valid token.
NOTE: Assumes that p is an mark type aquired from this instance of Parse. Assuming p is a valid token, this will returns false only when an IMark has been incremented past the last token in the command.
|
pure virtual |
Checks if token is a unsigned 32-bit integer. If successful, it will fill the uint32 pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a unsigned 64-bit long. If successful, it will fill the long pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a DVect. If successful, it will fill the DVect pointer to the object (if given) and increment the IParse::IMark position indicator two or three steps, dependig if code is 2D or 3D.
Returns a RetCode indicating if it was able to interpret the token as desired. Checks if token is a ADVect. If successful, it will fill the ADVect pointer to the object (if given) and increment the IParse::IMark position indicator two or three steps, dependig if code is 2D or 3D.
Returns a RetCode indicating if it was able to interpret the token as desired. Checks if token is a QVariant of the given QVariant::type. If successful, it will fill the QVariant pointer to the object (if given) and increment the IParse::IMark position indicator.
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Checks if token is a QVariant. If successful, it will fill the QVariant pointer to the object (if given) and increment the IParse::IMark position indicator.
Checks in the following order: DVect3,DVect2,double,int,bool,QString
Returns a RetCode indicating if it was able to interpret the token as desired.
|
pure virtual |
Removes tokens from the current list after and including token m. The current position indicator is updated to be consistent. p (if provided) is updated to be consistent as well.
|
pure virtual |
Checks if token is a boolean. If successful, returns a boolean and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a double. If successful, returns a double and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
Checks if token is a DVect. If successful, returns a DVect and increment the IParse::IMark position indicator two steps.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a DVect2. If successful, returns a DVect2 and increment the IParse::IMark position indicator two steps.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a DVect3. If successful, returns a DVect3 and increment the IParse::IMark position indicator three steps.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a valid file path. Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a 32-bit integer. If successful, returns a int and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Given a string that contains a list of comma delimited keywords, checks if the token is a valid word in the list. If successful, returns a position of the keyword in the list and increment the IParse::IMark position indicator. The position in the list starts at 1.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a 64-bit integer. If successful, returns a 64-bit integer and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
Checks if token is a string. If successful, returns a QString and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
Checks if token is a SymTensor. If successful, returns a SymTensor and increments the IParse::IMark position indicator six steps.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a uint32. If successful, returns a uint32 and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a 64-bit unsigned integer. If successful, returns a uint64 and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a QVariant. Returns a QVariant and increment the IParse::IMark position indicator.
Checks in the following order: DVect3,DVect2,double,int,bool,QString
Throws an Exception if the token was unable to be interpreted
|
pure virtual |
Checks if token is a DVect. If successful, returns a DVect and increment the IParse::IMark position indicator two or three steps, dependig if code is 2D or 3D.
Throws an Exception if the token was unable to be interpreted Checks if token is a DAVect. If successful, returns a DAVect and increment the IParse::IMark position indicator two or three steps, dependig if code is 2D or 3D.
Throws an Exception if the token was unable to be interpreted Checks if token is a QVariant of the given QVariant::type. Returns a QVariant and increment the IParse::IMark position indicator.
Throws an Exception if the token was unable to be interpreted