From 74dd68ad611d15abf16a65c36a7cfd3f4492930a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 16:25:22 +0000 Subject: Made the repo less libbu++-centric. --- c++-libbu++/src/string.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 c++-libbu++/src/string.cpp (limited to 'c++-libbu++/src/string.cpp') diff --git a/c++-libbu++/src/string.cpp b/c++-libbu++/src/string.cpp new file mode 100644 index 0000000..de66d5d --- /dev/null +++ b/c++-libbu++/src/string.cpp @@ -0,0 +1,70 @@ +#include "gats/string.h" + +#include "gats/integer.h" + +#include + +Gats::String::String() +{ +} + +Gats::String::String( const char *s ) : + Bu::String( s ) +{ +} + +Gats::String::String( const char *s, long iLength ) : + Bu::String( s, iLength ) +{ +} + +Gats::String::String( long iLength ) : + Bu::String( iLength ) +{ +} + +Gats::String::String( const String &s ) : + Bu::String( s ) +{ +} + +Gats::String::String( const Bu::String &s ) : + Bu::String( s ) +{ +} + +Gats::String::~String() +{ +} + +Gats::Object *Gats::String::clone() const +{ + return new Gats::String( Bu::String::clone() ); +} + +void Gats::String::write( Bu::Stream &rOut ) const +{ + rOut.write("s", 1 ); + uint32_t iSize = getSize(); + Gats::Integer::writePackedInt( rOut, iSize ); + rOut.write( getStr(), iSize ); +} + +void Gats::String::read( Bu::Stream &rIn, char cType ) +{ + uint32_t iSize; + Gats::Integer::readPackedInt( rIn, iSize ); + setSize( iSize ); + rIn.read( getStr(), iSize ); +} + +Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) +{ + for( Gats::String::const_iterator i = s.begin(); i; i++ ) + { + if( *i >= 127 || *i <= 31 ) + return f << "(binary str) " << s.getSize() << " bytes"; + } + return f << "(str) \"" << dynamic_cast(s) << "\""; +} + -- cgit v1.2.3