blob: 02e2a8d9c354cfdcc3eea1890f4c34ea7b7a2055 (
plain)
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
|
#include "gats/list.h"
#include "gats/string.h"
#include "gats/integer.h"
#include "gats/float.h"
#include "gats/boolean.h"
#include <bu/formatter.h>
#include <bu/stream.h>
Gats::List::List()
{
}
Gats::List::~List()
{
}
void Gats::List::write( Bu::Stream &rOut ) const
{
rOut.write("l", 1 );
for( const_iterator i = begin(); i; i++ )
{
(*i)->write( rOut );
}
rOut.write("e", 1 );
}
void Gats::List::read( Bu::Stream &rIn, char cType )
{
for(;;)
{
Gats::Object *pObj = Gats::Object::read( rIn );
if( pObj == NULL )
break;
append( pObj );
}
}
void Gats::List::append( const char *s )
{
Bu::List<Gats::Object *>::append( new Gats::String( s ) );
}
void Gats::List::append( const Bu::String &s )
{
Bu::List<Gats::Object *>::append( new Gats::String( s ) );
}
void Gats::List::append( int32_t i )
{
Bu::List<Gats::Object *>::append( new Gats::Integer( i ) );
}
void Gats::List::append( int64_t i )
{
Bu::List<Gats::Object *>::append( new Gats::Integer( i ) );
}
void Gats::List::append( bool b )
{
Bu::List<Gats::Object *>::append( new Gats::Boolean( b ) );
}
void Gats::List::append( double d )
{
Bu::List<Gats::Object *>::append( new Gats::Float( d ) );
}
void Gats::List::prepend( const char *s )
{
Bu::List<Gats::Object *>::prepend( new Gats::String( s ) );
}
void Gats::List::prepend( const Bu::String &s )
{
Bu::List<Gats::Object *>::prepend( new Gats::String( s ) );
}
void Gats::List::prepend( int32_t i )
{
Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) );
}
void Gats::List::prepend( int64_t i )
{
Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) );
}
void Gats::List::prepend( bool b )
{
Bu::List<Gats::Object *>::prepend( new Gats::Boolean( b ) );
}
void Gats::List::prepend( double d )
{
Bu::List<Gats::Object *>::prepend( new Gats::Float( d ) );
}
Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l )
{
f << "(list) [";
f.incIndent();
for( Gats::List::const_iterator i = l.begin(); i; i++ )
{
f << f.nl << **i;
}
f.decIndent();
f << f.nl << "]";
return f;
}
|