Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/converter.h @ 6273

Last change on this file since 6273 was 6273, checked in by rennerc, 18 years ago

converter: added functions for strings
network_protocol: length and id are now int
network_game_manager: fixed some more bugs :D
skybox: is loaded on client corectly now :)

File size: 1.3 KB
Line 
1/*!
2 * @file converter.h
3 *  Is able to convert int to byte-array and vice versa
4 */
5
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/* The size of a float in byte */
18#define FLOATSIZE 4
19
20/*!
21 * a class that can convert int to byte-array and vice versa
22 */
23class Converter: public BaseObject
24{
25  public:
26    static byte* intToByteArray(int x);
27    static int byteArrayToInt(const byte* a);
28
29    static int intToByteArray(int x, byte* a, int length);
30    static int byteArrayToInt(const byte* a, int* x);
31
32    static int floatToByteArray(float x, byte* a, int length);
33    static int byteArrayToFloat(const byte* a, float* x);
34
35    static int stringToByteArray(const char* s, byte* a, int length, int maxLength);
36    static int byteArrayToString(const byte* a, char* s, int maxLength);
37
38    //Test
39    static char* floatToBinString(float x);
40
41    static byte* floatToByteArray(float x);
42    static float byteArrayToFloat(byte* a);
43
44    static byte* _floatToByteArray(float x);
45    static float _byteArrayToFloat(byte* a);
46  private:
47    Converter();
48    ~Converter();
49};
50
51#endif /*_CONVERTER*/
Note: See TracBrowser for help on using the repository browser.