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

◆ SymbolMap

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

Definition at line 48 of file EasyScanner.h.

◆ SymbolMapPtr

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

Definition at line 50 of file EasyScanner.h.

◆ SymbolPair

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

Definition at line 49 of file EasyScanner.h.

Member Enumeration Documentation

◆ TokenType

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() [1/3]

EasyScanner::EasyScanner ( )

Definition at line 122 of file EasyScanner.cpp.

◆ EasyScanner() [2/3]

hrp::EasyScanner::EasyScanner ( std::string  filename)

◆ EasyScanner() [3/3]

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 162 of file EasyScanner.cpp.

◆ ~EasyScanner()

EasyScanner::~EasyScanner ( )
virtual

Definition at line 205 of file EasyScanner.cpp.

Member Function Documentation

◆ checkLF()

bool EasyScanner::checkLF ( )

Definition at line 390 of file EasyScanner.cpp.

◆ extractQuotedString()

int EasyScanner::extractQuotedString ( )
private

Definition at line 466 of file EasyScanner.cpp.

◆ getSymbolID()

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

Definition at line 65 of file EasyScanner.h.

◆ init()

void EasyScanner::init ( )
private

Definition at line 138 of file EasyScanner.cpp.

◆ isEOF()

bool hrp::EasyScanner::isEOF ( )
inline

Definition at line 130 of file EasyScanner.h.

◆ loadFile()

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 287 of file EasyScanner.cpp.

◆ moveToHead()

void EasyScanner::moveToHead ( )

Definition at line 217 of file EasyScanner.cpp.

◆ peekChar()

int EasyScanner::peekChar ( )

Definition at line 556 of file EasyScanner.cpp.

◆ putSymbols()

void EasyScanner::putSymbols ( )

Definition at line 224 of file EasyScanner.cpp.

◆ readChar() [1/2]

bool EasyScanner::readChar ( )

Definition at line 530 of file EasyScanner.cpp.

◆ readChar() [2/2]

bool EasyScanner::readChar ( int  chara)

Definition at line 544 of file EasyScanner.cpp.

◆ readCharEx() [1/2]

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.

◆ readCharEx() [2/2]

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

The exception version of readChar().

Definition at line 185 of file EasyScanner.h.

◆ readDouble()

bool EasyScanner::readDouble ( )

Definition at line 498 of file EasyScanner.cpp.

◆ readDoubleEx()

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.

◆ readInt()

bool EasyScanner::readInt ( )

Definition at line 514 of file EasyScanner.cpp.

◆ readIntEx()

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.

◆ readLF()

bool hrp::EasyScanner::readLF ( )
inline

reading a line feed

Definition at line 136 of file EasyScanner.h.

◆ readLF0()

bool EasyScanner::readLF0 ( )
private

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

Definition at line 372 of file EasyScanner.cpp.

◆ readLFEOF()

bool hrp::EasyScanner::readLFEOF ( )
inline

Definition at line 141 of file EasyScanner.h.

◆ readLFEOFex()

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

Definition at line 225 of file EasyScanner.h.

◆ readLFex()

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

The exception version of readLF().

Definition at line 221 of file EasyScanner.h.

◆ readLine()

bool EasyScanner::readLine ( )

Definition at line 709 of file EasyScanner.cpp.

◆ readQuotedString()

bool EasyScanner::readQuotedString ( bool  allowNoQuotedWord = false)

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

Definition at line 626 of file EasyScanner.cpp.

◆ readQuotedStringEx()

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

Definition at line 206 of file EasyScanner.h.

◆ readString() [1/3]

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.

◆ readString() [2/3]

bool EasyScanner::readString ( const char *  str)

Definition at line 606 of file EasyScanner.cpp.

◆ readString() [3/3]

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

Definition at line 119 of file EasyScanner.h.

◆ readString0()

bool EasyScanner::readString0 ( const int  delimiterChar)
private

Definition at line 585 of file EasyScanner.cpp.

◆ readStringEx()

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.

◆ readSymbol() [1/2]

bool EasyScanner::readSymbol ( )

Definition at line 662 of file EasyScanner.cpp.

◆ readSymbol() [2/2]

bool EasyScanner::readSymbol ( int  id)

Definition at line 675 of file EasyScanner.cpp.

◆ readSymbolEx()

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.

◆ readToken()

int EasyScanner::readToken ( )

Definition at line 401 of file EasyScanner.cpp.

◆ readUnquotedTextBlock()

bool EasyScanner::readUnquotedTextBlock ( )

Definition at line 641 of file EasyScanner.cpp.

◆ readWord()

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.

◆ readWord0()

bool EasyScanner::readWord0 ( )
private

