Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6413 was 6341, checked in by bensch, 19 years ago

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File size: 1.3 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
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
[6341]17/* The size of a float in byte */
18#define FLOATSIZE 4
[6106]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);
[6341]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    static int byteArrayToStringM(const byte* a, char*& s );
38
[6128]39    //Test
40    static char* floatToBinString(float x);
[6341]41
42    static byte* floatToByteArray(float x);
43    static float byteArrayToFloat(byte* a);
44
45    static byte* _floatToByteArray(float x);
46    static float _byteArrayToFloat(byte* a);
[6106]47  private:
48    Converter();
49    ~Converter();
50};
51
52#endif /*_CONVERTER*/
Note: See TracBrowser for help on using the repository browser.