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

robdefines.h

Go to the documentation of this file.
00001 /*
00002  * robdefines.h
00003  * 
00004  * Copyright (c) 2000-2004 by Florian Fischer (florianfischer@gmx.de)
00005  * and Martin Trautmann (martintrautmann@gmx.de) 
00006  * 
00007  * This file may be distributed and/or modified under the terms of the 
00008  * GNU General Public License version 2 as published by the Free Software 
00009  * Foundation. 
00010  * 
00011  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013  * 
00014  */
00015 
00021 #ifndef __RT_DEFINESTREAM__
00022 #define __RT_DEFINESTREAM__
00023 
00024 #include "robvars.h"
00025 
00026 #include <rtstring.h>
00027 #include <rtcollect.h>
00028 #include <rtstreams.h>
00029 #include <rtmap.h>
00030 
00031 using namespace lrt;
00032 
00033 namespace rt {
00034 
00036 class DefineInputStream : public InputStream  {
00037 public:
00038         static const String whitespace;
00039         DefineInputStream(InputStream *in, const String &separators, const char commentStart = 0);
00040         virtual void close();
00041         virtual ~DefineInputStream();
00042 
00043         void setIgnoreComments(bool);
00044         void setAutoTrim(bool);
00045         void setEnableDefines(bool);
00046         
00047         virtual void mark();
00048         virtual void reset();
00049         virtual bool markSupported();
00050         virtual bool fail();
00051 
00052         virtual int read();
00053         RobLoadReturnType getWord(String& word, const String& specialSeps = "");
00054         String getLine(bool skipEmpty = true);
00055 
00056         int getLineNumber();
00057         bool skipRestOfLine();
00058 
00059         bool eos();
00060 
00063         bool isIdentifierValid(const String& str);
00064 
00065 private:
00066         class Define {
00067         public:
00068                 Define(const String& name = "");
00069                 ~Define() {}
00070 
00071                 InputStream* getStream();
00072 
00073                 String name, value;
00074                 Vector<String> params;
00075                 int lineOffset;
00076         };
00077 
00078         class StreamInfo {
00079         public:
00080                 StreamInfo();
00081                 StreamInfo(Define& define);
00082                 ~StreamInfo();
00083 
00084                 int lineNum;
00085                 int lineOffset;
00086                 int buf;
00087                 bool eol;
00088                 StringMap<String> params;
00089         };
00090 
00091         class StringInStream : public InputStream {
00092         public:
00093                 StringInStream(const String&);
00094                 virtual ~StringInStream() {}
00095                 virtual int read();
00096                 bool eos();
00097         private:
00098                 const String& str;
00099                 int pos;
00100         };
00101 
00102         void unread(int c);
00103         RobLoadReturnType readParams(StringMap<String>& params, Vector<String>& paramNames);
00104         RobLoadReturnType createDefine();
00105         
00106         Vector<StreamInfo> infos;
00107         Vector<InputStream*> streams;
00108         StringMap<Define> defineMap;
00109 
00110         enum {
00111                 identCharInvalid = 0x00,
00112                 identCharValidFirst = 0x01,
00113                 identCharValidNext = 0x02,
00114                 identCharValidAlways = 0x03
00115         };
00116 
00117         int validAsIdentifierChar[256];
00118         void initValidIdentifierChars();
00119 
00120         int markLineNum;
00121         String separators;
00122         char commentStart;
00123         bool ignoreComments, autoTrim, defines;
00124         int curStream;
00125 };
00126 
00127 } // namespace
00128 
00129 #endif 

This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer