aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/string.cpp')
-rw-r--r--c++-libbu++/src/string.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/c++-libbu++/src/string.cpp b/c++-libbu++/src/string.cpp
index de66d5d..f8e4071 100644
--- a/c++-libbu++/src/string.cpp
+++ b/c++-libbu++/src/string.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "gats/string.h" 8#include "gats/string.h"
2 9
3#include "gats/integer.h" 10#include "gats/integer.h"
@@ -9,27 +16,27 @@ Gats::String::String()
9} 16}
10 17
11Gats::String::String( const char *s ) : 18Gats::String::String( const char *s ) :
12 Bu::String( s ) 19 Bu::String( s )
13{ 20{
14} 21}
15 22
16Gats::String::String( const char *s, long iLength ) : 23Gats::String::String( const char *s, long iLength ) :
17 Bu::String( s, iLength ) 24 Bu::String( s, iLength )
18{ 25{
19} 26}
20 27
21Gats::String::String( long iLength ) : 28Gats::String::String( long iLength ) :
22 Bu::String( iLength ) 29 Bu::String( iLength )
23{ 30{
24} 31}
25 32
26Gats::String::String( const String &s ) : 33Gats::String::String( const String &s ) :
27 Bu::String( s ) 34 Bu::String( s )
28{ 35{
29} 36}
30 37
31Gats::String::String( const Bu::String &s ) : 38Gats::String::String( const Bu::String &s ) :
32 Bu::String( s ) 39 Bu::String( s )
33{ 40{
34} 41}
35 42
@@ -39,32 +46,32 @@ Gats::String::~String()
39 46
40Gats::Object *Gats::String::clone() const 47Gats::Object *Gats::String::clone() const
41{ 48{
42 return new Gats::String( Bu::String::clone() ); 49 return new Gats::String( Bu::String::clone() );
43} 50}
44 51
45void Gats::String::write( Bu::Stream &rOut ) const 52void Gats::String::write( Bu::Stream &rOut ) const
46{ 53{
47 rOut.write("s", 1 ); 54 rOut.write("s", 1 );
48 uint32_t iSize = getSize(); 55 uint32_t iSize = getSize();
49 Gats::Integer::writePackedInt( rOut, iSize ); 56 Gats::Integer::writePackedInt( rOut, iSize );
50 rOut.write( getStr(), iSize ); 57 rOut.write( getStr(), iSize );
51} 58}
52 59
53void Gats::String::read( Bu::Stream &rIn, char cType ) 60void Gats::String::read( Bu::Stream &rIn, char cType )
54{ 61{
55 uint32_t iSize; 62 uint32_t iSize;
56 Gats::Integer::readPackedInt( rIn, iSize ); 63 Gats::Integer::readPackedInt( rIn, iSize );
57 setSize( iSize ); 64 setSize( iSize );
58 rIn.read( getStr(), iSize ); 65 rIn.read( getStr(), iSize );
59} 66}
60 67
61Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) 68Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s )
62{ 69{
63 for( Gats::String::const_iterator i = s.begin(); i; i++ ) 70 for( Gats::String::const_iterator i = s.begin(); i; i++ )
64 { 71 {
65 if( *i >= 127 || *i <= 31 ) 72 if( *i >= 127 || *i <= 31 )
66 return f << "(binary str) " << s.getSize() << " bytes"; 73 return f << "(binary str) " << s.getSize() << " bytes";
67 } 74 }
68 return f << "(str) \"" << dynamic_cast<const Bu::String &>(s) << "\""; 75 return f << "(str) \"" << dynamic_cast<const Bu::String &>(s) << "\"";
69} 76}
70 77