~ubuntu-branches/ubuntu/breezy/atlas-cpp/breezy

« back to all changes in this revision

Viewing changes to Atlas/Message/DecoderBase.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2005-10-02 11:41:44 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051002114144-8qmn4d1cdn9g27ta
Tags: 0.5.98-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
 
 
5
 
#include <Atlas/Message/DecoderBase.h>
6
 
 
7
 
namespace Atlas { namespace Message {
8
 
 
9
 
DecoderBase::DecoderBase()
10
 
{
11
 
}
12
 
 
13
 
void DecoderBase::streamBegin()
14
 
{
15
 
    state.push(STATE_STREAM);
16
 
}
17
 
 
18
 
void DecoderBase::streamMessage(const Map&)
19
 
{
20
 
    Element::MapType m;
21
 
    maps.push(m);
22
 
    state.push(STATE_MAP);
23
 
}
24
 
 
25
 
void DecoderBase::streamEnd()
26
 
{
27
 
    state.pop();
28
 
}
29
 
 
30
 
void DecoderBase::mapItem(const std::string& name, const Map&)
31
 
{
32
 
    Element::MapType m;
33
 
    names.push(name);
34
 
    maps.push(m);
35
 
    state.push(STATE_MAP);
36
 
}
37
 
 
38
 
void DecoderBase::mapItem(const std::string& name, const List&)
39
 
{
40
 
    Element::ListType l;
41
 
    names.push(name);
42
 
    lists.push(l);
43
 
    state.push(STATE_LIST);
44
 
}
45
 
    
46
 
void DecoderBase::mapItem(const std::string& name, long i)
47
 
{
48
 
    maps.top()[name] = i;
49
 
}
50
 
    
51
 
void DecoderBase::mapItem(const std::string& name, double d)
52
 
{
53
 
    maps.top()[name] = d;
54
 
}
55
 
    
56
 
void DecoderBase::mapItem(const std::string& name, const std::string& s)
57
 
{
58
 
    maps.top()[name] = s;
59
 
}
60
 
 
61
 
void DecoderBase::mapEnd()
62
 
{
63
 
    Element::MapType map = maps.top();
64
 
    maps.pop();
65
 
    state.pop();
66
 
    switch (state.top()) {
67
 
        case STATE_MAP:
68
 
            maps.top()[names.top()] = map;
69
 
            names.pop();
70
 
            break;
71
 
        case STATE_LIST:
72
 
            lists.top().insert(lists.top().end(), map);
73
 
            break;
74
 
        case STATE_STREAM:
75
 
            objectArrived(map);
76
 
            break;
77
 
    }
78
 
}
79
 
  
80
 
void DecoderBase::listItem(const Map&)
81
 
{
82
 
    Element::MapType map;
83
 
    maps.push(map);
84
 
    state.push(STATE_MAP);
85
 
}
86
 
    
87
 
void DecoderBase::listItem(const List&)
88
 
{
89
 
    Element::ListType list;
90
 
    lists.push(list);
91
 
    state.push(STATE_LIST);
92
 
}
93
 
    
94
 
void DecoderBase::listItem(long i)
95
 
{
96
 
    lists.top().push_back(i);
97
 
}
98
 
 
99
 
void DecoderBase::listItem(double d)
100
 
{
101
 
    lists.top().push_back(d);
102
 
}
103
 
    
104
 
void DecoderBase::listItem(const std::string& s)
105
 
{
106
 
    lists.top().push_back(s);
107
 
}
108
 
    
109
 
void DecoderBase::listEnd()
110
 
{
111
 
    Element::ListType list = lists.top();
112
 
    lists.pop();
113
 
    state.pop();
114
 
    switch (state.top()) {
115
 
        case STATE_MAP:
116
 
            maps.top()[names.top()] = list;
117
 
            names.pop();
118
 
            break;
119
 
        case STATE_LIST:
120
 
            lists.top().push_back(list);
121
 
            break;
122
 
        case STATE_STREAM:
123
 
            // XXX - report error?
124
 
            break;
125
 
    }
126
 
}
127
 
    
128
 
} } // namespace Atlas::Message