diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-31 17:34:11 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-31 17:34:11 +0000 |
commit | 82da0238a8171cf8bba6bb1c82d5abba207a10aa (patch) | |
tree | 83ff9b022b658e7a056fc85f132937b8bda4c1c3 /c++-qt/src/list.cpp | |
parent | 7dd5c386611e31930e7ccfb83cb585df27696881 (diff) | |
download | libgats-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.cpp | 192 |
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 | |||
9 | Gats::List::List() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | Gats::List::~List() | ||
14 | { | ||
15 | for( iterator i = begin(); i != end(); i++ ) | ||
16 | { | ||
17 | delete *i; | ||
18 | } | ||
19 | } | ||
20 | |||
21 | void 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 | |||
31 | void 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 | |||
42 | void Gats::List::append( const char *s ) | ||
43 | { | ||
44 | QList<Gats::Object *>::append( new Gats::String( s ) ); | ||
45 | } | ||
46 | |||
47 | void Gats::List::append( const QByteArray &s ) | ||
48 | { | ||
49 | QList<Gats::Object *>::append( new Gats::String( s ) ); | ||
50 | } | ||
51 | |||
52 | void Gats::List::append( int32_t i ) | ||
53 | { | ||
54 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | ||
55 | } | ||
56 | |||
57 | void Gats::List::append( int64_t i ) | ||
58 | { | ||
59 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | ||
60 | } | ||
61 | |||
62 | void Gats::List::append( double d ) | ||
63 | { | ||
64 | QList<Gats::Object *>::append( new Gats::Float( d ) ); | ||
65 | } | ||
66 | |||
67 | void Gats::List::appendStr( const QByteArray &s ) | ||
68 | { | ||
69 | QList<Gats::Object *>::append( new Gats::String( s ) ); | ||
70 | } | ||
71 | |||
72 | void Gats::List::appendInt( int64_t i ) | ||
73 | { | ||
74 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | ||
75 | } | ||
76 | |||
77 | void Gats::List::appendFloat( double d ) | ||
78 | { | ||
79 | QList<Gats::Object *>::append( new Gats::Float( d ) ); | ||
80 | } | ||
81 | |||
82 | void Gats::List::appendBool( bool b ) | ||
83 | { | ||
84 | QList<Gats::Object *>::append( new Gats::Boolean( b ) ); | ||
85 | } | ||
86 | |||
87 | void Gats::List::appendList( Gats::List *pL ) | ||
88 | { | ||
89 | QList<Gats::Object *>::append( pL ); | ||
90 | } | ||
91 | |||
92 | void Gats::List::appendDict( Gats::Dictionary *pD ) | ||
93 | { | ||
94 | QList<Gats::Object *>::append( pD ); | ||
95 | } | ||
96 | |||
97 | Gats::List *Gats::List::appendList() | ||
98 | { | ||
99 | Gats::List *pLst = new Gats::List(); | ||
100 | appendList( pLst ); | ||
101 | return pLst; | ||
102 | } | ||
103 | |||
104 | Gats::Dictionary *Gats::List::appendDict() | ||
105 | { | ||
106 | Gats::Dictionary *pDict = new Gats::Dictionary(); | ||
107 | appendDict( pDict ); | ||
108 | return pDict; | ||
109 | } | ||
110 | |||
111 | void Gats::List::prepend( const char *s ) | ||
112 | { | ||
113 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | ||
114 | } | ||
115 | |||
116 | void Gats::List::prepend( const QByteArray &s ) | ||
117 | { | ||
118 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | ||
119 | } | ||
120 | |||
121 | void Gats::List::prepend( int32_t i ) | ||
122 | { | ||
123 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | ||
124 | } | ||
125 | |||
126 | void Gats::List::prepend( int64_t i ) | ||
127 | { | ||
128 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | ||
129 | } | ||
130 | |||
131 | void Gats::List::prepend( double d ) | ||
132 | { | ||
133 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); | ||
134 | } | ||
135 | |||
136 | void Gats::List::prependStr( const QByteArray &s ) | ||
137 | { | ||
138 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | ||
139 | } | ||
140 | |||
141 | void Gats::List::prependInt( int64_t i ) | ||
142 | { | ||
143 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | ||
144 | } | ||
145 | |||
146 | void Gats::List::prependFloat( double d ) | ||
147 | { | ||
148 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); | ||
149 | } | ||
150 | |||
151 | void Gats::List::prependBool( bool b ) | ||
152 | { | ||
153 | QList<Gats::Object *>::prepend( new Gats::Boolean( b ) ); | ||
154 | } | ||
155 | |||
156 | void Gats::List::prependList( Gats::List *pL ) | ||
157 | { | ||
158 | QList<Gats::Object *>::prepend( pL ); | ||
159 | } | ||
160 | |||
161 | void Gats::List::prependDict( Gats::Dictionary *pD ) | ||
162 | { | ||
163 | QList<Gats::Object *>::prepend( pD ); | ||
164 | } | ||
165 | |||
166 | Gats::List *Gats::List::prependList() | ||
167 | { | ||
168 | Gats::List *pLst = new Gats::List(); | ||
169 | prependList( pLst ); | ||
170 | return pLst; | ||
171 | } | ||
172 | |||
173 | Gats::Dictionary *Gats::List::prependDict() | ||
174 | { | ||
175 | Gats::Dictionary *pDict = new Gats::Dictionary(); | ||
176 | prependDict( pDict ); | ||
177 | return pDict; | ||
178 | } | ||
179 | /* | ||
180 | Bu::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 | */ | ||