Gnash
0.8.10
|
00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 00003 // Free Software Foundation, Inc 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 00020 #ifndef GNASH_AMFCONVERTER_H 00021 #define GNASH_AMFCONVERTER_H 00022 00023 #include <map> 00024 #include <string> 00025 #include <vector> 00026 00027 #include "dsodefs.h" 00028 #include "AMF.h" 00029 00030 namespace gnash { 00031 class as_object; 00032 class as_value; 00033 class SimpleBuffer; 00034 class Global_as; 00035 } 00036 00037 namespace gnash { 00038 00040 // 00044 namespace amf { 00045 00047 // 00050 // 00055 class Writer 00056 { 00057 public: 00058 00059 typedef std::map<as_object*, size_t> OffsetTable; 00060 00061 Writer(SimpleBuffer& buf, bool strictArray = false) 00062 : 00063 _buf(buf), 00064 _strictArray(strictArray) 00065 {} 00066 00068 // 00070 bool writeObject(as_object* obj); 00071 00073 // 00075 bool writeString(const std::string& str); 00076 00078 bool writeNull(); 00079 00081 bool writeUndefined(); 00082 00084 bool writeNumber(double d); 00085 00087 bool writeBoolean(bool b); 00088 00090 // 00092 bool writePropertyName(const std::string& name); 00093 00095 void writeData(const boost::uint8_t* data, size_t length); 00096 00097 private: 00098 00099 OffsetTable _offsets; 00100 SimpleBuffer& _buf; 00101 bool _strictArray; 00102 00103 }; 00104 00105 00107 // 00111 // 00115 // 00121 class Reader 00122 { 00123 public: 00124 00126 // 00129 // 00135 Reader(const boost::uint8_t*& pos, const boost::uint8_t* end, Global_as& gl) 00136 : 00137 _pos(pos), 00138 _end(end), 00139 _global(gl) 00140 {} 00141 00143 // 00149 bool operator()(as_value& val, Type t = NOTYPE); 00150 00151 private: 00152 00154 as_value readXML(); 00155 00157 as_value readDate(); 00158 00160 as_value readObject(); 00161 00163 as_value readReference(); 00164 00166 as_value readArray(); 00167 00169 as_value readStrictArray(); 00170 00172 std::vector<as_object*> _objectRefs; 00173 00175 const boost::uint8_t*& _pos; 00176 00178 const boost::uint8_t* const _end; 00179 00181 Global_as& _global; 00182 00183 }; 00184 00185 } // namespace amf 00186 } // namespace gnash 00187 00188 #endif