diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-31 17:34:11 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-31 17:34:11 +0000 |
commit | 82da0238a8171cf8bba6bb1c82d5abba207a10aa (patch) | |
tree | 83ff9b022b658e7a056fc85f132937b8bda4c1c3 /c++-qt/src/string.cpp | |
parent | 7dd5c386611e31930e7ccfb83cb585df27696881 (diff) | |
download | libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.gz libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.bz2 libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.xz libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.zip |
Gats for QT is here. It's a pretty basic conversion right now, it doesn't
support debugging formatting (Bu::sio), it doesn't support gats-text string
parsing, and the exceptions need to be fixed to be real exceptions.
The basic functions have been renamed to match the Qt API and we use QT types
for everything (QHash, QList, QByteArray). It needs more testing, but it's a
great start.
Diffstat (limited to 'c++-qt/src/string.cpp')
-rw-r--r-- | c++-qt/src/string.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/c++-qt/src/string.cpp b/c++-qt/src/string.cpp new file mode 100644 index 0000000..0b9e4d8 --- /dev/null +++ b/c++-qt/src/string.cpp | |||
@@ -0,0 +1,58 @@ | |||
1 | #include "gats-qt/string.h" | ||
2 | |||
3 | #include "gats-qt/integer.h" | ||
4 | |||
5 | Gats::String::String() | ||
6 | { | ||
7 | } | ||
8 | |||
9 | Gats::String::String( const char *s ) : | ||
10 | QByteArray( s ) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Gats::String::String( const char *s, long iLength ) : | ||
15 | QByteArray( s, iLength ) | ||
16 | { | ||
17 | } | ||
18 | |||
19 | Gats::String::String( long iLength ) : | ||
20 | QByteArray( iLength, '\0' ) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | Gats::String::String( const String &s ) : | ||
25 | QByteArray( s ) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | Gats::String::String( const QByteArray &s ) : | ||
30 | QByteArray( s ) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | Gats::String::~String() | ||
35 | { | ||
36 | } | ||
37 | |||
38 | void Gats::String::write( QIODevice &rOut ) const | ||
39 | { | ||
40 | rOut.write("s", 1 ); | ||
41 | uint32_t iSize = size(); | ||
42 | Gats::Integer::writePackedInt( rOut, iSize ); | ||
43 | rOut.write( constData(), iSize ); | ||
44 | } | ||
45 | |||
46 | void Gats::String::read( QIODevice &rIn, char cType ) | ||
47 | { | ||
48 | uint32_t iSize; | ||
49 | Gats::Integer::readPackedInt( rIn, iSize ); | ||
50 | fill( '\0', iSize ); | ||
51 | rIn.read( data(), iSize ); | ||
52 | } | ||
53 | /* | ||
54 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) | ||
55 | { | ||
56 | return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\""; | ||
57 | } | ||
58 | */ | ||