Definition at line 564 of file EasyScanner.cpp.

◆ readWordEx()

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.

◆ registerSymbol()

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

Definition at line 61 of file EasyScanner.h.

◆ setCommentChar()

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 254 of file EasyScanner.cpp.

◆ setDefaultErrorMessage()

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

Definition at line 83 of file EasyScanner.h.

◆ setLineNumberOffset()

void EasyScanner::setLineNumberOffset ( int  offset)

Definition at line 211 of file EasyScanner.cpp.

◆ setLineOriented()

void EasyScanner::setLineOriented ( bool  on)

Definition at line 260 of file EasyScanner.cpp.

◆ setQuoteChar()

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 277 of file EasyScanner.cpp.

◆ setText()

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

This function directly sets a text in the main memory

Definition at line 190 of file EasyScanner.cpp.

◆ setWhiteSpaceChar()

void EasyScanner::setWhiteSpaceChar ( char  ws)

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

Definition at line 267 of file EasyScanner.cpp.

◆ skipBlankLines()

bool EasyScanner::skipBlankLines ( )

Definition at line 732 of file EasyScanner.cpp.

◆ skipLine()

bool EasyScanner::skipLine ( )

Definition at line 695 of file EasyScanner.cpp.

◆ skipSpace()

void EasyScanner::skipSpace ( )

Definition at line 332 of file EasyScanner.cpp.

◆ skipToLineEnd()

void EasyScanner::skipToLineEnd ( )
inlineprivate

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

Definition at line 326 of file EasyScanner.cpp.

◆ throwException() [1/2]

void EasyScanner::throwException ( const char *  message)

Definition at line 234 of file EasyScanner.cpp.

◆ throwException() [2/2]

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

Definition at line 244 of file EasyScanner.cpp.

◆ toLower()

void EasyScanner::toLower ( )

This function makes all the characters in stringValue lower case

Definition at line 458 of file EasyScanner.cpp.

Friends And Related Function Documentation

◆ operator>> [1/6]

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

Definition at line 746 of file EasyScanner.cpp.

◆ operator>> [2/6]

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

Definition at line 756 of file EasyScanner.cpp.

◆ operator>> [3/6]

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

Definition at line 767 of file EasyScanner.cpp.

◆ operator>> [4/6]

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

Definition at line 779 of file EasyScanner.cpp.

◆ operator>> [5/6]

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

◆ operator>> [6/6]

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

Definition at line 800 of file EasyScanner.cpp.

Member Data Documentation

◆ charValue

char hrp::EasyScanner::charValue

Definition at line 232 of file EasyScanner.h.

◆ commentChar

int hrp::EasyScanner::commentChar
private

Definition at line 255 of file EasyScanner.h.

◆ defaultErrorMessage

std::string hrp::EasyScanner::defaultErrorMessage

Definition at line 235 of file EasyScanner.h.

◆ doubleValue

double hrp::EasyScanner::doubleValue

Definition at line 230 of file EasyScanner.h.

◆ endl

Endl hrp::EasyScanner::endl

Definition at line 52 of file EasyScanner.h.

◆ filename

std::string hrp::EasyScanner::filename

Definition at line 240 of file EasyScanner.h.

◆ intValue

int hrp::EasyScanner::intValue

Definition at line 229 of file EasyScanner.h.

◆ isLineOriented

bool hrp::EasyScanner::isLineOriented
private

Definition at line 257 of file EasyScanner.h.

◆ lineNumber

int hrp::EasyScanner::lineNumber

Definition at line 236 of file EasyScanner.h.

◆ lineNumberOffset

int hrp::EasyScanner::lineNumberOffset
private

Definition at line 254 of file EasyScanner.h.

◆ quoteChar

int hrp::EasyScanner::quoteChar
private

Definition at line 256 of file EasyScanner.h.

◆ size

int hrp::EasyScanner::size
private

Definition at line 252 of file EasyScanner.h.

◆ stringValue

std::string hrp::EasyScanner::stringValue

Definition at line 231 of file EasyScanner.h.

◆ symbols

SymbolMapPtr hrp::EasyScanner::symbols
private

Definition at line 261 of file EasyScanner.h.

◆ symbolValue

int hrp::EasyScanner::symbolValue

Definition at line 233 of file EasyScanner.h.

◆ text

char* hrp::EasyScanner::text

Definition at line 238 of file EasyScanner.h.

◆ textBuf

char* hrp::EasyScanner::textBuf
private

Definition at line 251 of file EasyScanner.h.

◆ textBufEnd

char* hrp::EasyScanner::textBufEnd
private

Definition at line 253 of file EasyScanner.h.

◆ whiteSpaceChars

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 Thu Sep 8 2022 02:24:08