aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/list.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-31 17:34:11 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-31 17:34:11 +0000
commit82da0238a8171cf8bba6bb1c82d5abba207a10aa (patch)
tree83ff9b022b658e7a056fc85f132937b8bda4c1c3 /c++-qt/src/list.cpp
parent7dd5c386611e31930e7ccfb83cb585df27696881 (diff)
downloadlibgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.gz
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.bz2
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.xz
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.zip
Gats for QT is here. It's a pretty basic conversion right now, it doesn't
support debugging formatting (Bu::sio), it doesn't support gats-text string parsing, and the exceptions need to be fixed to be real exceptions. The basic functions have been renamed to match the Qt API and we use QT types for everything (QHash, QList, QByteArray). It needs more testing, but it's a great start.
Diffstat (limited to '')
-rw-r--r--c++-qt/src/list.cpp192
1 files changed, 192 insertions, 0 deletions
diff --git a/c++-qt/src/list.cpp b/c++-qt/src/list.cpp
new file mode 100644
index 0000000..59e1770
--- /dev/null
+++ b/c++-qt/src/list.cpp
@@ -0,0 +1,192 @@
1#include "gats-qt/list.h"
2
3#include "gats-qt/string.h"
4#include "gats-qt/integer.h"
5#include "gats-qt/float.h"
6#include "gats-qt/boolean.h"
7#include "gats-qt/dictionary.h"
8
9Gats::List::List()
10{
11}
12
13Gats::List::~List()
14{
15 for( iterator i = begin(); i != end(); i++ )
16 {
17 delete *i;
18 }
19}
20
21void Gats::List::write( QIODevice &rOut ) const
22{
23 rOut.write("l", 1 );
24 for( const_iterator i = begin(); i != end(); i++ )
25 {
26 (*i)->write( rOut );
27 }
28 rOut.write("e", 1 );
29}
30
31void Gats::List::read( QIODevice &rIn, char cType )
32{
33 for(;;)
34 {
35 Gats::Object *pObj = Gats::Object::read( rIn );
36 if( pObj == NULL )
37 break;
38 append( pObj );
39 }
40}
41
42void Gats::List::append( const char *s )
43{
44 QList<Gats::Object *>::append( new Gats::String( s ) );
45}
46
47void Gats::List::append( const QByteArray &s )
48{
49 QList<Gats::Object *>::append( new Gats::String( s ) );
50}
51
52void Gats::List::append( int32_t i )
53{
54 QList<Gats::Object *>::append( new Gats::Integer( i ) );
55}
56
57void Gats::List::append( int64_t i )
58{
59 QList<Gats::Object *>::append( new Gats::Integer( i ) );
60}
61
62void Gats::List::append( double d )
63{
64 QList<Gats::Object *>::append( new Gats::Float( d ) );
65}
66
67void Gats::List::appendStr( const QByteArray &s )
68{
69 QList<Gats::Object *>::append( new Gats::String( s ) );
70}
71
72void Gats::List::appendInt( int64_t i )
73{
74 QList<Gats::Object *>::append( new Gats::Integer( i ) );
75}
76
77void Gats::List::appendFloat( double d )
78{
79 QList<Gats::Object *>::append( new Gats::Float( d ) );
80}
81
82void Gats::List::appendBool( bool b )
83{
84 QList<Gats::Object *>::append( new Gats::Boolean( b ) );
85}
86
87void Gats::List::appendList( Gats::List *pL )
88{
89 QList<Gats::Object *>::append( pL );
90}
91
92void Gats::List::appendDict( Gats::Dictionary *pD )
93{
94 QList<Gats::Object *>::append( pD );
95}
96
97Gats::List *Gats::List::appendList()
98{
99 Gats::List *pLst = new Gats::List();
100 appendList( pLst );
101 return pLst;
102}
103
104Gats::Dictionary *Gats::List::appendDict()
105{
106 Gats::Dictionary *pDict = new Gats::Dictionary();
107 appendDict( pDict );
108 return pDict;
109}
110
111void Gats::List::prepend( const char *s )
112{
113 QList<Gats::Object *>::prepend( new Gats::String( s ) );
114}
115
116void Gats::List::prepend( const QByteArray &s )
117{
118 QList<Gats::Object *>::prepend( new Gats::String( s ) );
119}
120
121void Gats::List::prepend( int32_t i )
122{
123 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
124}
125
126void Gats::List::prepend( int64_t i )
127{
128 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
129}
130
131void Gats::List::prepend( double d )
132{
133 QList<Gats::Object *>::prepend( new Gats::Float( d ) );
134}
135
136void Gats::List::prependStr( const QByteArray &s )
137{
138 QList<Gats::Object *>::prepend( new Gats::String( s ) );
139}
140
141void Gats::List::prependInt( int64_t i )
142{
143 QList<Gats::Object *>::prepend( new Gats::Integer( i ) );
144}
145
146void Gats::List::prependFloat( double d )
147{
148 QList<Gats::Object *>::prepend( new Gats::Float( d ) );
149}
150
151void Gats::List::prependBool( bool b )
152{
153 QList<Gats::Object *>::prepend( new Gats::Boolean( b ) );
154}
155
156void Gats::List::prependList( Gats::List *pL )
157{
158 QList<Gats::Object *>::prepend( pL );
159}
160
161void Gats::List::prependDict( Gats::Dictionary *pD )
162{
163 QList<Gats::Object *>::prepend( pD );
164}
165
166Gats::List *Gats::List::prependList()
167{
168 Gats::List *pLst = new Gats::List();
169 prependList( pLst );
170 return pLst;
171}
172
173Gats::Dictionary *Gats::List::prependDict()
174{
175 Gats::Dictionary *pDict = new Gats::Dictionary();
176 prependDict( pDict );
177 return pDict;
178}
179/*
180Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l )
181{
182 f << "(list) [";
183 f.incIndent();
184 for( Gats::List::const_iterator i = l.begin(); i; i++ )
185 {
186 f << f.nl << **i;
187 }
188 f.decIndent();
189 f << f.nl << "]";
190 return f;
191}
192*/