aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/list.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-qt/src/list.cpp')
-rw-r--r--c++-qt/src/list.cpp139
1 files changed, 73 insertions, 66 deletions
diff --git a/c++-qt/src/list.cpp b/c++-qt/src/list.cpp
index 8a648e9..158a7c1 100644
--- a/c++-qt/src/list.cpp
+++ b/c++-qt/src/list.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "gats-qt/list.h" 8#include "gats-qt/list.h"
2 9
3#include "gats-qt/string.h" 10#include "gats-qt/string.h"
@@ -12,193 +19,193 @@ Gats::List::List()
12 19
13Gats::List::~List() 20Gats::List::~List()
14{ 21{
15 for( iterator i = begin(); i != end(); i++ ) 22 for( iterator i = begin(); i != end(); i++ )
16 { 23 {
17 delete *i; 24 delete *i;
18 } 25 }
19} 26}
20 27
21Gats::Object *Gats::List::clone() const 28Gats::Object *Gats::List::clone() const
22{ 29{
23 Gats::List *pClone = new Gats::List; 30 Gats::List *pClone = new Gats::List;
24 31
25 for( const_iterator i = begin(); i != end(); i++ ) 32 for( const_iterator i = begin(); i != end(); i++ )
26 { 33 {
27 pClone->append( (*i)->clone() ); 34 pClone->append( (*i)->clone() );
28 } 35 }
29 36
30 return pClone; 37 return pClone;
31} 38}
32 39
33void Gats::List::write( QIODevice &rOut ) const 40void Gats::List::write( QIODevice &rOut ) const
34{ 41{
35 rOut.write("l", 1 ); 42 rOut.write("l", 1 );
36 for( const_iterator i = begin(); i != end(); i++ ) 43 for( const_iterator i = begin(); i != end(); i++ )
37 { 44 {
38 (*i)->write( rOut ); 45 (*i)->write( rOut );
39 } 46 }
40 rOut.write("e", 1 ); 47 rOut.write("e", 1 );
41} 48}
42 49
43void Gats::List::read( QIODevice &rIn, char cType ) 50void Gats::List::read( QIODevice &rIn, char cType )
44{ 51{
45 for(;;) 52 for(;;)
46 { 53 {
47 Gats::Object *pObj = Gats::Object::read( rIn ); 54 Gats::Object *pObj = Gats::Object::read( rIn );
48 if( pObj == NULL ) 55 if( pObj == NULL )
49 break; 56 break;
50 append( pObj ); 57 append( pObj );
51 } 58 }
52} 59}
53 60
54void Gats::List::append( const char *s ) 61void Gats::List::append( const char *s )
55{ 62{
56 QList<Gats::Object *>::append( new Gats::String( s ) ); 63 QList<Gats::Object *>::append( new Gats::String( s ) );
57} 64}
58 65
59void Gats::List::append( const QByteArray &s ) 66void Gats::List::append( const QByteArray &s )
60{ 67{
61 QList<Gats::Object *>::append( new Gats::String( s ) ); 68 QList<Gats::Object *>::append( new Gats::String( s ) );
62} 69}
63 70
64void Gats::List::append( int32_t i ) 71void Gats::List::append( int32_t i )
65{ 72{
66 QList<Gats::Object *>::append( new Gats::Integer( i ) ); 73 QList<Gats::Object *>::append( new Gats::Integer( i ) );
67} 74}
68 75
69void Gats::List::append( int64_t i ) 76void Gats::List::append( int64_t i )
70{ 77{
71 QList<Gats::Object *>::append( new Gats::Integer( i ) ); 78 QList<Gats::Object *>::append( new Gats::Integer( i ) );
72} 79}
73 80
74void Gats::List::append( double d ) 81void Gats::List::append( double d )
75{ 82{
76 QList<Gats::Object *>::append( new Gats::Float( d ) ); 83 QList<Gats::Object *>::append( new Gats::Float( d ) );
77} 84}
78 85
79void Gats::List::appendStr( const QByteArray &s ) 86void Gats::List::appendStr( const QByteArray &s )
80{ 87{
81 QList<Gats::Object *>::append( new Gats::String( s ) ); 88 QList<Gats::Object *>::append( new Gats::String( s ) );
82} 89}
83 90
84void Gats::List::appendInt( int64_t i ) 91void Gats::List::appendInt( int64_t i )
85{ 92{
86 QList<Gats::Object *>::append( new Gats::Integer( i ) ); 93 QList<Gats::Object *>::append( new Gats::Integer( i ) );
87} 94}
88 95
89void Gats::List::appendFloat( double d ) 96void Gats::List::appendFloat( double d )
90{ 97{
91 QList<Gats::Object *>::append( new Gats::Float( d ) ); 98 QList<Gats::Object *>::append( new Gats::Float( d ) );
92} 99}
93 100
94void Gats::List::appendBool( bool b ) 101void Gats::List::appendBool( bool b )
95{ 102{
96 QList<Gats::Object *>::append( new Gats::Boolean( b ) ); 103 QList<Gats::Object *>::append( new Gats::Boolean( b ) );
97} 104}
98 105
99void Gats::List::appendList( Gats::List *pL ) 106void Gats::List::appendList( Gats::List *pL )
100{ 107{
101 QList<Gats::Object *>::append( pL ); 108 QList<Gats::Object *>::append( pL );
102} 109}
103 110
104void Gats::List::appendDict( Gats::Dictionary *pD ) 111void Gats::List::appendDict( Gats::Dictionary *pD )
105{ 112{
106 QList<Gats::Object *>::append( pD ); 113 QList<Gats::Object *>::append( pD );
107} 114}
108 115
109Gats::List *Gats::List::appendList() 116Gats::List *Gats::List::appendList()
110{ 117{
111 Gats::List *pLst = new Gats::List(); 118 Gats::List *pLst = new Gats::List();
112 appendList( pLst ); 119 appendList( pLst );
113 return pLst; 120 return pLst;
114} 121}
115 122
116Gats::Dictionary *Gats::List::appendDict() 123Gats::Dictionary *Gats::List::appendDict()
117{ 124{
118 Gats::Dictionary *pDict = new Gats::Dictionary(); 125 Gats::Dictionary *pDict = new Gats::Dictionary();
119 appendDict( pDict ); 126 appendDict( pDict );
120 return pDict; 127 return pDict;
121} 128}
122 129
123void Gats::List::prepend( const char *s ) 130void Gats::List::prepend( const char *s )
124{ 131{
125 QList<Gats::Object *>::prepend( new Gats::String( s ) ); 132 QList<Gats::Object *>::prepend( new Gats::String( s ) );
126} 133}
127 134
128void Gats::List::prepend( const QByteArray &s ) 135void Gats::List::prepend( const QByteArray &s )
129{ 136{
130 QList<Gats::Object *>::prepend( new Gats::String( s ) ); 137 QList<Gats::Object *>::prepend( new Gats::String( s ) );
131} 138}
132 139
133void Gats::List::prepend( int32_t i ) 140void Gats::List::prepend( int32_t i )
134{ 141{
135 QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); 142 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
136} 143}
137 144
138void Gats::List::prepend( int64_t i ) 145void Gats::List::prepend( int64_t i )
139{ 146{
140 QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); 147 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
141} 148}
142 149
143void Gats::List::prepend( double d ) 150void Gats::List::prepend( double d )
144{ 151{
145 QList<Gats::Object *>::prepend( new Gats::Float( d ) ); 152 QList<Gats::Object *>::prepend( new Gats::Float( d ) );
146} 153}
147 154
148void Gats::List::prependStr( const QByteArray &s ) 155void Gats::List::prependStr( const QByteArray &s )
149{ 156{
150 QList<Gats::Object *>::prepend( new Gats::String( s ) ); 157 QList<Gats::Object *>::prepend( new Gats::String( s ) );
151} 158}
152 159
153void Gats::List::prependInt( int64_t i ) 160void Gats::List::prependInt( int64_t i )
154{ 161{
155 QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); 162 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
156} 163}
157 164
158void Gats::List::prependFloat( double d ) 165void Gats::List::prependFloat( double d )
159{ 166{
160 QList<Gats::Object *>::prepend( new Gats::Float( d ) ); 167 QList<Gats::Object *>::prepend( new Gats::Float( d ) );
161} 168}
162 169
163void Gats::List::prependBool( bool b ) 170void Gats::List::prependBool( bool b )
164{ 171{
165 QList<Gats::Object *>::prepend( new Gats::Boolean( b ) ); 172 QList<Gats::Object *>::prepend( new Gats::Boolean( b ) );
166} 173}
167 174
168void Gats::List::prependList( Gats::List *pL ) 175void Gats::List::prependList( Gats::List *pL )
169{ 176{
170 QList<Gats::Object *>::prepend( pL ); 177 QList<Gats::Object *>::prepend( pL );
171} 178}
172 179
173void Gats::List::prependDict( Gats::Dictionary *pD ) 180void Gats::List::prependDict( Gats::Dictionary *pD )
174{ 181{
175 QList<Gats::Object *>::prepend( pD ); 182 QList<Gats::Object *>::prepend( pD );
176} 183}
177 184
178Gats::List *Gats::List::prependList() 185Gats::List *Gats::List::prependList()
179{ 186{
180 Gats::List *pLst = new Gats::List(); 187 Gats::List *pLst = new Gats::List();
181 prependList( pLst ); 188 prependList( pLst );
182 return pLst; 189 return pLst;
183} 190}
184 191
185Gats::Dictionary *Gats::List::prependDict() 192Gats::Dictionary *Gats::List::prependDict()
186{ 193{
187 Gats::Dictionary *pDict = new Gats::Dictionary(); 194 Gats::Dictionary *pDict = new Gats::Dictionary();
188 prependDict( pDict ); 195 prependDict( pDict );
189 return pDict; 196 return pDict;
190} 197}
191/* 198/*
192Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) 199Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l )
193{ 200{
194 f << "(list) ["; 201 f << "(list) [";
195 f.incIndent(); 202 f.incIndent();
196 for( Gats::List::const_iterator i = l.begin(); i; i++ ) 203 for( Gats::List::const_iterator i = l.begin(); i; i++ )
197 { 204 {
198 f << f.nl << **i; 205 f << f.nl << **i;
199 } 206 }
200 f.decIndent(); 207 f.decIndent();
201 f << f.nl << "]"; 208 f << f.nl << "]";
202 return f; 209 return f;
203} 210}
204*/ 211*/