Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
hrp::EasyScanner Class Reference

#include <EasyScanner.h>

Classes

class  Endl
 
class  Exception
 

Public Types

typedef std::map< std::string, intSymbolMap
 
typedef boost::shared_ptr< SymbolMapSymbolMapPtr
 
typedef std::pair< std::string, intSymbolPair
 
enum  TokenType {
  T_NONE = 0, T_SPACE, T_ALPHABET, T_INTEGER,
  T_DOUBLE, T_WORD, T_STRING, T_SIGLUM,
  T_LF, T_EOF
}
 

Public Member Functions

bool checkLF ()
 
 EasyScanner ()
 
 EasyScanner (std::string filename)
 
 EasyScanner (const EasyScanner &scanner, bool copy_text=false)
 
int getSymbolID (const std::string &symbol)
 
bool isEOF ()
 
void loadFile (const std::string &filename)
 
void moveToHead ()
 
int peekChar ()
 
void putSymbols ()
 
bool readChar ()
 
bool readChar (int chara)
 
int readCharEx (const char *message=0)
 
void readCharEx (int chara, const char *message=0)
 
bool readDouble ()
 
double readDoubleEx (const char *message=0)
 
bool readInt ()
 
int readIntEx (const char *message=0)
 
bool readLF ()
 reading a line feed More...
 
bool readLFEOF ()
 
void readLFEOFex (const char *message=0)
 
void readLFex (const char *message=0)
 
bool readLine ()
 
bool readQuotedString (bool allowNoQuotedWord=false)
 
std::string readQuotedStringEx (const char *message=0)
 
bool readString (const int delimiterChar= ',')
 
bool readString (const char *str)
 
bool readString (const std::string &str)
 
std::string readStringEx (const char *message=0)
 
bool readSymbol ()
 
bool readSymbol (int id)
 
int readSymbolEx (const char *message=0)
 
int readToken ()
 
bool readUnquotedTextBlock ()
 
bool readWord ()
 
std::string readWordEx (const char *message=0)
 
void registerSymbol (int id, const std::string &symbol)
 
void setCommentChar (char cc)
 if 0, comment is disabled More...
 
void setDefaultErrorMessage (const std::string &message)
 
void setLineNumberOffset (int offset)
 
void setLineOriented (bool on)
 
void setQuoteChar (char qc)
 
void setText (const char *text, int len)
 
void setWhiteSpaceChar (char ws)
 
bool skipBlankLines ()
 
bool skipLine ()
 
void skipSpace ()
 
void throwException (const char *message)
 
void throwException (const std::string &message)
 
void toLower ()
 
virtual ~EasyScanner ()
 

Public Attributes

char charValue
 
std::string defaultErrorMessage
 
double doubleValue
 
Endl endl
 
std::string filename
 
int intValue
 
int lineNumber
 
std::string stringValue
 
int symbolValue
 
char * text
 

Private Member Functions

int extractQuotedString ()
 
void init ()
 
bool readLF0 ()
 
bool readString0 (const int delimiterChar)
 
bool readWord0 ()
 
void skipToLineEnd ()
 

Private Attributes

int commentChar
 
bool isLineOriented
 
int lineNumberOffset
 
int quoteChar
 
int size
 
SymbolMapPtr symbols
 
char * textBuf
 
char * textBufEnd
 
std::vector< intwhiteSpaceChars
 

Friends

HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, double &value)
 
HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, int &value)
 
HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, const char *matchString)
 
HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, char matchChar)
 
HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, std::string &str)
 
HRP_UTIL_EXPORT EasyScanneroperator>> (EasyScanner &scanner, EasyScanner::Endl endl)
 

Detailed Description

Definition at line 27 of file EasyScanner.h.

Member Typedef Documentation

typedef std::map<std::string, int> hrp::EasyScanner::SymbolMap

Definition at line 48 of file EasyScanner.h.

typedef boost::shared_ptr<SymbolMap> hrp::EasyScanner::SymbolMapPtr

Definition at line 50 of file EasyScanner.h.

typedef std::pair<std::string, int> hrp::EasyScanner::SymbolPair

Definition at line 49 of file EasyScanner.h.

Member Enumeration Documentation

Enumerator
T_NONE 
T_SPACE 
T_ALPHABET 
T_INTEGER 
T_DOUBLE 
T_WORD 
T_STRING 
T_SIGLUM 
T_LF 
T_EOF 

Definition at line 43 of file EasyScanner.h.

Constructor & Destructor Documentation

EasyScanner::EasyScanner ( )

Definition at line 109 of file EasyScanner.cpp.

hrp::EasyScanner::EasyScanner ( std::string  filename)
EasyScanner::EasyScanner ( const EasyScanner org,
bool  copyText = false 
)

Copy Constructor. New object inherits another's propety and symbols.

Parameters
orgoriginal object
copyTextIf true, new object has same text as original

Definition at line 149 of file EasyScanner.cpp.

EasyScanner::~EasyScanner ( )
virtual

Definition at line 192 of file EasyScanner.cpp.

