Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/converter.h @ 6782

Last change on this file since 6782 was 6753, checked in by patrick, 19 years ago

trunk: merged network back to trunk

File size: 1.5 KB
RevLine 
[6106]1/*!
2 * @file converter.h
3 *  Is able to convert int to byte-array and vice versa
4 */
[6341]5
[6106]6#ifndef _CONVERTER
7#define _CONVERTER
8
9/* include this file, it contains some default definitions */
10#include "netdefs.h"
11
[6634]12
[6106]13/* include base_object.h since all classes are derived from this one */
14#include "base_object.h"
15
16/* The size of an int in byte */
17#define INTSIZE 4
[6341]18/* The size of a float in byte */
19#define FLOATSIZE 4
[6106]20
21/*!
22 * a class that can convert int to byte-array and vice versa
23 */
[6634]24class Converter : public BaseObject
[6106]25{
26  public:
27    static byte* intToByteArray(int x);
[6341]28    static int byteArrayToInt(const byte* a);
29
30    static int intToByteArray(int x, byte* a, int length);
31    static int byteArrayToInt(const byte* a, int* x);
32
33    static int stringToByteArray(const char* s, byte* a, int length, int maxLength);
34    static int byteArrayToString(const byte* a, char* s, int maxLength);
35    static int byteArrayToStringM(const byte* a, char*& s );
36
[6128]37    //Test
38    static char* floatToBinString(float x);
[6341]39
[6753]40//     static byte* floatToByteArray(float x);
41//     static float byteArrayToFloat(byte* a);
[6341]42
[6753]43    static int floatToByteArray(float x, byte* a, int length);
44    static int byteArrayToFloat(const byte* a, float* x);
45
[6634]46    static int _floatToByteArray(float x, byte* a, int length);
47    static int _byteArrayToFloat(const byte* a, float* x);
48
49
[6753]50
[6634]51    static void debug();
52    static void floatTest(float x);
[6737]53    static void ArrayfloatTest(float x);
[6634]54    static float getDenormConst();
55
56
[6106]57  private:
58    Converter();
59    ~Converter();
60};
61
[6634]62#undef byte
63
[6106]64#endif /*_CONVERTER*/
Note: See TracBrowser for help on using the repository browser.