00001 /* libobby - Network text editing library 00002 * Copyright (C) 2005 0x539 dev group 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public 00015 * License along with this program; if not, write to the Free 00016 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef _OBBY_SERIALISE_TOKEN_HPP_ 00020 #define _OBBY_SERIALISE_TOKEN_HPP_ 00021 00022 #include <string> 00023 #include <list> 00024 00025 namespace obby 00026 { 00027 00028 namespace serialise 00029 { 00030 00031 class token 00032 { 00033 public: 00034 enum type 00035 { 00036 TYPE_UNKNOWN, 00037 00038 TYPE_INDENTATION, 00039 TYPE_EXCLAMATION, 00040 TYPE_IDENTIFIER, 00041 TYPE_STRING, 00042 TYPE_ASSIGNMENT 00043 }; 00044 00045 token( 00046 type type, 00047 const std::string& text, 00048 unsigned int line 00049 ); 00050 00051 type get_type() const; 00052 const std::string& get_text() const; 00053 unsigned int get_line() const; 00054 private: 00055 type m_type; 00056 std::string m_text; 00057 unsigned int m_line; 00058 }; 00059 00060 class token_list 00061 { 00062 public: 00063 typedef std::list<token> list_type; 00064 typedef list_type::const_iterator iterator; 00065 00066 token_list(); 00067 00068 void serialise(std::string& string) const; 00069 void deserialise(const std::string& string); 00070 00071 void add( 00072 token::type type, 00073 const std::string& text, 00074 unsigned int line 00075 ); 00076 00077 iterator begin() const; 00078 iterator end() const; 00079 00085 void next_token( 00086 iterator& iter 00087 ) const; 00088 private: 00089 list_type m_list; 00090 }; 00091 00092 } // namespace serialise 00093 00094 } // namespace obby 00095 00096 #endif // _OBBY_SERIALISE_TOKEN_HPP_
1.5.1