Last change
on this file since 6219 was
6219,
checked in by rennerc, 18 years ago
|
network_game_manager: implemented some functions
|
File size:
949 bytes
|
Rev | Line | |
---|
[6106] | 1 | /*! |
---|
| 2 | * @file converter.h |
---|
| 3 | * Is able to convert int to byte-array and vice versa |
---|
| 4 | */ |
---|
[6219] | 5 | |
---|
[6106] | 6 | #ifndef _CONVERTER |
---|
| 7 | #define _CONVERTER |
---|
| 8 | |
---|
| 9 | /* include this file, it contains some default definitions */ |
---|
| 10 | #include "netdefs.h" |
---|
| 11 | |
---|
| 12 | /* include base_object.h since all classes are derived from this one */ |
---|
| 13 | #include "base_object.h" |
---|
| 14 | |
---|
| 15 | /* The size of an int in byte */ |
---|
| 16 | #define INTSIZE 4 |
---|
| 17 | |
---|
| 18 | /*! |
---|
| 19 | * a class that can convert int to byte-array and vice versa |
---|
| 20 | */ |
---|
| 21 | class Converter: public BaseObject |
---|
| 22 | { |
---|
| 23 | public: |
---|
| 24 | static byte* intToByteArray(int x); |
---|
[6219] | 25 | static int byteArrayToInt(const byte* a); |
---|
| 26 | |
---|
[6128] | 27 | //byte* floatToByteArray(float x); |
---|
| 28 | //float byteArrayToFloat(byte[] a); |
---|
[6219] | 29 | |
---|
[6128] | 30 | //Test |
---|
| 31 | static char* floatToBinString(float x); |
---|
[6219] | 32 | |
---|
[6197] | 33 | static byte* floatToByteArray(float x); |
---|
| 34 | static float byteArrayToFloat(byte* a); |
---|
[6219] | 35 | |
---|
[6197] | 36 | static byte* _floatToByteArray(float x); |
---|
| 37 | static float _byteArrayToFloat(byte* a); |
---|
[6106] | 38 | private: |
---|
| 39 | Converter(); |
---|
| 40 | ~Converter(); |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | #endif /*_CONVERTER*/ |
---|
Note: See
TracBrowser
for help on using the repository browser.