From 146930268a695dcc0432599d625ec3eb7e74025e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 18 Dec 2009 08:59:16 +0000 Subject: The OptParser still needs help banners and more helper functions, but otherwise, it's done. It works great, and provides much flexibility and usefulness. It now relies on the input side of the Formatter class, which at the moment supports reading strings...not real useful yet... Next up, adding readers for numbers and such, then it'll be mostly complete. Also, fixed a bug when copying uninitialized signal objects. --- src/formatter.h | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'src/formatter.h') diff --git a/src/formatter.h b/src/formatter.h index db144eb..aec5c5d 100644 --- a/src/formatter.h +++ b/src/formatter.h @@ -15,7 +15,7 @@ namespace Bu class Formatter { public: - Formatter( Stream &rOut ); + Formatter( Stream &rStream ); virtual ~Formatter(); typedef struct Fmt @@ -103,6 +103,8 @@ namespace Bu void writeAligned( const Bu::FString &sStr ); void writeAligned( const char *sStr, int iLen ); + Bu::FString readToken(); + void incIndent(); void decIndent(); void setIndent( uint8_t uLevel ); @@ -206,11 +208,11 @@ namespace Bu void doFlush() { - rOut.flush(); + rStream.flush(); } private: - Stream &rOut; + Stream &rStream; Fmt fLast; bool bTempFmt; uint8_t uIndent; @@ -219,31 +221,33 @@ namespace Bu typedef Formatter::Fmt Fmt; - Formatter &operator<<( Formatter &rOut, const Formatter::Fmt &f ); - Formatter &operator<<( Formatter &rOut, Formatter::Special s ); - Formatter &operator<<( Formatter &rOut, const char *sStr ); - Formatter &operator<<( Formatter &rOut, char *sStr ); - Formatter &operator<<( Formatter &rOut, const Bu::FString &sStr ); - Formatter &operator<<( Formatter &rOut, signed char c ); - Formatter &operator<<( Formatter &rOut, char c ); - Formatter &operator<<( Formatter &rOut, unsigned char c ); - Formatter &operator<<( Formatter &rOut, signed short i ); - Formatter &operator<<( Formatter &rOut, unsigned short i ); - Formatter &operator<<( Formatter &rOut, signed int i ); - Formatter &operator<<( Formatter &rOut, unsigned int i ); - Formatter &operator<<( Formatter &rOut, signed long i ); - Formatter &operator<<( Formatter &rOut, unsigned long i ); - Formatter &operator<<( Formatter &rOut, signed long long i ); - Formatter &operator<<( Formatter &rOut, unsigned long long i ); - Formatter &operator<<( Formatter &rOut, float f ); - Formatter &operator<<( Formatter &rOut, double f ); - Formatter &operator<<( Formatter &rOut, long double f ); - Formatter &operator<<( Formatter &rOut, bool b ); + Formatter &operator<<( Formatter &f, const Formatter::Fmt &fmt ); + Formatter &operator<<( Formatter &f, Formatter::Special s ); + Formatter &operator<<( Formatter &f, const char *sStr ); + Formatter &operator<<( Formatter &f, char *sStr ); + Formatter &operator<<( Formatter &f, const Bu::FString &sStr ); + Formatter &operator<<( Formatter &f, signed char c ); + Formatter &operator<<( Formatter &f, char c ); + Formatter &operator<<( Formatter &f, unsigned char c ); + Formatter &operator<<( Formatter &f, signed short i ); + Formatter &operator<<( Formatter &f, unsigned short i ); + Formatter &operator<<( Formatter &f, signed int i ); + Formatter &operator<<( Formatter &f, unsigned int i ); + Formatter &operator<<( Formatter &f, signed long i ); + Formatter &operator<<( Formatter &f, unsigned long i ); + Formatter &operator<<( Formatter &f, signed long long i ); + Formatter &operator<<( Formatter &f, unsigned long long i ); + Formatter &operator<<( Formatter &f, float flt ); + Formatter &operator<<( Formatter &f, double flt ); + Formatter &operator<<( Formatter &f, long double flt ); + Formatter &operator<<( Formatter &f, bool b ); + + Formatter &operator>>( Formatter &f, Bu::FString &sStr ); template - Formatter &operator<<( Formatter &rOut, const type *p ) + Formatter &operator<<( Formatter &f, const type *p ) { - return rOut << "0x" << Fmt::hex(sizeof(ptrdiff_t)*2) << (ptrdiff_t)(p); + return f << "0x" << Fmt::hex(sizeof(ptrdiff_t)*2) << (ptrdiff_t)(p); } }; -- cgit v1.2.3