token.h

Go to the documentation of this file.
00001 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005 Copyright (C) 2006  Bernd Opitz
00006 Exclusive copyright is granted to Klaus Schmidt
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #ifndef TOKEN_H
00024 
00025 #include "definitions.h"
00026 #include "helper.h"
00027 #include <string>
00028 #include <iostream>
00029 #include <fstream>
00030 #include <assert.h>
00031 
00032 namespace faudes {
00033 
00052 class Token {
00053 public:
00054 
00058   Token(void);
00059     
00063   Token(const Token& rToken);
00064 
00065 
00069   ~Token(void);
00070 
00074   enum TokenType {
00075     None,      
00076     Begin,     
00077     End,       
00078     String,    
00079     Option,    
00080     Integer,   
00081     Integer16, 
00082     Float      
00083   };
00084 
00085 
00090   void SetNone(void);
00091 
00098   void SetString(const std::string& rName);
00099 
00106   void SetBegin(const std::string& rName);
00107 
00114   void SetEnd(const std::string& rName);
00115 
00122   void SetOption(const std::string& rName);
00123 
00130   void SetInteger(const long int number);
00131 
00138   void SetInteger16(const long int number);
00139 
00146   void SetFloat(const double number);
00147     
00154   long int IntegerValue(void) const {
00155     return(mIntegerValue);
00156   }
00157 
00164   double FloatValue(void) const {
00165     return(mFloatValue);
00166   }
00167 
00174   const std::string& StringValue(void) const {
00175     return(mStringValue);
00176   }
00177 
00184   TokenType Type(void) const {
00185     return(mType);
00186   }
00187 
00196   int Read(std::istream* pStream);
00197 
00206   void Write(std::ostream* pStream); 
00207 
00208 private:
00210   TokenType mType; 
00211     
00213   std::string mStringValue;
00214 
00216   long int mIntegerValue;
00217 
00219   double mFloatValue;
00220 
00221 
00231   bool ReadNumber(std::istream* pStream); 
00232 
00243   bool ReadString(std::istream* pStream, char stop);
00244 
00254   int  ReadSpace(std::istream* pStream);
00255 };
00256 
00257 } // namespace faudes
00258 
00259 #define TOKEN_H
00260 #endif
00261 
00262 

Generated on Fri May 9 11:26:47 2008 for libFAUDES 2.09b by  doxygen 1.4.4