32 #include <Pt/SerializationInfo.h>
33 #include <Pt/SerializationContext.h>
78 void setId(
const std::string&
id)
79 {
onSetId(
id.c_str(),
id.size() ); }
85 void setId(
const char*
id, std::size_t len)
196 virtual void onSetId(
const char*
id, std::size_t len) = 0;
267 template <
typename T>
294 _current->
setId(
id, len);
393 if( ! _current->
parent() )
395 *_current >> Pt::load() >>= *_type;
401 _current = _current->
parent();
void setReference(const std::string &id)
Composes a reference.
Definition: Composer.h:136
void setChar(const Pt::Char &ch)
Composes a char value.
Definition: Composer.h:105
Composer * onBeginDictElement()
Begins composition of a dict key.
Definition: Composer.h:367
void setReference(const void *ref)
Set to reference for which to create an ID.
void setFloat(long double value)
Composes a float value.
Definition: Composer.h:131
virtual void onSetInt(Pt::int64_t)
Compose a integer value.
Definition: Composer.h:215
Composer * beginDictValue()
Begins composition of a dict value.
Definition: Composer.h:176
void onSetReference(const char *id, std::size_t len)
Compose a reference.
Definition: Composer.h:345
SerializationInfo * parent()
Returns the parent node.
Definition: SerializationInfo.h:206
size_type size() const
Returns the length of the string.
Definition: String.h:239
virtual void onSetBinary(const char *, std::size_t)
Compose a binary value.
Definition: Composer.h:203
virtual Composer * onBeginMember(const char *, std::size_t)
Begin composition os a struct member.
Definition: Composer.h:231
Composer * finish()
Finishes composition of a struct or sequence member.
Definition: Composer.h:181
virtual void onSetId(const char *id, std::size_t len)=0
Set reference ID.
Composes types during serialization.
Definition: Composer.h:42
virtual Composer * onBeginDictValue()
Begins composition of a dict value.
Definition: Composer.h:251
SerializationInfo & addElement()
Add a sequence element.
Composer * beginDictKey()
Begins composition of a dict key.
Definition: Composer.h:171
virtual void onSetChar(const Pt::Char &)
Compose a character value.
Definition: Composer.h:207
void setId(const std::string &id)
Sets the reference id of the type to compose.
Definition: Composer.h:78
void setTypeName(const char *type, std::size_t len)
Sets the type name of the type to compose.
Definition: Composer.h:71
Composer()
Constructor.
Definition: Composer.h:187
void setInt(Pt::int64_t value)
Composes a signed integer type.
Definition: Composer.h:118
void setInt64(Pt::int64_t l)
Set to 64-bit integer value.
void onSetBinary(const char *data, std::size_t length)
Compose a binary value.
Definition: Composer.h:309
SerializationInfo & addMember(const std::string &name)
Add a struct member.
Definition: SerializationInfo.h:449
virtual void onSetBool(bool)
Compose a bool value.
Definition: Composer.h:211
SerializationInfo & addDictValue()
Add a dict value.
Composer * beginMember(const std::string &name)
Begins composition of a struct member.
Definition: Composer.h:146
void onSetBool(bool value)
Compose a bool value.
Definition: Composer.h:321
virtual Composer * onFinish()
Finishes composition of a struct or sequence member.
Definition: Composer.h:256
void setBool(bool value)
Composes a boolean value.
Definition: Composer.h:110
void onSetUInt(Pt::uint64_t value)
Compose a unsigned integer value.
Definition: Composer.h:333
Error during serialization of a type.
Definition: SerializationError.h:45
Composer * onBeginDictValue()
Begins composition of a dict value.
Definition: Composer.h:383
void setUInt(Pt::int64_t value)
Composes an unsigned integer type.
Definition: Composer.h:126
virtual void onSetReference(const char *, std::size_t)
Compose a reference.
Definition: Composer.h:227
virtual Composer * onBeginDictKey()
Begins composition of a dict key.
Definition: Composer.h:246
Composer * onBeginElement()
Begins composition of a sequence member.
Definition: Composer.h:359
void setBinary(const char *data, std::size_t length)
Set to binary value.
Composer * beginElement()
Begins composition of a sequence member.
Definition: Composer.h:156
const Pt::Char * c_str() const
Returns a null terminated C string.
Definition: String.h:264
void setLongDouble(long double d)
Set to long double value.
void setUInt64(Pt::uint64_t n)
Set to 64-bit unsigned integer value.
Unicode character type.
Definition: String.h:66
virtual Composer * onBeginElement()
Begins composition of a sequence member.
Definition: Composer.h:236
int_type int64_t
Signed 64-bit integer type.
Definition: Types.h:48
void onSetString(const Pt::Char *value, std::size_t len)
Compose a string value.
Definition: Composer.h:303
void setBool(bool b)
Set to bool value.
void clear()
Clears all content.
virtual ~Composer()
Destructor.
Definition: Composer.h:47
virtual void onSetString(const Pt::Char *, std::size_t)
Compose a string value.
Definition: Composer.h:199
void setString(const Pt::String &value)
Composes a string value.
Definition: Composer.h:90
Composer * beginMember(const char *name, std::size_t len)
Begins composition of a struct member.
Definition: Composer.h:151
void setChar(char c)
Set to character value.
virtual void onSetTypeName(const char *, std::size_t)
Set type name.
Definition: Composer.h:192
void onSetInt(Pt::int64_t value)
Compose a integer value.
Definition: Composer.h:327
Manages the composition of types during serialization.
Definition: Composer.h:268
Composer * parent() const
Returns the parent composer.
Definition: Composer.h:57
SerializationInfo & addDictElement()
Add a dict element.
Composer * onFinish()
Finishes composition of a struct or sequence member.
Definition: Composer.h:391
Composer * onBeginDictKey()
Begins composition of a dict key.
Definition: Composer.h:375
void setString(const Pt::Char *value, std::size_t len)
Composes a string value.
Definition: Composer.h:95
void onSetFloat(long double value)
Compose a floating point value.
Definition: Composer.h:339
virtual void onSetUInt(Pt::uint64_t)
Compose a unsigned integer value.
Definition: Composer.h:219
uint_type uint64_t
Unsigned 64-bit integer type.
Definition: Types.h:54
Unicode capable basic_string.
Definition: String.h:42
void setString(const char *s)
Set to string value.
void setReference(const char *id, std::size_t len)
Composes a reference.
Definition: Composer.h:141
Composer * beginDictElement()
Begins composition of a dict key.
Definition: Composer.h:166
void setId(const std::string &id)
Sets the reference ID.
void setId(const char *id, std::size_t len)
Sets the reference id of the type to compose.
Definition: Composer.h:85
Composer * onBeginMember(const char *name, std::size_t len)
Begin composition os a struct member.
Definition: Composer.h:351
Context for the serialization of types.
Definition: SerializationContext.h:20
void onSetId(const char *id, std::size_t len)
Set reference ID.
Definition: Composer.h:292
Represents arbitrary types during serialization.
Definition: SerializationInfo.h:58
void setTypeName(const std::string &type)
Sets the type name of the type to compose.
Definition: Composer.h:64
SerializationInfo & addDictKey()
Add a dict key.
virtual void onSetFloat(long double)
Compose a floating point value.
Definition: Composer.h:223
BasicComposer(SerializationContext *context=0)
Construct with context.
Definition: Composer.h:272
void onSetTypeName(const char *type, std::size_t len)
Set type name.
Definition: Composer.h:298
virtual Composer * onBeginDictElement()
Begins composition of a dict key.
Definition: Composer.h:241
void begin(T &type)
Begin composing a type.
Definition: Composer.h:279
void setParent(Composer *parent)
Sets the parent composer.
Definition: Composer.h:52
void onSetChar(const Pt::Char &ch)
Compose a character value.
Definition: Composer.h:315
void setBinary(const char *data, std::size_t length)
Composes a binary value.
Definition: Composer.h:100
void setTypeName(const std::string &type)
Sets the type name.