18 #ifndef INCLUDED_BINARYSERIALIZER
19 #define INCLUDED_BINARYSERIALIZER
44 std::streamsize
xsputn(
const char* s, std::streamsize n)
100 template <
typename A>
157 m_Impl.Put(name, (
const u8*)&v,
sizeof(int32_t));
162 m_Impl.Put(name, (
const u8*)&value,
sizeof(
float));
167 m_Impl.Put(name, (
const u8*)&value,
sizeof(
double));
173 m_Impl.Put(name, (
const u8*)&v,
sizeof(int32_t));
176 virtual void PutBool(
const char* name,
bool value)
178 NumberU8(name, value ? 1 : 0, 0, 1);
181 virtual void PutString(
const char* name,
const std::string& value)
185 m_Impl.Put(name, (
u8*)value.data(), value.length());
193 virtual void PutRaw(
const char* name,
const u8* data,
size_t len)
195 m_Impl.Put(name, data, len);
213 #endif // INCLUDED_BINARYSERIALIZER
A simple fixed-point number class.
CSerializerStreamBuf< T > m_RawStreamBuf
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
ScriptInterface & m_ScriptInterface
virtual void PutScriptVal(const char *name, jsval value)
Serialization interface; see serialization overview.
virtual void PutNumber(const char *name, int32_t value)
virtual void PutNumber(const char *name, fixed value)
virtual void PutNumber(const char *name, float value)
ProxyAllocator< std::pair< JSObject *const, u32 >, Allocators::DynamicArena > ScriptBackrefsAlloc
T GetInternalValue() const
ISerializer & m_Serializer
virtual void PutRaw(const char *name, const u8 *data, size_t len)
virtual void PutBool(const char *name, bool value)
std::map< JSObject *, u32, std::less< JSObject * >, ScriptBackrefsAlloc > backrefs_t
PutScriptVal implementation details.
void ScriptString(const char *name, JSString *string)
virtual void PutNumber(const char *name, uint32_t value)
std::streamsize xsputn(const char *s, std::streamsize n)
virtual void PutString(const char *name, const std::string &value)
void SetSerializablePrototypes(std::map< JSObject *, std::wstring > &prototypes)
Allocators::DynamicArena m_ScriptBackrefsArena
virtual void SetSerializablePrototypes(std::map< JSObject *, std::wstring > &prototypes)
virtual void PutNumber(const char *name, int8_t value)
CBinarySerializer(ScriptInterface &scriptInterface, A &a)
std::map< JSObject *, std::wstring > m_SerializablePrototypes
#define T(string_literal)
CBinarySerializerScriptImpl(ScriptInterface &scriptInterface, ISerializer &serializer)
NONCOPYABLE(CSerializerStreamBuf)
std::auto_ptr< CBinarySerializerScriptImpl > m_ScriptImpl
virtual void PutNumber(const char *name, int16_t value)
virtual std::ostream & GetStream()
Returns a stream which can be used to serialize data directly.
fully STL-compatible allocator that simply draws upon another Allocator.
virtual void PutNumber(const char *name, uint16_t value)
allocator design parameters:
Abstraction around a SpiderMonkey JSContext.
Serialize to a binary stream.
backrefs_t m_ScriptBackrefs
NONCOPYABLE(CBinarySerializer)
Wrapper for redirecting ostream writes to CBinarySerializer's impl.
std::wstring GetPrototypeName(JSObject *prototype)
void HandleScriptVal(jsval val)
virtual void PutNumber(const char *name, double value)
void NumberU8(const char *name, uint8_t value, uint8_t lower, uint8_t upper)
Serialize a number, which must be lower <= value <= upper.
u32 GetScriptBackrefTag(JSObject *obj)
CBinarySerializer(ScriptInterface &scriptInterface)
Helper for rooting large groups of script values.
virtual void PutNumber(const char *name, uint8_t value)
CSerializerStreamBuf(T &impl)
bool IsSerializablePrototype(JSObject *prototype)