diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-08-27 21:53:54 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-27 21:53:54 +0000 |
commit | c10c9ef627c7e79fde6170fe334238bbcb5d66e5 (patch) | |
tree | 4a0971d81e666e91866ddeaf9b58b952ce2fdd0a /src/list.cpp | |
parent | 2a72923397d866f33221b9d32a3f9653d1a960e7 (diff) | |
download | libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.gz libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.bz2 libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.xz libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.zip |
Added formatter handlers for debugging, works really well. Also added a bunch
more helpers to make it as easy to use as possible.
Diffstat (limited to 'src/list.cpp')
-rw-r--r-- | src/list.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/list.cpp b/src/list.cpp index 995a764..0e5f56f 100644 --- a/src/list.cpp +++ b/src/list.cpp | |||
@@ -1,5 +1,11 @@ | |||
1 | #include "gats/list.h" | 1 | #include "gats/list.h" |
2 | 2 | ||
3 | #include "gats/string.h" | ||
4 | #include "gats/integer.h" | ||
5 | #include "gats/float.h" | ||
6 | #include "gats/boolean.h" | ||
7 | |||
8 | #include <bu/formatter.h> | ||
3 | #include <bu/stream.h> | 9 | #include <bu/stream.h> |
4 | 10 | ||
5 | Gats::List::List() | 11 | Gats::List::List() |
@@ -31,3 +37,78 @@ void Gats::List::read( Bu::Stream &rIn, char cType ) | |||
31 | } | 37 | } |
32 | } | 38 | } |
33 | 39 | ||
40 | void Gats::List::append( const char *s ) | ||
41 | { | ||
42 | Bu::List<Gats::Object *>::append( new Gats::String( s ) ); | ||
43 | } | ||
44 | |||
45 | void Gats::List::append( const Bu::FString &s ) | ||
46 | { | ||
47 | Bu::List<Gats::Object *>::append( new Gats::String( s ) ); | ||
48 | } | ||
49 | |||
50 | void Gats::List::append( int32_t i ) | ||
51 | { | ||
52 | Bu::List<Gats::Object *>::append( new Gats::Integer( i ) ); | ||
53 | } | ||
54 | |||
55 | void Gats::List::append( int64_t i ) | ||
56 | { | ||
57 | Bu::List<Gats::Object *>::append( new Gats::Integer( i ) ); | ||
58 | } | ||
59 | |||
60 | void Gats::List::append( bool b ) | ||
61 | { | ||
62 | Bu::List<Gats::Object *>::append( new Gats::Boolean( b ) ); | ||
63 | } | ||
64 | |||
65 | void Gats::List::append( double d ) | ||
66 | { | ||
67 | Bu::List<Gats::Object *>::append( new Gats::Float( d ) ); | ||
68 | } | ||
69 | |||
70 | |||
71 | void Gats::List::prepend( const char *s ) | ||
72 | { | ||
73 | Bu::List<Gats::Object *>::prepend( new Gats::String( s ) ); | ||
74 | } | ||
75 | |||
76 | void Gats::List::prepend( const Bu::FString &s ) | ||
77 | { | ||
78 | Bu::List<Gats::Object *>::prepend( new Gats::String( s ) ); | ||
79 | } | ||
80 | |||
81 | void Gats::List::prepend( int32_t i ) | ||
82 | { | ||
83 | Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) ); | ||
84 | } | ||
85 | |||
86 | void Gats::List::prepend( int64_t i ) | ||
87 | { | ||
88 | Bu::List<Gats::Object *>::prepend( new Gats::Integer( i ) ); | ||
89 | } | ||
90 | |||
91 | void Gats::List::prepend( bool b ) | ||
92 | { | ||
93 | Bu::List<Gats::Object *>::prepend( new Gats::Boolean( b ) ); | ||
94 | } | ||
95 | |||
96 | void Gats::List::prepend( double d ) | ||
97 | { | ||
98 | Bu::List<Gats::Object *>::prepend( new Gats::Float( d ) ); | ||
99 | } | ||
100 | |||
101 | |||
102 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) | ||
103 | { | ||
104 | f << "(list) ["; | ||
105 | f.incIndent(); | ||
106 | for( Gats::List::const_iterator i = l.begin(); i; i++ ) | ||
107 | { | ||
108 | f << f.nl << **i; | ||
109 | } | ||
110 | f.decIndent(); | ||
111 | f << f.nl << "]"; | ||
112 | return f; | ||
113 | } | ||
114 | |||