vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AP_LSystem::LongString Class Reference

#include <longstring.h>

Public Member Functions

 LongString (unsigned int length=1048576)
 
 LongString (const LongString &c)
 
LongStringoperator= (const LongString &c)
 
 ~LongString ()
 
void convertFromString (std::string *str, unsigned int &=ZERO, const char= '\0')
 
template<class T >
void append (T par)
 
void append (const char ch)
 
void append (const char *data, int length)
 
void append (LongString *ls)
 
template<class T >
bool getParameters (unsigned int &pos, T *pParams, int &paramsCnt)
 
char * getData ()
 
char * getData (unsigned int &pos, unsigned int &length, char delimiter)
 
char * getSymbol (unsigned int &pos)
 
int matchRight (char ch, int pos, const std::string *ignore=NULL, const std::string *consider=NULL)
 
int matchLeft (char ch, int pos, const std::string *ignore=NULL, const std::string *consider=NULL)
 
char peekSymbol (int &pos, bool direction)
 
int findMatchingRightBracket (int pos)
 
int findMatchingLeftBracket (int pos)
 
std::string toString ()
 
char & operator[] (unsigned int i) const
 
unsigned int length () const
 

Detailed Description

Class for storing L-system string in fast form optimalized for append operation and for storing values/parameters of different types

Constructor & Destructor Documentation

LongString::LongString ( unsigned int  length = 1048576)

Create a LongString and set a default increment and initial length

Parameters
lengthinitial length and also default increment
LongString::LongString ( const LongString c)

Copy constructor

LongString::~LongString ( )

Destructor

Member Function Documentation

template<class T >
void AP_LSystem::LongString::append ( par)
inline

Appends some parameter of any type declared in Parameter::Type. Can be used to append module parameter.

Parameters
parparameter
void LongString::append ( const char  ch)

Appends one byte.

Parameters
chbyte to append
void LongString::append ( const char *  data,
int  length 
)

Appends buffer with data.

Parameters
databuffer with data
lengthlength of buffer
void LongString::append ( LongString ls)

Appends another LongString

Parameters
lsstring to append
void LongString::convertFromString ( std::string *  str,
unsigned int &  pos = ZERO,
const char  delimiter = '\0' 
)

Converts standart string of L-system to internal LongString format. Useful for successors and axioms.

int LongString::findMatchingLeftBracket ( int  pos)

Look for matching left bracket

Parameters
posinitial position
Returns
position of matching bracket.
int LongString::findMatchingRightBracket ( int  pos)

Look for matching right bracket

Parameters
posinitial position
Returns
position of matching bracket.
char * LongString::getData ( )

Get pointer to string data in LongString in raw form

Returns
all raw data of LongString
char * LongString::getData ( unsigned int &  pos,
unsigned int &  length,
char  delimiter 
)

Get pointer to string data in LongString in raw form

Parameters
posposition of first byte in the string to be taken into consideration
lengthmaximum length of taken data
delimiteroptional delimiter
Returns
raw data
template<class T >
bool AP_LSystem::LongString::getParameters ( unsigned int &  pos,
T *  pParams,
int &  paramsCnt 
)
inline

Extracts parameters of same type from some position in string

Parameters
posstart position of parameters
pParamsarray for storing parameters
paramsCntnumber of found parameters
Returns
- false: invalid position
  • true: success
char * LongString::getSymbol ( unsigned int &  pos)

Returns data whole symbol/module with it's parameters

Parameters
posPosition of module. Will be changet to position after module
Returns
module in raw data form
unsigned int AP_LSystem::LongString::length ( ) const
inline

Length of longstring

Returns
length
int LongString::matchLeft ( char  ch,
int  pos,
const std::string *  ignore = NULL,
const std::string *  consider = NULL 
)

Matches left context

Todo:
Implement consider
Parameters
chleft context
posinitial position - might be right behind identifier character
ignorestring of characters that should be ignored during matching algorithm
considerstring of characters that shoul be considered during matching algorithm
Returns
position of matching context or -1 if not found
int LongString::matchRight ( char  ch,
int  pos,
const std::string *  ignore = NULL,
const std::string *  consider = NULL 
)

Match right context

Todo:
Implement consider
Parameters
chright context
posinitial position - might be right behind identifier character
ignorestring of characters that should be ignored during matching algorithm
considerstring of characters that shoul be considered during matching algorithm
Returns
position of matching context or -1 if not found
LongString & LongString::operator= ( const LongString c)

Assignment operator

char& AP_LSystem::LongString::operator[] ( unsigned int  i) const
inline

Access to any byte of string

char LongString::peekSymbol ( int &  pos,
bool  direction 
)

Peek neighbouring symbol's identifier.

Parameters
posinitial position
directiontrue for searching to the right; false for searching to the left
Returns
module's/symbol's identifier
std::string LongString::toString ( )

Debug method for converting LongString from internal raw format to standart string. Becareful - very slow !

Returns
string in standart L-system format

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