aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-qt/src/string.cpp')
-rw-r--r--c++-qt/src/string.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/c++-qt/src/string.cpp b/c++-qt/src/string.cpp
index ef23829..7d2d20f 100644
--- a/c++-qt/src/string.cpp
+++ b/c++-qt/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-qt/string.h" 8#include "gats-qt/string.h"
2 9
3#include "gats-qt/integer.h" 10#include "gats-qt/integer.h"
@@ -7,27 +14,27 @@ Gats::String::String()
7} 14}
8 15
9Gats::String::String( const char *s ) : 16Gats::String::String( const char *s ) :
10 QByteArray( s ) 17 QByteArray( s )
11{ 18{
12} 19}
13 20
14Gats::String::String( const char *s, long iLength ) : 21Gats::String::String( const char *s, long iLength ) :
15 QByteArray( s, iLength ) 22 QByteArray( s, iLength )
16{ 23{
17} 24}
18 25
19Gats::String::String( long iLength ) : 26Gats::String::String( long iLength ) :
20 QByteArray( iLength, '\0' ) 27 QByteArray( iLength, '\0' )
21{ 28{
22} 29}
23 30
24Gats::String::String( const String &s ) : 31Gats::String::String( const String &s ) :
25 QByteArray( s ) 32 QByteArray( s )
26{ 33{
27} 34}
28 35
29Gats::String::String( const QByteArray &s ) : 36Gats::String::String( const QByteArray &s ) :
30 QByteArray( s ) 37 QByteArray( s )
31{ 38{
32} 39}
33 40
@@ -37,29 +44,29 @@ Gats::String::~String()
37 44
38Gats::Object *Gats::String::clone() const 45Gats::Object *Gats::String::clone() const
39{ 46{
40 QByteArray baClone = *this; 47 QByteArray baClone = *this;
41 baClone.detach(); 48 baClone.detach();
42 return new Gats::String( baClone ); 49 return new Gats::String( baClone );
43} 50}
44 51
45void Gats::String::write( QIODevice &rOut ) const 52void Gats::String::write( QIODevice &rOut ) const
46{ 53{
47 rOut.write("s", 1 ); 54 rOut.write("s", 1 );
48 uint32_t iSize = size(); 55 uint32_t iSize = size();
49 Gats::Integer::writePackedInt( rOut, iSize ); 56 Gats::Integer::writePackedInt( rOut, iSize );
50 rOut.write( constData(), iSize ); 57 rOut.write( constData(), iSize );
51} 58}
52 59
53void Gats::String::read( QIODevice &rIn, char cType ) 60void Gats::String::read( QIODevice &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 fill( '\0', iSize ); 64 fill( '\0', iSize );
58 rIn.read( data(), iSize ); 65 rIn.read( data(), 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 return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\""; 70 return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\"";
64} 71}
65*/ 72*/