diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
| commit | d534a56d95bca7bdd812be024d9eacba4734e2b7 (patch) | |
| tree | f9b98ee2b80e645a7b54e7934882be6c9f73c165 /c++-qt/src/string.cpp | |
| parent | 61ccc86fdf06f12cb72a8b7e65286f812cf62154 (diff) | |
| download | libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.gz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.bz2 libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.xz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.zip | |
Many changes: tabconv'd the C++ code, added a license, BSD, and docs.
Diffstat (limited to '')
| -rw-r--r-- | c++-qt/src/string.cpp | 41 |
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 | ||
| 9 | Gats::String::String( const char *s ) : | 16 | Gats::String::String( const char *s ) : |
| 10 | QByteArray( s ) | 17 | QByteArray( s ) |
| 11 | { | 18 | { |
| 12 | } | 19 | } |
| 13 | 20 | ||
| 14 | Gats::String::String( const char *s, long iLength ) : | 21 | Gats::String::String( const char *s, long iLength ) : |
| 15 | QByteArray( s, iLength ) | 22 | QByteArray( s, iLength ) |
| 16 | { | 23 | { |
| 17 | } | 24 | } |
| 18 | 25 | ||
| 19 | Gats::String::String( long iLength ) : | 26 | Gats::String::String( long iLength ) : |
| 20 | QByteArray( iLength, '\0' ) | 27 | QByteArray( iLength, '\0' ) |
| 21 | { | 28 | { |
| 22 | } | 29 | } |
| 23 | 30 | ||
| 24 | Gats::String::String( const String &s ) : | 31 | Gats::String::String( const String &s ) : |
| 25 | QByteArray( s ) | 32 | QByteArray( s ) |
| 26 | { | 33 | { |
| 27 | } | 34 | } |
| 28 | 35 | ||
| 29 | Gats::String::String( const QByteArray &s ) : | 36 | Gats::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 | ||
| 38 | Gats::Object *Gats::String::clone() const | 45 | Gats::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 | ||
| 45 | void Gats::String::write( QIODevice &rOut ) const | 52 | void 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 | ||
| 53 | void Gats::String::read( QIODevice &rIn, char cType ) | 60 | void 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 | /* |
| 61 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) | 68 | Bu::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 | */ |
