The Parametric Pseudo-Manifold (PPS) Library 1.0
lexer.h
Go to the documentation of this file.
00001 
00026 #ifndef LEXER_H
00027 #define LEXER_H
00028 
00029 #include <iostream>
00030 #include <string>
00031 
00032 
00046 namespace offlib {
00047 
00048 
00055   class Lexer {
00056   public:
00057     // ---------------------------------------------------------------
00058     //
00059     // Public methods.
00060     //
00061     // ---------------------------------------------------------------
00062 
00070     Lexer(std::istream& is ) : _realstr( is )
00071     {
00072       _line_counter = 0 ;
00073       _char_counter = 0 ;
00074     }
00075 
00076 
00084     bool get_string( std::string& s ) ;
00085 
00086 
00094     bool get_integer( int& x ) ;
00095 
00096 
00105     bool get_double( double& d ) ;
00106 
00107 
00115     inline int get_line_counter() const
00116     { 
00117       return _line_counter ; 
00118     }
00119 
00120 
00128     int get_char_counter() const
00129     { 
00130       return _char_counter ; 
00131     }
00132 
00133   private:
00134     // ---------------------------------------------------------------
00135     //
00136     // Private methods
00137     //
00138     // ---------------------------------------------------------------
00139 
00145     inline void increment_line()
00146     {
00147       ++_line_counter ;
00148       reset_char_counter() ;
00149     }
00150 
00151 
00157     inline void increment_char()
00158     {
00159       ++_char_counter ;
00160     }
00161 
00162 
00168     inline void decrement_char()
00169     {
00170       if ( _char_counter > 0 ) --_char_counter ;
00171     }
00172 
00173 
00179     inline void reset_char_counter()
00180     { 
00181       _char_counter = 0 ; 
00182     }
00183 
00184 
00191     bool skip_space() ;
00192 
00193 
00194     // ---------------------------------------------------------------
00195     //
00196     // Private data members
00197     //
00198     // ---------------------------------------------------------------
00199 
00200     std::istream& _realstr ;  
00201 
00202     int _line_counter ;       
00203 
00204     int _char_counter ;       
00205 
00206   } ;
00207 
00208 }
00209  //end of group class.
00211 
00212 #endif    // LEXER_H