File: Formatter.cpp

package info (click to toggle)
atlas-cpp 0.5.98-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,652 kB
  • ctags: 2,284
  • sloc: sh: 8,305; cpp: 6,372; python: 1,471; makefile: 216
file content (121 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// This file may be redistributed and modified only under the terms of
// the GNU Lesser General Public License (See COPYING for details).
// Copyright (C) 2005 Alistair Riddoch

#include <Atlas/Formatter.h>

#include <iostream>

namespace Atlas {


Formatter::Formatter(std::iostream & s, Atlas::Bridge & b) : m_stream(s),
                                                             m_bridge(b),
                                                             m_indent(0),
                                                             m_spacing(2)
{
}

void Formatter::streamBegin()
{
    m_bridge.streamBegin();
    m_indent = m_spacing;
    m_stream << std::endl;
}

void Formatter::streamMessage()
{
    m_stream << std::endl;
    m_stream << std::string(m_indent, ' ');
    m_bridge.streamMessage();
    m_indent += m_spacing;
    m_stream << std::endl;
}

void Formatter::streamEnd()
{
    m_stream << std::endl;
    m_bridge.streamEnd();
    m_stream << std::endl;
}

    
void Formatter::mapMapItem(const std::string & name)
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapMapItem(name);
    m_indent += m_spacing;
    m_stream << std::endl;
}

void Formatter::mapListItem(const std::string & name)
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapListItem(name);
}

void Formatter::mapIntItem(const std::string & name, long l)
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapIntItem(name, l);
    m_stream << std::endl;
}

void Formatter::mapFloatItem(const std::string & name, double d)
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapFloatItem(name, d);
    m_stream << std::endl;
}

void Formatter::mapStringItem(const std::string & name, const std::string & s)
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapStringItem(name, s);
    m_stream << std::endl;
}

void Formatter::mapEnd()
{
    m_indent -= m_spacing;
    m_stream << std::string(m_indent, ' ');
    m_bridge.mapEnd();
    m_stream << std::endl;
}

    
void Formatter::listMapItem()
{
    m_stream << std::string(m_indent, ' ');
    m_bridge.listMapItem();
    m_indent += m_spacing;
    m_stream << std::endl;
}

void Formatter::listListItem()
{
    m_bridge.listListItem();
}

void Formatter::listIntItem(long l)
{
    m_bridge.listIntItem(l);
}

void Formatter::listFloatItem(double d)
{
    m_bridge.listFloatItem(d);
}

void Formatter::listStringItem(const std::string & s)
{
    m_bridge.listStringItem(s);
}

void Formatter::listEnd()
{
    m_bridge.listEnd();
    m_stream << std::endl;
}

} // Atlas namespace