/usr/include/gnash/asobj/AMFConverter.h is in gnash-dev 0.8.11~git20160109-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | //
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef GNASH_AMFCONVERTER_H
#define GNASH_AMFCONVERTER_H
#include <map>
#include <string>
#include <vector>
#include "dsodefs.h"
#include "AMF.h"
namespace gnash {
class as_object;
class as_value;
class SimpleBuffer;
class Global_as;
}
namespace gnash {
/// Functions and classes for handling AMF.
//
/// AMF is a simple serialization format for ActionScript objects and values,
/// allowing them to be stored and transmitted. These classes convert between
/// AMF buffers and the objects they contain.
namespace amf {
/// A class to compose AMF buffers.
//
/// A single amf::Writer class can take successive values and encode them
/// in a single buffer. The class takes care of object references.
//
/// This class merely encodes basic types such as strings, numbers, and
/// ActionScript Objects. It does not handle as_values. However, it
/// is designed for use with as_value::writeAMF0(), which uses an
/// instance of this class to serialize itself.
class Writer
{
public:
typedef std::map<as_object*, size_t> OffsetTable;
Writer(SimpleBuffer& buf, bool strictArray = false)
:
_buf(buf),
_strictArray(strictArray)
{}
/// Write any simple Object type: not DisplayObjects.
//
/// Handles functions, dates, XML, and arrays. The object must not be null.
bool writeObject(as_object* obj);
/// Write a string.
//
/// Handles long and short strings.
bool writeString(const std::string& str);
/// Write a null value.
bool writeNull();
/// Write an undefined value.
bool writeUndefined();
/// Write a double.
bool writeNumber(double d);
/// Write a boolean.
bool writeBoolean(bool b);
/// Encode the name of an object's property.
//
/// You should encode the value of the property immediately afterwards.
bool writePropertyName(const std::string& name);
/// Write custom data for special cases.
void writeData(const std::uint8_t* data, size_t length);
private:
OffsetTable _offsets;
SimpleBuffer& _buf;
bool _strictArray;
};
/// Deserialize an AMF buffer to as_values.
//
/// This class relies on the public interface of as_value because we don't
/// necessarily know in advance what basic type will be read from the
/// buffer.
//
/// Note that callers may change the current buffer position. They must
/// check that the read position is not past the end when a Reader object
/// is called. This is very important!
//
/// For reading of basic types, there is no need to use VM resources. Object
/// types required the construction of objects, which in turn needs a
/// reference to a Global_as. For this reason, object reading functions
/// are member functions, and the Reader requires a Global_as& reference
/// in case it encounters object data.
class Reader
{
public:
/// Construct a Reader with pointers into an AMF buffer.
//
/// You can use the amf::Reader in combination with other reads on the
/// data as long as the read position is never moved after end.
//
/// @param pos The read position in the buffer. This is moved after
/// every read to point to the next data field. You must
/// ensure that pos is not greater than end on every read.
/// @param end The end of the buffer.
/// @param gl A global reference for creating objects when necessary.
Reader(const std::uint8_t*& pos, const std::uint8_t* end, Global_as& gl)
:
_pos(pos),
_end(end),
_global(gl)
{}
/// Create a type from current position in the AMF buffer.
//
/// @param val An as_value to be created from the AMF data.
/// @param type The type of the data to read.
/// @return false if this read failed for any reason.
/// The constructed as_value is then invalid. True if
/// the read succeeded and the as_value is valid.
bool operator()(as_value& val, Type t = NOTYPE);
private:
/// Read an XML type.
as_value readXML();
/// Read a Date object type.
as_value readDate();
/// Read a simple object type.
as_value readObject();
/// Read an object reference type.
as_value readReference();
/// Read an array object type.
as_value readArray();
/// Read a strict array object type.
as_value readStrictArray();
/// Object references.
std::vector<as_object*> _objectRefs;
/// The current position in the buffer.
const std::uint8_t*& _pos;
/// The end of the buffer.
const std::uint8_t* const _end;
/// For creating objects if necessary.
Global_as& _global;
};
} // namespace amf
} // namespace gnash
#endif
|