aboutsummaryrefslogtreecommitdiff
path: root/src/list.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-08 21:03:43 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-08 21:03:43 +0000
commit744fe4ecbcf613ee637d00e8808f69668eac6bb2 (patch)
treea35e424f73a099d5cfc342623f56a7b2de41f02d /src/list.cpp
parentcd210c95a5a429293aa5c88965d3526116ba8723 (diff)
downloadlibgats-744fe4ecbcf613ee637d00e8808f69668eac6bb2.tar.gz
libgats-744fe4ecbcf613ee637d00e8808f69668eac6bb2.tar.bz2
libgats-744fe4ecbcf613ee637d00e8808f69668eac6bb2.tar.xz
libgats-744fe4ecbcf613ee637d00e8808f69668eac6bb2.zip
Added a whole load of new, cool helpers for working with dictionaries and lists.
Diffstat (limited to 'src/list.cpp')
-rw-r--r--src/list.cpp89
1 files changed, 83 insertions, 6 deletions
diff --git a/src/list.cpp b/src/list.cpp
index 02e2a8d..3e871d6 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -4,6 +4,7 @@
4#include "gats/integer.h" 4#include "gats/integer.h"
5#include "gats/float.h" 5#include "gats/float.h"
6#include "gats/boolean.h" 6#include "gats/boolean.h"
7#include "gats/dictionary.h"
7 8
8#include <bu/formatter.h> 9#include <bu/formatter.h>
9#include <bu/stream.h> 10#include <bu/stream.h>
@@ -57,16 +58,54 @@ void Gats::List::append( int64_t i )
57 Bu::List<Gats::Object *>::append( new Gats::Integer( i ) ); 58 Bu::List<Gats::Object *>::append( new Gats::Integer( i ) );
58} 59}
59 60
60void Gats::List::append( bool b ) 61void Gats::List::append( double d )
61{ 62{
62 Bu::List<Gats::Object *>::append( new Gats::Boolean( b ) ); 63 Bu::List<Gats::Object *>::append( new Gats::Float( d ) );
63} 64}
64 65
65void Gats::List::append( double d ) 66void Gats::List::appendStr( const Bu::String &s )
67{
68 Bu::List<Gats::Object *>::append( new Gats::String( s ) );
69}
70
71void Gats::List::appendInt( int64_t i )
72{
73 Bu::List<Gats::Object *>::append( new Gats::Integer( i ) );
74}
75
76void Gats::List::appendFloat( double d )
66{ 77{
67 Bu::List<Gats::Object *>::append( new Gats::Float( d ) ); 78 Bu::List<Gats::Object *>::append( new Gats::Float( d ) );
68} 79}
69 80
81void Gats::List::appendBool( bool b )
82{
83 Bu::List<Gats::Object *>::append( new Gats::Boolean( b ) );
84}
85
86void Gats::List::appendList( Gats::List *pL )
87{
88 Bu::List<Gats::Object *>::append( pL );
89}
90
91void Gats::List::appendDict( Gats::Dictionary *pD )
92{
93 Bu::List<Gats::Object *>::append( pD );
94}
95
96Gats::List *Gats::List::appendList()
97{
98 Gats::List *pLst = new Gats::List();
99 appendList( pLst );
100 return pLst;
101}
102
103Gats::Dictionary *Gats::List::appendDict()
104{
105 Gats::Dictionary *pDict = new Gats::Dictionary();
106 appendDict( pDict );
107 return pDict;
108}
70 109
71void Gats::List::prepend( const char *s ) 110void Gats::List::prepend( const char *s )
72{ 111{
@@ -88,16 +127,54 @@ void Gats::List::prepend( int64_t i )
88 Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) ); 127 Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) );
89} 128}
90 129
91void Gats::List::prepend( bool b ) 130void Gats::List::prepend( double d )
92{ 131{
93 Bu::List<Gats::Object *>::prepend( new Gats::Boolean( b ) ); 132 Bu::List<Gats::Object *>::prepend( new Gats::Float( d ) );
94} 133}
95 134
96void Gats::List::prepend( double d ) 135void Gats::List::prependStr( const Bu::String &s )
136{
137 Bu::List<Gats::Object *>::prepend( new Gats::String( s ) );
138}
139
140void Gats::List::prependInt( int64_t i )
141{
142 Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) );
143}
144
145void Gats::List::prependFloat( double d )
97{ 146{
98 Bu::List<Gats::Object *>::prepend( new Gats::Float( d ) ); 147 Bu::List<Gats::Object *>::prepend( new Gats::Float( d ) );
99} 148}
100 149
150void Gats::List::prependBool( bool b )
151{
152 Bu::List<Gats::Object *>::prepend( new Gats::Boolean( b ) );
153}
154
155void Gats::List::prependList( Gats::List *pL )
156{
157 Bu::List<Gats::Object *>::prepend( pL );
158}
159
160void Gats::List::prependDict( Gats::Dictionary *pD )
161{
162 Bu::List<Gats::Object *>::prepend( pD );
163}
164
165Gats::List *Gats::List::prependList()
166{
167 Gats::List *pLst = new Gats::List();
168 prependList( pLst );
169 return pLst;
170}
171
172Gats::Dictionary *Gats::List::prependDict()
173{
174 Gats::Dictionary *pDict = new Gats::Dictionary();
175 prependDict( pDict );
176 return pDict;
177}
101 178
102Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) 179Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l )
103{ 180{