sources/network/bytestream.cpp

changeset 98
4f0f0b1b8e0b
parent 94
294803d4ab5d
child 99
f9f73eeba3b7
equal deleted inserted replaced
97:2d43f05b284c 98:4f0f0b1b8e0b
134 } 134 }
135 } 135 }
136 136
137 // ------------------------------------------------------------------------------------------------- 137 // -------------------------------------------------------------------------------------------------
138 // 138 //
139 char Bytestream::read_byte() 139 int8_t Bytestream::read_byte()
140 { 140 {
141 ensure_read_space (1); 141 ensure_read_space (1);
142 return *m_cursor++; 142 return *m_cursor++;
143 } 143 }
144 144
145 // ------------------------------------------------------------------------------------------------- 145 // -------------------------------------------------------------------------------------------------
146 // 146 //
147 short int Bytestream::read_short() 147 int16_t Bytestream::read_short()
148 { 148 {
149 ensure_read_space (2); 149 ensure_read_space (2);
150 short int result = 0; 150 short int result = 0;
151 151
152 for (int i = 0; i < 2; ++i) 152 for (int i = 0; i < 2; ++i)
156 return result; 156 return result;
157 } 157 }
158 158
159 // ------------------------------------------------------------------------------------------------- 159 // -------------------------------------------------------------------------------------------------
160 // 160 //
161 long int Bytestream::read_long() 161 int32_t Bytestream::read_long()
162 { 162 {
163 ensure_read_space (4); 163 ensure_read_space (4);
164 long int result = 0; 164 long int result = 0;
165 165
166 for (int i = 0; i < 4; ++i) 166 for (int i = 0; i < 4; ++i)
248 resize (allocated_size() + bytes + 128); 248 resize (allocated_size() + bytes + 128);
249 } 249 }
250 250
251 // ------------------------------------------------------------------------------------------------- 251 // -------------------------------------------------------------------------------------------------
252 // 252 //
253 void Bytestream::write_byte (char val) 253 void Bytestream::write_byte (int8_t val)
254 { 254 {
255 grow_to_fit (1); 255 grow_to_fit (1);
256 write (val); 256 write (val);
257 } 257 }
258 258
259 // ------------------------------------------------------------------------------------------------- 259 // -------------------------------------------------------------------------------------------------
260 // 260 //
261 void Bytestream::write_short (short int val) 261 void Bytestream::write_short (int16_t val)
262 { 262 {
263 grow_to_fit (2); 263 grow_to_fit (2);
264 264
265 for (int i = 0; i < 2; ++i) 265 for (int i = 0; i < 2; ++i)
266 write ((val >> (i * 8)) & 0xFF); 266 write ((val >> (i * 8)) & 0xFF);
267 } 267 }
268 268
269 // ------------------------------------------------------------------------------------------------- 269 // -------------------------------------------------------------------------------------------------
270 // 270 //
271 void Bytestream::write_long (long int val) 271 void Bytestream::write_long (int32_t val)
272 { 272 {
273 grow_to_fit (4); 273 grow_to_fit (4);
274 274
275 for (int i = 0; i < 4; ++i) 275 for (int i = 0; i < 4; ++i)
276 write ((val >> (i * 8)) & 0xFF); 276 write ((val >> (i * 8)) & 0xFF);

mercurial