kspread

#include <formula.h>

Public Types

enum  Type {
  Unknown = 0 , Boolean , Integer , Float ,
  String , Operator , Cell , Range ,
  Identifier
}
enum  Op {
  InvalidOp = 0 , Plus , Minus , Asterisk ,
  Slash , Caret , LeftPar , RightPar ,
  Comma , Semicolon , Ampersand , Equal ,
  NotEqual , Less , Greater , LessEqual ,
  GreaterEqual , Percent
}

Public Member Functions

 Token (Type type=Unknown, const TQString &text=TQString(), int pos=-1)
 Token (const Token &)
Token & operator= (const Token &)
Type type () const
TQString text () const
int pos () const
bool isBoolean () const
bool isInteger () const
bool isFloat () const
bool isNumber () const
bool isString () const
bool isOperator () const
bool isCell () const
bool isRange () const
bool isIdentifier () const
bool asBoolean () const
long asInteger () const
double asFloat () const
TQString asString () const
Op asOperator () const
TQString sheetName () const
TQString description () const

Static Public Attributes

static const Token null

Protected Attributes

Type m_type
TQString m_text
int m_pos

Detailed Description

Token.

Definition at line 37 of file formula.h.

Member Enumeration Documentation

◆ Op

operator types

Enumerator
InvalidOp 

invalid operator

Plus 
  • (addition)
Minus 
  • (substraction, negation)
Asterisk 
  • (multiplication)
Slash 

/ (division)

Caret 

^ (power)

LeftPar 

(

RightPar 

)

Comma 

,

Semicolon 

; (argument separator)

Ampersand 

& (string concat)

Equal 

=

NotEqual 

<>

Less 

<

Greater 

LessEqual 

<=

GreaterEqual 

>=

Percent 

%

Definition at line 59 of file formula.h.

◆ Type

token types

Enumerator
Unknown 

unknown type

Boolean 

True, False (also i18n-ized).

Integer 

14, 3, 1977

Float 

3.141592, 1e10, 5.9e-7

String 

"KOffice", "The quick brown fox..."

Operator 

+, *, /, -

Cell 

$A$1, F4, Sheet2!B5, 'Sales Forecast'!Sum

Range 

C1:C100.

Identifier 

function name or named area

Definition at line 43 of file formula.h.

Constructor & Destructor Documentation

◆ Token() [1/2]

Token::Token ( Type type = Unknown,
const TQString & text = TQString(),
int pos = -1 )

Creates a token.

Definition at line 212 of file formula.cpp.

◆ Token() [2/2]

Token::Token ( const Token & token)

Definition at line 220 of file formula.cpp.

Member Function Documentation

◆ asBoolean()

bool Token::asBoolean ( ) const

Returns boolean value for an boolean token.

For any other type of token, return value is undefined.

Definition at line 236 of file formula.cpp.

◆ asFloat()

double Token::asFloat ( ) const

Returns floating-point value for a floating-point token.

For any other type of token, returns 0.0.

Definition at line 249 of file formula.cpp.

◆ asInteger()

long Token::asInteger ( ) const

Returns integer value for an integer token.

For any other type of token, returns 0.

Definition at line 243 of file formula.cpp.

◆ asOperator()

Token::Op Token::asOperator ( ) const

Returns operator value for an operator token.

For any other type of token, returns Token::InvalidOp.

Definition at line 261 of file formula.cpp.

◆ asString()

TQString Token::asString ( ) const

Returns string value for a string token.

For any other type of token, it returns TQString().

Note that token text for a string token still has leading and trailing double-quotes, i.e for "KOffice", text() return "KOffice" (with the quotes, 9 characters) while asString() only return KOffice (without quotes, 7 characters).

Definition at line 255 of file formula.cpp.

◆ description()

TQString Token::description ( ) const

Returns a short description of the token.

Should be used only to assist debugging.

Definition at line 276 of file formula.cpp.

◆ isBoolean()

bool KSpread::Token::isBoolean ( ) const
inline

Returns true if token is a boolean token.

Definition at line 110 of file formula.h.

◆ isCell()

bool KSpread::Token::isCell ( ) const
inline

Returns true if token is a cell reference token.

Definition at line 140 of file formula.h.

◆ isFloat()

bool KSpread::Token::isFloat ( ) const
inline

Returns true if token is a floating-point token.

Definition at line 120 of file formula.h.

◆ isIdentifier()

bool KSpread::Token::isIdentifier ( ) const
inline

Returns true if token is an identifier.

Definition at line 150 of file formula.h.

◆ isInteger()

bool KSpread::Token::isInteger ( ) const
inline

Returns true if token is a integer token.

Definition at line 115 of file formula.h.

◆ isNumber()

bool KSpread::Token::isNumber ( ) const
inline

Returns true if token is either integer or floating-point token.

Definition at line 125 of file formula.h.

◆ isOperator()

bool KSpread::Token::isOperator ( ) const
inline

Returns true if token is an operator token.

Definition at line 135 of file formula.h.

◆ isRange()

bool KSpread::Token::isRange ( ) const
inline

Returns true if token is a range reference token.

Definition at line 145 of file formula.h.

◆ isString()

bool KSpread::Token::isString ( ) const
inline

Returns true if token is a string token.

Definition at line 130 of file formula.h.

◆ operator=()

Token & Token::operator= ( const Token & token)

Definition at line 228 of file formula.cpp.

◆ pos()

int KSpread::Token::pos ( ) const
inline

Definition at line 105 of file formula.h.

◆ sheetName()

TQString Token::sheetName ( ) const

Returns sheet name in a cell reference token.

For any other type of token, it returns TQString().

If the cell reference doesn't specify sheet name, an empty string is returned. As example, for "Sheet1!B3" , sheetName() returns "Sheet1" while for "A2" sheetName() returns "".

When sheet name contains quotes (as if the name has spaces) like in "'Sales Forecast'!F4", sheetName() returns the name without the quotes, i.e "Sales Forecast" in this case.

Definition at line 267 of file formula.cpp.

◆ text()

TQString KSpread::Token::text ( ) const
inline

Returns text associated with the token.

If you want to obtain meaningful value of this token, instead of text(), you might use asInteger(), asFloat(), asString(), sheetName(), etc.

Definition at line 103 of file formula.h.

◆ type()

Type KSpread::Token::type ( ) const
inline

Returns type of the token.

Definition at line 94 of file formula.h.

Member Data Documentation

◆ m_pos

int KSpread::Token::m_pos
protected

Definition at line 211 of file formula.h.

◆ m_text

TQString KSpread::Token::m_text
protected

Definition at line 210 of file formula.h.

◆ m_type

Type KSpread::Token::m_type
protected

Definition at line 209 of file formula.h.

◆ null

const Token Token::null
static

Definition at line 86 of file formula.h.


The documentation for this class was generated from the following files: