root/trunk/raknet/raknet/bitstream.d

Revision 30, 3.3 kB (checked in by clayasaurus, 6 years ago)

windows works better out of the box now

Line 
1 module raknet.bitstream;
2
3 import raknet.raknet;
4
5
6 // we won't simply alias these names, rather we'll overload them
7 // START ////////////////////////////////////////////////////////////
8 void start()
9 {
10    rakBitstream_start1();
11 }
12
13 // we won't simply alias these names, rather we'll overload them
14 void start(int initBytes)
15 {
16    rakBitstream_start2(initBytes);
17 }
18
19 void start(char *_data, uint lengthInBytes, bool _copyData)
20 {
21    rakBitstream_start3(_data, lengthInBytes, _copyData);
22 }
23
24 // END ///////////////////////////////////////////////////////////////
25 void end()
26 {
27    rakBitstream_end();
28 }
29
30 // WRITE /////////////////////////////////////////////////////////////
31 void  write (bool input)
32 {
33    rakBitstream_Write1(input);
34 }
35
36 void  write (ubyte input)
37 {
38    rakBitstream_Write2(input);
39 }
40
41 void  write (char input)
42 {
43    rakBitstream_Write3(input);
44 }
45
46 void  write (ushort input)
47 {
48    rakBitstream_Write4(input);
49 }
50
51 void  write (short input)
52 {
53    rakBitstream_Write5(input);
54 }
55
56 void  write (uint input)
57 {
58    rakBitstream_Write6(input);
59 }
60
61 void  write (int input)
62 {
63    rakBitstream_Write7(input);
64 }
65
66 void  write (float input)
67 {
68    rakBitstream_Write8(input);
69 }
70
71 void  write (double input)
72 {
73    rakBitstream_Write9(input);
74 }
75
76 void  write (char *input, int numberOfBytes)
77 {
78    rakBitstream_Write10(input, numberOfBytes);
79 }
80
81
82 // READ ////////////////////////////////////////////////////////////////////////
83 bool  read (inout bool output)
84 {
85    return rakBitstream_Read1(output);
86 }
87
88 bool  read (inout ubyte output)
89 {
90    return rakBitstream_Read2(output);
91 }
92
93 bool  read (inout char output)
94 {
95    return rakBitstream_Read3(output);
96 }
97
98 bool  read (inout ushort output)
99 {
100    return rakBitstream_Read4(output);
101 }
102
103 bool  read (inout short output)
104 {
105    return rakBitstream_Read5(output);
106 }
107
108 bool  read (inout uint output)
109 {
110    return rakBitstream_Read6(output);
111 }
112
113 bool  read (inout int output)
114 {
115    return rakBitstream_Read7(output);
116 }
117
118 bool  read (inout float output)
119 {
120    return rakBitstream_Read8(output);
121 }
122
123 bool  read (inout double output)
124 {
125    return rakBitstream_Read9(output);
126 }
127
128 bool  read (char *output, int numberOfBytes)
129 {
130    return rakBitstream_Read10(output, numberOfBytes);
131 }
132
133
134
135  extern(C):
136
137
138 private {
139 // start and end using the bitstream
140 void rakBitstream_start1();
141 void rakBitstream_start2(int initialBytes);
142 void rakBitstream_start3(char *_data, uint lengthInBytes, bool _copyData);
143 void rakBitstream_end();
144
145 // write
146 void  rakBitstream_Write1 (bool input);
147 void  rakBitstream_Write2 (ubyte input);
148 void  rakBitstream_Write3 (char input);
149 void  rakBitstream_Write4 (ushort input);
150 void  rakBitstream_Write5 (short input);
151 void  rakBitstream_Write6 (uint input);
152 void  rakBitstream_Write7 (int input);
153 void  rakBitstream_Write8 (float input);
154 void  rakBitstream_Write9 (double input);
155 void  rakBitstream_Write10 (char *input, int numberOfBytes);
156
157
158 // read
159 bool  rakBitstream_Read1 (inout bool output);
160 bool  rakBitstream_Read2 (inout ubyte output);
161 bool  rakBitstream_Read3 (inout char output);
162 bool  rakBitstream_Read4 (inout ushort output);
163 bool  rakBitstream_Read5 (inout short output);
164 bool  rakBitstream_Read6 (inout uint output);
165 bool  rakBitstream_Read7 (inout int output);
166 bool  rakBitstream_Read8 (inout float output);
167 bool  rakBitstream_Read9 (inout double output);
168 bool  rakBitstream_Read10 (char *output, int numberOfBytes);
169 }
Note: See TracBrowser for help on using the browser.