From c10c9ef627c7e79fde6170fe334238bbcb5d66e5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 27 Aug 2010 21:53:54 +0000 Subject: Added formatter handlers for debugging, works really well. Also added a bunch more helpers to make it as easy to use as possible. --- src/list.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'src/list.cpp') 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 @@ #include "gats/list.h" +#include "gats/string.h" +#include "gats/integer.h" +#include "gats/float.h" +#include "gats/boolean.h" + +#include #include Gats::List::List() @@ -31,3 +37,78 @@ void Gats::List::read( Bu::Stream &rIn, char cType ) } } +void Gats::List::append( const char *s ) +{ + Bu::List::append( new Gats::String( s ) ); +} + +void Gats::List::append( const Bu::FString &s ) +{ + Bu::List::append( new Gats::String( s ) ); +} + +void Gats::List::append( int32_t i ) +{ + Bu::List::append( new Gats::Integer( i ) ); +} + +void Gats::List::append( int64_t i ) +{ + Bu::List::append( new Gats::Integer( i ) ); +} + +void Gats::List::append( bool b ) +{ + Bu::List::append( new Gats::Boolean( b ) ); +} + +void Gats::List::append( double d ) +{ + Bu::List::append( new Gats::Float( d ) ); +} + + +void Gats::List::prepend( const char *s ) +{ + Bu::List::prepend( new Gats::String( s ) ); +} + +void Gats::List::prepend( const Bu::FString &s ) +{ + Bu::List::prepend( new Gats::String( s ) ); +} + +void Gats::List::prepend( int32_t i ) +{ + Bu::List::prepend( new Gats::Integer( i ) ); +} + +void Gats::List::prepend( int64_t i ) +{ + Bu::List::prepend( new Gats::Integer( i ) ); +} + +void Gats::List::prepend( bool b ) +{ + Bu::List::prepend( new Gats::Boolean( b ) ); +} + +void Gats::List::prepend( double d ) +{ + Bu::List::prepend( new Gats::Float( d ) ); +} + + +Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) +{ + f << "(list) ["; + f.incIndent(); + for( Gats::List::const_iterator i = l.begin(); i; i++ ) + { + f << f.nl << **i; + } + f.decIndent(); + f << f.nl << "]"; + return f; +} + -- cgit v1.2.3