Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }
00186 }
00187
00188 #endif