00001 /* 00002 Copyright (C) 2001-2006, William Joseph. 00003 All Rights Reserved. 00004 00005 This file is part of GtkRadiant. 00006 00007 GtkRadiant is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 GtkRadiant is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GtkRadiant; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #if !defined(INCLUDED_ISCRIPLIB_H) 00023 #define INCLUDED_ISCRIPLIB_H 00024 00027 00028 #include <cstddef> 00029 #include <string> 00030 #include "generic/constant.h" 00031 00032 #define MAXTOKEN 1024 00033 00034 class Tokeniser 00035 { 00036 public: 00037 virtual ~Tokeniser () 00038 { 00039 } 00040 virtual const std::string getToken () = 0; 00041 virtual void ungetToken () = 0; 00042 virtual std::size_t getLine () const = 0; 00043 virtual std::size_t getColumn () const = 0; 00044 }; 00045 00046 class TextInputStream; 00047 00048 class TokenWriter 00049 { 00050 public: 00051 virtual ~TokenWriter () 00052 { 00053 } 00054 virtual void nextLine () = 0; 00055 virtual void writeToken (const char* token) = 0; 00056 virtual void writeString (const char* string) = 0; 00057 virtual void writeInteger (int i) = 0; 00058 virtual void writeUnsigned (std::size_t i) = 0; 00059 virtual void writeFloat (double f) = 0; 00060 }; 00061 00062 class TextOutputStream; 00063 00064 struct _QERScripLibTable 00065 { 00066 INTEGER_CONSTANT(Version, 1); 00067 STRING_CONSTANT(Name, "scriptlib"); 00068 00069 Tokeniser* (*m_pfnNewScriptTokeniser) (TextInputStream& istream); 00070 Tokeniser* (*m_pfnNewSimpleTokeniser) (TextInputStream& istream); 00071 TokenWriter* (*m_pfnNewSimpleTokenWriter) (TextOutputStream& ostream); 00072 }; 00073 00074 #include "modulesystem.h" 00075 00076 template<typename Type> 00077 class GlobalModule; 00078 typedef GlobalModule<_QERScripLibTable> GlobalScripLibModule; 00079 00080 template<typename Type> 00081 class GlobalModuleRef; 00082 typedef GlobalModuleRef<_QERScripLibTable> GlobalScripLibModuleRef; 00083 00084 inline _QERScripLibTable& GlobalScriptLibrary () 00085 { 00086 return GlobalScripLibModule::getTable(); 00087 } 00088 00089 #endif