| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // Urho3D Engine
- // Copyright (c) 2008-2011 Lasse Öörni
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- #pragma once
- #include "StringHash.h"
- #include "Map.h"
- #include "Vector.h"
- class Color;
- class IntRect;
- class IntVector2;
- class Quaternion;
- class Rect;
- class Variant;
- class Vector2;
- class Vector3;
- class Vector4;
- struct ResourceRef;
- struct ResourceRefList;
- typedef Vector<Variant> VariantVector;
- typedef Map<ShortStringHash, Variant> VariantMap;
- /// Abstract stream for writing
- class Serializer
- {
- public:
- /// Destruct
- virtual ~Serializer();
-
- /// Write bytes to the stream. Return number of bytes actually written
- virtual unsigned Write(const void* data, unsigned size) = 0;
-
- /// Write a 32-bit integer
- bool WriteInt(int value);
- /// Write a 16-bit integer
- bool WriteShort(short value);
- /// Write an 8-bit integer
- bool WriteByte(signed char value);
- /// Write a 32-bit unsigned integer
- bool WriteUInt(unsigned value);
- /// Write a 16-bit unsigned integer
- bool WriteUShort(unsigned short value);
- /// Write an 8-bit unsigned integer
- bool WriteUByte(unsigned char value);
- /// Write a bool
- bool WriteBool(bool value);
- /// Write a float
- bool WriteFloat(float value);
- /// Write an IntRect
- bool WriteIntRect(const IntRect& value);
- /// Write an IntVector2
- bool WriteIntVector2(const IntVector2& value);
- /// Write a Rect
- bool WriteRect(const Rect& value);
- /// Write a Vector2
- bool WriteVector2(const Vector2& value);
- /// Write a Vector3
- bool WriteVector3(const Vector3& value);
- /// Write a Vector3 packed into 3 x 16 bits with the specified maximum absolute range
- bool WritePackedVector3(const Vector3& value, float maxAbsCoord);
- /// Write a Vector4
- bool WriteVector4(const Vector4& value);
- /// Write a Quaternion
- bool WriteQuaternion(const Quaternion& value);
- /// Write a Quaternion with each component packed in 16 bits
- bool WritePackedQuaternion(const Quaternion& value);
- /// Write a Color
- bool WriteColor(const Color& value);
- /// Write a BoundingBox
- bool WriteBoundingBox(const BoundingBox& value);
- /// Write a null-terminated string
- bool WriteString(const String& value);
- /// Write a four-letter ID. If the string is not long enough, spaces will be appended
- bool WriteID(const String& value);
- /// Write a 32-bit StringHash
- bool WriteStringHash(const StringHash& value);
- /// Write a 16-bit ShortStringHash
- bool WriteShortStringHash(const ShortStringHash& value);
- /// Write a buffer, with size encoded as VLE
- bool WriteBuffer(const Vector<unsigned char>& buffer);
- /// Write a resource reference
- bool WriteResourceRef(const ResourceRef& value);
- /// Write a resource reference list
- bool WriteResourceRefList(const ResourceRefList& value);
- /// Write a Variant
- bool WriteVariant(const Variant& value);
- /// Write a Variant without the type information
- bool WriteVariantData(const Variant& value);
- /// Write a variant vector
- bool WriteVariantVector(const VariantVector& value);
- /// Write a variant map
- bool WriteVariantMap(const VariantMap& value);
- /// Write a variable-length encoded unsigned integer, which can use 29 bits maximum
- bool WriteVLE(unsigned value);
- /// Write a text line. Char codes 13 & 10 will be automatically appended.
- bool WriteLine(const String& value);
- };
|