aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/string.cpp
blob: 0b9e4d8e1222c46b6c3b250e5ca0d8131552e757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "gats-qt/string.h"

#include "gats-qt/integer.h"

Gats::String::String()
{
}

Gats::String::String( const char *s ) :
	QByteArray( s )
{
}

Gats::String::String( const char *s, long iLength ) :
	QByteArray( s, iLength )
{
}

Gats::String::String( long iLength ) :
	QByteArray( iLength, '\0' )
{
}

Gats::String::String( const String &s ) :
	QByteArray( s )
{
}

Gats::String::String( const QByteArray &s ) :
	QByteArray( s )
{
}

Gats::String::~String()
{
}

void Gats::String::write( QIODevice &rOut ) const
{
	rOut.write("s", 1 );
	uint32_t iSize = size();
	Gats::Integer::writePackedInt( rOut, iSize );
	rOut.write( constData(), iSize );
}

void Gats::String::read( QIODevice &rIn, char cType )
{
	uint32_t iSize;
	Gats::Integer::readPackedInt( rIn, iSize );
	fill( '\0', iSize );
	rIn.read( data(), iSize );
}
/*
Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s )
{
	return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\"";
}
*/