aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/integer.h
diff options
context:
space:
mode:
Diffstat (limited to 'c++-qt/src/integer.h')
-rw-r--r--c++-qt/src/integer.h95
1 files changed, 0 insertions, 95 deletions
diff --git a/c++-qt/src/integer.h b/c++-qt/src/integer.h
deleted file mode 100644
index 9178796..0000000
--- a/c++-qt/src/integer.h
+++ /dev/null
@@ -1,95 +0,0 @@
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
8#ifndef GATS_INTEGER_H
9#define GATS_INTEGER_H
10
11#include "gats-qt/object.h"
12
13#include <stdint.h>
14
15#include <QIODevice>
16
17namespace Gats
18{
19 class Integer : public Gats::Object
20 {
21 Q_OBJECT;
22 public:
23 Integer();
24 Integer( int64_t iVal );
25 virtual ~Integer();
26
27 virtual Object *clone() const;
28
29 virtual Type getType() const { return typeInteger; }
30 int64_t getValue() const { return iVal; }
31 void setValue( int64_t iNewVal ) { iVal = iNewVal; }
32
33 virtual void write( QIODevice &rOut ) const;
34 virtual void read( QIODevice &rIn, char cType );
35
36 template<typename itype>
37 static void readPackedInt( QIODevice &rStream, itype &rOut )
38 {
39 int8_t b;
40 rOut = 0;
41 bool bNeg;
42
43 rStream.read( (char *)&b, 1 );
44 bNeg = ( b&0x40 );
45 rOut |= (itype(b&0x3F));
46 int c = 0;
47 while( (b&0x80) )
48 {
49 rStream.read( (char *)&b, 1 );
50 rOut |= (itype(b&0x7F)) << (6+7*(c++));
51 }
52 if( bNeg ) rOut = -rOut;
53 }
54
55 template<typename itype>
56 static void writePackedInt( QIODevice &rStream, itype iIn )
57 {
58 uint8_t b;
59
60 if( iIn < 0 )
61 {
62 iIn = -iIn;
63 b = (iIn&0x3F);
64 if( iIn > b )
65 b |= 0x80 | 0x40;
66 else
67 b |= 0x40;
68 }
69 else
70 {
71 b = (iIn&0x3F);
72 if( iIn > b )
73 b |= 0x80;
74 }
75 rStream.write( (const char *)&b, 1 );
76 iIn = iIn >> 6;
77
78 while( iIn )
79 {
80 b = (iIn&0x7F);
81 if( iIn > b )
82 b |= 0x80;
83 rStream.write( (const char *)&b, 1 );
84 iIn = iIn >> 7;
85 }
86 }
87
88 private:
89 int64_t iVal;
90 };
91};
92
93//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i );
94
95#endif