1
// This file may be redistributed and modified only under the terms of
2
// the GNU Lesser General Public License (See COPYING for details).
3
// Copyright (C) 2000 Stefanus Du Toit
5
#include <Atlas/Message/MEncoder.h>
7
#include <Atlas/Message/Element.h>
9
namespace Atlas { namespace Message {
11
Encoder::Encoder(Atlas::Bridge & b)
20
void Encoder::listElementItem(const Element& obj)
22
switch (obj.getType()) {
23
case Element::TYPE_INT: m_b.listIntItem(obj.asInt()); break;
24
case Element::TYPE_FLOAT: m_b.listFloatItem(obj.asFloat()); break;
25
case Element::TYPE_STRING: m_b.listStringItem(obj.asString()); break;
26
case Element::TYPE_MAP: {
28
MapType::const_iterator I;
29
for (I = obj.asMap().begin(); I != obj.asMap().end(); I++) {
30
mapElementItem((*I).first, (*I).second);
35
case Element::TYPE_LIST: {
37
ListType::const_iterator I;
38
for (I = obj.asList().begin(); I != obj.asList().end(); I++) {
48
void Encoder::listElementMapItem(const MapType& obj)
51
MapType::const_iterator I;
52
for (I = obj.begin(); I != obj.end(); I++) {
53
mapElementItem(I->first, I->second);
58
void Encoder::listElementListItem(const ListType& obj)
61
ListType::const_iterator I;
62
for (I = obj.begin(); I != obj.end(); I++) {
68
void Encoder::mapElementItem(const std::string& name, const Element& obj)
70
switch (obj.getType()) {
71
case Element::TYPE_INT: m_b.mapIntItem(name, obj.asInt()); break;
72
case Element::TYPE_FLOAT: m_b.mapFloatItem(name, obj.asFloat()); break;
73
case Element::TYPE_STRING: m_b.mapStringItem(name, obj.asString()); break;
74
case Element::TYPE_MAP: {
76
MapType::const_iterator I;
77
for (I = obj.asMap().begin(); I != obj.asMap().end(); I++) {
78
mapElementItem((*I).first, (*I).second);
83
case Element::TYPE_LIST: {
84
m_b.mapListItem(name);
85
ListType::const_iterator I;
86
for (I = obj.asList().begin(); I != obj.asList().end(); I++) {
97
void Encoder::mapElementMapItem(const std::string& name, const MapType& obj)
100
MapType::const_iterator I;
101
for (I = obj.begin(); I != obj.end(); I++) {
102
mapElementItem((*I).first, (*I).second);
107
void Encoder::mapElementListItem(const std::string& name, const ListType& obj)
109
m_b.mapListItem(name);
110
ListType::const_iterator I;
111
for (I = obj.begin(); I != obj.end(); I++) {
117
void Encoder::streamMessageElement(const MapType& obj)
120
MapType::const_iterator I;
121
for (I = obj.begin(); I != obj.end(); I++) {
122
mapElementItem((*I).first, (*I).second);
127
} } // namespace Atlas::Message