Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
TextSerializer.h
1 /*
2  * $Id$
3  * Copyright (c) 2006, IRIT UPS.
4  *
5  * TextSerializer class interface.
6  */
7 #ifndef ELM_SERIAL2_TEXT_SERIALIZER_H
8 #define ELM_SERIAL2_TEXT_SERIALIZER_H
9 
10 #include <elm/io.h>
11 #include <elm/serial2/Serializer.h>
12 #include <elm/data/HashMap.h>
13 #include <elm/data/VectorQueue.h>
14 #include <elm/util/Pair.h>
15 
16 namespace elm { namespace serial2 {
17 
18 // TextSerializer class
19 class TextSerializer: public Serializer {
20 public:
21  inline TextSerializer(io::Output &out = cout): level(0), _out(out) { }
22  virtual void flush(void);
23 
24  // Complex type serializers
25  virtual void beginObject(const rtti::Type& clazz, const void *object);
26  virtual void endObject(const rtti::Type& clazz, const void *object);
27  virtual void beginField(CString name);
28  virtual void endField(void);
29  virtual void onPointer(const rtti::Type& clazz, const void *object);
30  virtual void beginCompound(const void*);
31  virtual void onItem(void);
32  virtual void endCompound(const void*);
33  virtual void onEnum(const void *address, int value, const rtti::Type& clazz);
34 
35  // Base value serializers
36  virtual void onValue(const bool& v);
37  virtual void onValue(const signed int& v);
38  virtual void onValue(const unsigned int& v);
39  virtual void onValue(const signed char& v);
40  virtual void onValue(const unsigned char& v);
41  virtual void onValue(const signed short& v);
42  virtual void onValue(const unsigned short& v);
43  virtual void onValue(const signed long& v);
44  virtual void onValue(const unsigned long& v);
45  virtual void onValue(const signed long long& v);
46  virtual void onValue(const unsigned long long& v);
47  virtual void onValue(const float& v);
48  virtual void onValue(const double& v);
49  virtual void onValue(const long double& v);
50  virtual void onValue(const CString& v);
51  virtual void onValue(const String& v);
52 
53 private:
56  VectorQueue<delay_t> to_process;
57  int level;
58  io::Output& _out;
59  void prefix(const rtti::Type& type, const void *object);
60  void suffix(void);
61 };
62 
63 } } // elm::serial2
64 
65 #endif // ELM_SERIAL2_TEXT_SERIALIZER_H
elm::t::out
typename type_info< T >::out_t out
Definition: type_info.h:284
elm::HashMap< const void *, bool >
elm::serial2::TextSerializer::endObject
virtual void endObject(const rtti::Type &clazz, const void *object)
Definition: serial2_TextSerializer.cpp:68
elm::Pair
Definition: Pair.h:33
elm::VectorQueue
Definition: VectorQueue.h:31
elm::serial2::TextSerializer::onValue
virtual void onValue(const bool &v)
Definition: serial2_TextSerializer.cpp:100
elm::cout
io::Output cout
value
elm::CString
Definition: CString.h:17
elm::serial2::TextSerializer::onPointer
virtual void onPointer(const rtti::Type &clazz, const void *object)
Definition: serial2_TextSerializer.cpp:89
elm::serial2::TextSerializer::onItem
virtual void onItem(void)
Definition: serial2_TextSerializer.cpp:264
elm::serial2::TextSerializer::onEnum
virtual void onEnum(const void *address, int value, const rtti::Type &clazz)
Definition: serial2_TextSerializer.cpp:245
elm
Definition: adapter.h:26
elm::serial2::Serializer
Definition: Serializer.h:36
elm::serial2::TextSerializer
Definition: TextSerializer.h:19
elm::serial2::TextSerializer::endField
virtual void endField(void)
Definition: serial2_TextSerializer.cpp:83
elm::serial2::TextSerializer::endCompound
virtual void endCompound(const void *)
Definition: serial2_TextSerializer.cpp:270
elm::serial2::TextSerializer::beginCompound
virtual void beginCompound(const void *)
Definition: serial2_TextSerializer.cpp:256
elm::serial2::TextSerializer::beginField
virtual void beginField(CString name)
Definition: serial2_TextSerializer.cpp:76
elm::serial2::TextSerializer::TextSerializer
TextSerializer(io::Output &out=cout)
Definition: TextSerializer.h:21
elm::String
Definition: String.h:30
elm::serial2::TextSerializer::beginObject
virtual void beginObject(const rtti::Type &clazz, const void *object)
Definition: serial2_TextSerializer.cpp:60
elm::io::Output
Definition: Output.h:179
elm::rtti::Type
Definition: Type.h:83
elm::serial2::TextSerializer::flush
virtual void flush(void)
Definition: serial2_TextSerializer.cpp:48