00001 #ifndef IONFLUX_TOOLS_UTF8TOKENTYPEMAP 00002 #define IONFLUX_TOOLS_UTF8TOKENTYPEMAP 00003 /* ========================================================================== 00004 * Ionflux Tools 00005 * Copyright (c) 2005 Joern P. Meier 00006 * mail@ionflux.org 00007 * -------------------------------------------------------------------------- 00008 * Utf8TokenTypeMap.hpp Token type map with UTF-8 support. 00009 * ========================================================================== 00010 * 00011 * This file is part of Ionflux Tools. 00012 * 00013 * Ionflux Tools is free software; you can redistribute it and/or modify it 00014 * under the terms of the GNU General Public License as published by the 00015 * Free Software Foundation; either version 2 of the License, or (at your 00016 * option) any later version. 00017 * 00018 * Ionflux Tools is distributed in the hope that it will be useful, but 00019 * WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along 00024 * with Ionflux Tools; if not, write to the Free Software Foundation, Inc., 00025 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 * 00027 * ========================================================================== */ 00028 00029 #include <string> 00030 #include <vector> 00031 #include <map> 00032 #include "ionflux/ManagedObject.hpp" 00033 00034 namespace Ionflux 00035 { 00036 00037 namespace Tools 00038 { 00039 00040 struct Utf8TokenType; 00041 00042 typedef std::map<unsigned int, Ionflux::Tools::Utf8TokenType*> ImplTokenTypeMap; 00043 00047 struct Utf8TokenType 00048 { 00050 int typeID; 00052 std::string validChars; 00054 unsigned int maxChars; 00056 static const int USERTYPE_ID; 00058 static const int INVALID_ID; 00060 static const int EMPTY_ID; 00061 }; 00062 00064 class Utf8TokenTypeMapClassInfo 00065 : public Ionflux::Tools::ClassInfo 00066 { 00067 public: 00069 Utf8TokenTypeMapClassInfo(); 00071 virtual ~Utf8TokenTypeMapClassInfo() { }; 00072 }; 00073 00079 class Utf8TokenTypeMap 00080 : public Ionflux::Tools::ManagedObject 00081 { 00082 private: 00083 00084 protected: 00086 std::vector<Utf8TokenType*> tokenTypes; 00088 ImplTokenTypeMap typeMap; 00090 Utf8TokenType* defaultTokenType; 00091 00092 public: 00094 static const Utf8TokenTypeMapClassInfo utf8TokenTypeMapClassInfo; 00096 static const Ionflux::Tools::ClassInfo* CLASS_INFO; 00097 00102 Utf8TokenTypeMap(); 00103 00108 virtual ~Utf8TokenTypeMap(); 00109 00114 virtual void clear(); 00115 00122 virtual unsigned int getNumTokenTypes(); 00123 00130 virtual void addTokenType(const Utf8TokenType& newTokenType); 00131 00138 virtual void removeTokenType(const Utf8TokenType& removeTokenType); 00139 00147 virtual void setDefaultTokenType(const Utf8TokenType& 00148 newDefaultTokenType); 00149 00158 virtual Utf8TokenType getTokenType(unsigned int testChar); 00159 00170 static bool isValid(const Utf8TokenType& checkTokenType); 00171 }; 00172 00173 } 00174 00175 } 00176 00180 #endif