Gnash  0.8.11dev
AMFConverter.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 
20 #ifndef GNASH_AMFCONVERTER_H
21 #define GNASH_AMFCONVERTER_H
22 
23 #include <map>
24 #include <string>
25 #include <vector>
26 
27 #include "dsodefs.h"
28 #include "AMF.h"
29 
30 namespace gnash {
31  class as_object;
32  class as_value;
33  class SimpleBuffer;
34  class Global_as;
35 }
36 
37 namespace gnash {
38 
40 //
44 namespace amf {
45 
47 //
50 //
55 class Writer
56 {
57 public:
58 
59  typedef std::map<as_object*, size_t> OffsetTable;
60 
61  Writer(SimpleBuffer& buf, bool strictArray = false)
62  :
63  _buf(buf),
64  _strictArray(strictArray)
65  {}
66 
68  //
70  bool writeObject(as_object* obj);
71 
73  //
75  bool writeString(const std::string& str);
76 
78  bool writeNull();
79 
81  bool writeUndefined();
82 
84  bool writeNumber(double d);
85 
87  bool writeBoolean(bool b);
88 
90  //
92  bool writePropertyName(const std::string& name);
93 
95  void writeData(const std::uint8_t* data, size_t length);
96 
97 private:
98 
99  OffsetTable _offsets;
100  SimpleBuffer& _buf;
101  bool _strictArray;
102 
103 };
104 
105 
107 //
111 //
115 //
121 class Reader
122 {
123 public:
124 
126  //
129  //
135  Reader(const std::uint8_t*& pos, const std::uint8_t* end, Global_as& gl)
136  :
137  _pos(pos),
138  _end(end),
139  _global(gl)
140  {}
141 
143  //
149  bool operator()(as_value& val, Type t = NOTYPE);
150 
151 private:
152 
154  as_value readXML();
155 
157  as_value readDate();
158 
160  as_value readObject();
161 
163  as_value readReference();
164 
166  as_value readArray();
167 
169  as_value readStrictArray();
170 
172  std::vector<as_object*> _objectRefs;
173 
175  const std::uint8_t*& _pos;
176 
178  const std::uint8_t* const _end;
179 
181  Global_as& _global;
182 
183 };
184 
185 } // namespace amf
186 } // namespace gnash
187 
188 #endif
bool writeNumber(double d)
Write a double.
Definition: AMFConverter.cpp:258
Definition: GnashKey.h:150
std::map< as_object *, size_t > OffsetTable
Definition: AMFConverter.h:59
ActionScript value type.
Definition: as_value.h:94
bool writeBoolean(bool b)
Write a boolean.
Definition: AMFConverter.cpp:265
bool writeUndefined()
Write an undefined value.
Definition: AMFConverter.cpp:273
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
bool writeObject(as_object *obj)
Write any simple Object type: not DisplayObjects.
Definition: AMFConverter.cpp:122
A class to compose AMF buffers.
Definition: AMFConverter.h:55
bool writeNull()
Write a null value.
Definition: AMFConverter.cpp:283
The base class for all ActionScript objects.
Definition: as_object.h:161
Type
Definition: AMF.h:45
bool writePropertyName(const std::string &name)
Encode the name of an object&#39;s property.
Definition: AMFConverter.cpp:115
Reader(const std::uint8_t *&pos, const std::uint8_t *end, Global_as &gl)
Construct a Reader with pointers into an AMF buffer.
Definition: AMFConverter.h:135
Definition: GnashKey.h:166
Definition: klash_part.cpp:329
Deserialize an AMF buffer to as_values.
Definition: AMFConverter.h:121
Definition: GnashKey.h:148
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:49
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
A simple buffer of bytes.
Definition: SimpleBuffer.h:38
Definition: AMF.h:46
std::string name
Definition: LocalConnection_as.cpp:149
bool writeString(const std::string &str)
Write a string.
Definition: AMFConverter.cpp:251
Writer(SimpleBuffer &buf, bool strictArray=false)
Definition: AMFConverter.h:61
void writeData(const std::uint8_t *data, size_t length)
Write custom data for special cases.
Definition: AMFConverter.cpp:293