Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

StreamTokenizer.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ストリームトークナイザヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef STREAM_TOKENIZER_H_
00026 #define STREAM_TOKENIZER_H_
00027 
00028 #include <Core/Utility/StringTokenizer.h>
00029 
00030 namespace Lamp{
00031 
00032 class TextReader;
00033 
00034 //------------------------------------------------------------------------------
00035 /**
00036  * ストリームトークナイザ
00037  */
00038 class StreamTokenizer{
00039 public:
00040     /**
00041      * コンストラクタ
00042      * @param reader テキストリーダ
00043      * @param delimiter デリミタ、改行は強制的にデリミタとなります。
00044      */
00045     StreamTokenizer(TextReader* reader,
00046         const String& delimiter = defaultDelimiter);
00047 
00048     /**
00049      * デストラクタ
00050      */
00051     virtual ~StreamTokenizer();
00052 
00053     /**
00054      * 次のトークン
00055      * @return trueならトークンがある。
00056      */
00057     virtual bool nextToken();
00058 
00059     /**
00060      * トークン取得
00061      * @return トークン
00062      */
00063     virtual String getToken() const{ return nowToken_; }
00064 
00065     /**
00066      * 一つ前のトークン取得
00067      * @return 一つ前のトークン
00068      */
00069     virtual String getPreviousToken() const{ return previousToken_; }
00070 
00071     /**
00072      * スラッシュスラッシュコメントフラグの設定
00073      * @param slashSlash スラッシュスラッシュコメントを有効にするならtrue
00074      */
00075     virtual void setSlashSlashCommentFlag(bool slashSlash){
00076         slashSlash_ = slashSlash;
00077     }
00078 
00079     /**
00080      * スラッシュスラッシュコメントフラグの取得
00081      * @return スラッシュスラッシュコメントが有効ならtrue
00082      */
00083     virtual bool getSlashSlashCommentFlag(){ return slashSlash_; }
00084 
00085     /**
00086      * スラッシュスターコメントフラグの設定
00087      * @param slashStar スラッシュスターコメントを有効にするならtrue
00088      */
00089     virtual void setSlashStarCommentFlag(bool slashStar){
00090         slashStar_ = slashStar;
00091     }
00092 
00093     /**
00094      * スラッシュスターコメントフラグの取得
00095      * @return スラッシュスターコメントが有効ならtrue
00096      */
00097     virtual bool getSlashStarCommentFlag(){ return slashStar_; }
00098 
00099     /**
00100      * 行番号の取得
00101      * @return 行番号
00102      */
00103     virtual int getLineNumber(){ return lineNumber_; }
00104 
00105 private:
00106 
00107     // コピーコンストラクタの隠蔽
00108     StreamTokenizer(const StreamTokenizer& copy);
00109 
00110     // 代入コピーの隠蔽
00111     void operator =(const StreamTokenizer& copy);
00112 
00113     bool checkTokenzier();
00114 
00115     // テキストリーダ
00116     TextReader* reader_;
00117     // 文字列トークナイザ
00118     StringTokenizer tokenizer_;
00119     // デリミタ
00120     String delimiter_;
00121     // 現在のトークン
00122     String nowToken_;
00123     // 一つ前のトークン
00124     String previousToken_;
00125     // スラッシュスラッシュコメント
00126     bool slashSlash_;
00127     // スラッシュスターコメント
00128     bool slashStar_;
00129     // ライン番号
00130     int lineNumber_;
00131 
00132     // デフォルトデリミタ
00133     static const String defaultDelimiter;
00134 
00135 };
00136 
00137 //------------------------------------------------------------------------------
00138 } // End of namespace Lamp
00139 #endif // End of STREAM_TOKENIZER_H_
00140 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:36 2005 for Lamp by doxygen 1.3.2