Member Function Documentation

bool EasyScanner::checkLF ( )

Definition at line 377 of file EasyScanner.cpp.

int EasyScanner::extractQuotedString ( )
private

Definition at line 453 of file EasyScanner.cpp.

int hrp::EasyScanner::getSymbolID ( const std::string &  symbol)
inline

Definition at line 65 of file EasyScanner.h.

void EasyScanner::init ( )
private

Definition at line 125 of file EasyScanner.cpp.

bool hrp::EasyScanner::isEOF ( )
inline

Definition at line 130 of file EasyScanner.h.

void EasyScanner::loadFile ( const std::string &  filename)

This function loads a text from a given file. The function thorws EasyScanner::Exception when the file cannot be loaded.

Definition at line 274 of file EasyScanner.cpp.

void EasyScanner::moveToHead ( )

Definition at line 204 of file EasyScanner.cpp.

int EasyScanner::peekChar ( )

Definition at line 543 of file EasyScanner.cpp.

void EasyScanner::putSymbols ( )

Definition at line 211 of file EasyScanner.cpp.

bool EasyScanner::readChar ( )

Definition at line 517 of file EasyScanner.cpp.

bool EasyScanner::readChar ( int  chara)

Definition at line 531 of file EasyScanner.cpp.

int hrp::EasyScanner::readCharEx ( const char *  message = 0)
inline

The exception version of readChar().

Returns
Scanned char value.

Definition at line 177 of file EasyScanner.h.

void hrp::EasyScanner::readCharEx ( int  chara,
const char *  message = 0 
)
inline

The exception version of readChar().

Definition at line 185 of file EasyScanner.h.

bool EasyScanner::readDouble ( )

Definition at line 485 of file EasyScanner.cpp.

double hrp::EasyScanner::readDoubleEx ( const char *  message = 0)
inline

The exception version of readDouble().

Returns
Scanned double value.

Definition at line 169 of file EasyScanner.h.

bool EasyScanner::readInt ( )

Definition at line 501 of file EasyScanner.cpp.

int hrp::EasyScanner::readIntEx ( const char *  message = 0)
inline

The exception version of readInt().

Returns
Scanned int value.

Definition at line 161 of file EasyScanner.h.

bool hrp::EasyScanner::readLF ( )
inline

reading a line feed

Definition at line 136 of file EasyScanner.h.

bool EasyScanner::readLF0 ( )
private

This function does not call 'skipSpace()'. On the other hand, 'readLF()' calls 'skipSpace()' before calling 'readLF0()'

Definition at line 359 of file EasyScanner.cpp.

bool hrp::EasyScanner::readLFEOF ( )
inline

Definition at line 141 of file EasyScanner.h.

void hrp::EasyScanner::readLFEOFex ( const char *  message = 0)
inline

Definition at line 225 of file EasyScanner.h.

void hrp::EasyScanner::readLFex ( const char *  message = 0)
inline

The exception version of readLF().

Definition at line 221 of file EasyScanner.h.

bool EasyScanner::readLine ( )

Definition at line 696 of file EasyScanner.cpp.

bool EasyScanner::readQuotedString ( bool  allowNoQuotedWord = false)

read a quoted string. If 'allowNoQuotedWord' is true, the function read a word without quotations.

Definition at line 613 of file EasyScanner.cpp.

std::string hrp::EasyScanner::readQuotedStringEx ( const char *  message = 0)
inline

Definition at line 206 of file EasyScanner.h.

bool hrp::EasyScanner::readString ( const int  delimiterChar = ',')
inline

In contrast to readWord(), this function allows a string to include siglums such as !,",#,$,%,&,...

Definition at line 112 of file EasyScanner.h.

bool EasyScanner::readString ( const char *  str)

Definition at line 593 of file EasyScanner.cpp.

bool hrp::EasyScanner::readString ( const std::string &  str)
inline

Definition at line 119 of file EasyScanner.h.

bool EasyScanner::readString0 ( const int  delimiterChar)
private

Definition at line 572 of file EasyScanner.cpp.

std::string hrp::EasyScanner::readStringEx ( const char *  message = 0)
inline

The exception version of readString().

Returns
Scanned word string.

Definition at line 201 of file EasyScanner.h.

bool EasyScanner::readSymbol ( )

Definition at line 649 of file EasyScanner.cpp.

bool EasyScanner::readSymbol ( int  id)

Definition at line 662 of file EasyScanner.cpp.

int hrp::EasyScanner::readSymbolEx ( const char *  message = 0)
inline

The exception version of readSymbol().

Returns
ID of the scanned symbol.

Definition at line 214 of file EasyScanner.h.

int EasyScanner::readToken ( )

Definition at line 388 of file EasyScanner.cpp.

bool EasyScanner::readUnquotedTextBlock ( )

Definition at line 628 of file EasyScanner.cpp.

bool hrp::EasyScanner::readWord ( )
inline

In contrast to readString(), this function does not recognize siglums except '_' as a part of a word.

Definition at line 103 of file EasyScanner.h.

bool EasyScanner::readWord0 ( )
private

Definition at line 551 of file EasyScanner.cpp.

std::string hrp::EasyScanner::readWordEx ( const char *  message = 0)
inline

The exception version of readWord().

Returns
Scanned word string.

Definition at line 192 of file EasyScanner.h.

void hrp::EasyScanner::registerSymbol ( int  id,
const std::string &  symbol 
)
inline

Definition at line 61 of file EasyScanner.h.

void EasyScanner::setCommentChar ( char  cc)

if 0, comment is disabled

This function sets the identifier character of comment beginning.

Parameters
ccIdentifier character. Default is '#'. If you want no comment, set 0.

Definition at line 241 of file EasyScanner.cpp.

void hrp::EasyScanner::setDefaultErrorMessage ( const std::string &  message)
inline

Definition at line 83 of file EasyScanner.h.

void EasyScanner::setLineNumberOffset ( int  offset)

Definition at line 198 of file EasyScanner.cpp.

void EasyScanner::setLineOriented ( bool  on)

Definition at line 247 of file EasyScanner.cpp.

void EasyScanner::setQuoteChar ( char  qs)

If you want to read quoted string, set quote character by this function. In default, this is unset.

Definition at line 264 of file EasyScanner.cpp.

void EasyScanner::setText ( const char *  text,
int  len 
)

This function directly sets a text in the main memory

Definition at line 177 of file EasyScanner.cpp.

void EasyScanner::setWhiteSpaceChar ( char  ws)

If there is a character to ignore, you can set it by this function

Definition at line 254 of file EasyScanner.cpp.

bool EasyScanner::skipBlankLines ( )

Definition at line 719 of file EasyScanner.cpp.

bool EasyScanner::skipLine ( )

Definition at line 682 of file EasyScanner.cpp.

void EasyScanner::skipSpace ( )

Definition at line 319 of file EasyScanner.cpp.

void EasyScanner::skipToLineEnd ( )
inlineprivate

move the current position to just before the end (LF or EOF) of a line

Definition at line 313 of file EasyScanner.cpp.

void EasyScanner::throwException ( const char *  message)

Definition at line 221 of file EasyScanner.cpp.

void EasyScanner::throwException ( const std::string &  message)

Definition at line 231 of file EasyScanner.cpp.

void EasyScanner::toLower ( )

This function makes all the characters in stringValue lower case

Definition at line 445 of file EasyScanner.cpp.

Friends And Related Function Documentation

HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
double &  value 
)
friend

Definition at line 733 of file EasyScanner.cpp.

HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
int value 
)
friend

Definition at line 743 of file EasyScanner.cpp.

HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
const char *  matchString 
)
friend

Definition at line 754 of file EasyScanner.cpp.

HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
char  matchChar 
)
friend

Definition at line 766 of file EasyScanner.cpp.

HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
std::string &  str 
)
friend
HRP_UTIL_EXPORT EasyScanner& operator>> ( EasyScanner scanner,
EasyScanner::Endl  endl 
)
friend

Definition at line 787 of file EasyScanner.cpp.

Member Data Documentation

char hrp::EasyScanner::charValue

Definition at line 232 of file EasyScanner.h.

int hrp::EasyScanner::commentChar
private

Definition at line 255 of file EasyScanner.h.

std::string hrp::EasyScanner::defaultErrorMessage

Definition at line 235 of file EasyScanner.h.

double hrp::EasyScanner::doubleValue

Definition at line 230 of file EasyScanner.h.

Endl hrp::EasyScanner::endl

Definition at line 52 of file EasyScanner.h.

std::string hrp::EasyScanner::filename

Definition at line 240 of file EasyScanner.h.

int hrp::EasyScanner::intValue

Definition at line 229 of file EasyScanner.h.

bool hrp::EasyScanner::isLineOriented
private

Definition at line 257 of file EasyScanner.h.

int hrp::EasyScanner::lineNumber

Definition at line 236 of file EasyScanner.h.

int hrp::EasyScanner::lineNumberOffset
private

Definition at line 254 of file EasyScanner.h.

int hrp::EasyScanner::quoteChar
private

Definition at line 256 of file EasyScanner.h.

int hrp::EasyScanner::size
private

Definition at line 252 of file EasyScanner.h.

std::string hrp::EasyScanner::stringValue

Definition at line 231 of file EasyScanner.h.

SymbolMapPtr hrp::EasyScanner::symbols
private

Definition at line 261 of file EasyScanner.h.

int hrp::EasyScanner::symbolValue

Definition at line 233 of file EasyScanner.h.

char* hrp::EasyScanner::text

Definition at line 238 of file EasyScanner.h.

char* hrp::EasyScanner::textBuf
private

Definition at line 251 of file EasyScanner.h.

char* hrp::EasyScanner::textBufEnd
private

Definition at line 253 of file EasyScanner.h.

std::vector<int> hrp::EasyScanner::whiteSpaceChars
private

Definition at line 259 of file EasyScanner.h.


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


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:31