Choreonoid  1.1
構成 | Public 型 | Public メソッド | Public 変数 | フレンド | すべてのメンバ一覧
クラス cnoid::EasyScanner

#include <EasyScanner.h>

構成

class  Endl
 
class  Exception
 

Public 型

enum  TokenType {
  T_NONE = 0, T_SPACE, T_ALPHABET, T_INTEGER,
  T_DOUBLE, T_WORD, T_STRING, T_SIGLUM,
  T_LF, T_EOF
}
 
typedef std::map< std::string,
int > 
SymbolMap
 
typedef std::pair< std::string,
int > 
SymbolPair
 
typedef boost::shared_ptr
< SymbolMap
SymbolMapPtr
 

Public メソッド

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

Public 変数

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

フレンド

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

説明

TODO:
introduce a pimpl to hide the use of map, vector

型定義

typedef std::map<std::string, int> cnoid::EasyScanner::SymbolMap
typedef boost::shared_ptr<SymbolMap> cnoid::EasyScanner::SymbolMapPtr
typedef std::pair<std::string, int> cnoid::EasyScanner::SymbolPair

列挙型

列挙型の値
T_NONE 
T_SPACE 
T_ALPHABET 
T_INTEGER 
T_DOUBLE 
T_WORD 
T_STRING 
T_SIGLUM 
T_LF 
T_EOF 

コンストラクタとデストラクタ

EasyScanner::EasyScanner ( )
EasyScanner::EasyScanner ( std::string  filename)
引数
filenamefile to read.
EasyScanner::EasyScanner ( const EasyScanner org,
bool  copyText = false 
)

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

引数
scanneroriginal object
copy_textIf true, new object has same text as original
EasyScanner::~EasyScanner ( )
virtual

関数

bool EasyScanner::checkLF ( )
int cnoid::EasyScanner::getSymbolID ( const std::string &  symbol)
inline
bool cnoid::EasyScanner::isEOF ( )
inline
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.

void EasyScanner::moveToHead ( )
int EasyScanner::peekChar ( )
void EasyScanner::putSymbols ( )
bool EasyScanner::readChar ( )
bool EasyScanner::readChar ( int  chara)
int cnoid::EasyScanner::readCharEx ( const char *  message = 0)
inline

The exception version of readChar().

戻り値
Scanned char value.
void cnoid::EasyScanner::readCharEx ( int  chara,
const char *  message = 0 
)
inline

The exception version of readChar().

bool EasyScanner::readDouble ( )
double cnoid::EasyScanner::readDoubleEx ( const char *  message = 0)
inline

The exception version of readDouble().

戻り値
Scanned double value.
bool EasyScanner::readInt ( )
int cnoid::EasyScanner::readIntEx ( const char *  message = 0)
inline

The exception version of readInt().

戻り値
Scanned int value.
bool cnoid::EasyScanner::readLF ( )
inline

reading a line feed

bool cnoid::EasyScanner::readLFEOF ( )
inline
void cnoid::EasyScanner::readLFEOFex ( const char *  message = 0)
inline
void cnoid::EasyScanner::readLFex ( const char *  message = 0)
inline

The exception version of readLF().

bool EasyScanner::readLine ( )
bool EasyScanner::readQuotedString ( bool  allowNoQuotedWord = false)

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

std::string cnoid::EasyScanner::readQuotedStringEx ( const char *  message = 0)
inline
bool cnoid::EasyScanner::readString ( const int  delimiterChar = ',')
inline

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

bool EasyScanner::readString ( const char *  str)
bool cnoid::EasyScanner::readString ( const std::string &  str)
inline
std::string cnoid::EasyScanner::readStringEx ( const char *  message = 0)
inline

The exception version of readString().

戻り値
Scanned word string.
bool EasyScanner::readSymbol ( )
bool EasyScanner::readSymbol ( int  id)
int cnoid::EasyScanner::readSymbolEx ( const char *  message = 0)
inline

The exception version of readSymbol().

戻り値
ID of the scanned symbol.
int EasyScanner::readToken ( )
bool EasyScanner::readUnquotedTextBlock ( )
bool cnoid::EasyScanner::readWord ( )
inline

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

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

The exception version of readWord().

戻り値
Scanned word string.
void cnoid::EasyScanner::registerSymbol ( int  id,
const std::string &  symbol 
)
inline
void EasyScanner::setCommentChar ( char  cc)

if 0, comment is disabled

This function sets the identifier character of comment beginning.

引数
ccIdentifier character. Default is '#'. If you want no comment, set 0.
void cnoid::EasyScanner::setDefaultErrorMessage ( const std::string &  message)
inline
void EasyScanner::setLineNumberOffset ( int  offset)
void EasyScanner::setLineOriented ( bool  on)
void EasyScanner::setQuoteChar ( char  qs)

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

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

This function directly sets a text in the main memory

void EasyScanner::setWhiteSpaceChar ( char  ws)

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

bool EasyScanner::skipBlankLines ( )
bool EasyScanner::skipLine ( )
void EasyScanner::skipSpace ( )
void EasyScanner::throwException ( const char *  message)
void EasyScanner::throwException ( const std::string &  message)
void EasyScanner::toLower ( )

This function makes all the characters in stringValue lower case

フレンドと関連する関数

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

変数

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

このクラスの説明は次のファイルから生成されました: