Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6228 was 6228, checked in by bwuest, 18 years ago

Take my converter.h again!

File size: 1.1 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, const byte* a, int length);
33    static int byteArrayToFloat(const byte* a, float* x);
34   
35    //Test
36    static char* floatToBinString(float x);
37
38    static byte* floatToByteArray(float x);
39    static float byteArrayToFloat(byte* a);
40
41    static byte* _floatToByteArray(float x);
42    static float _byteArrayToFloat(byte* a);
43  private:
44    Converter();
45    ~Converter();
46};
47
48#endif /*_CONVERTER*/
Note: See TracBrowser for help on using the repository browser.