Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10621 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 1.7 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{
[9869]26  ObjectListDeclaration(Converter);
[6106]27  public:
28    static byte* intToByteArray(int x);
[6341]29    static int byteArrayToInt(const byte* a);
30
31    static int intToByteArray(int x, byte* a, int length);
32    static int byteArrayToInt(const byte* a, int* x);
[6981]33
[6959]34    static int _intToByteArray(int x, byte* a, int length);
35    static int _byteArrayToInt(const byte* a, int* x);
[6341]36
[7230]37    static int stringToByteArray(const std::string & s, byte* a, int maxLength);
38    static int byteArrayToString(const byte* a, std::string&s, int maxLength);
39//    static int byteArrayToStringM(const byte* a, char*& s );
[6341]40
[6128]41    //Test
42    static char* floatToBinString(float x);
[6341]43
[6753]44//     static byte* floatToByteArray(float x);
45//     static float byteArrayToFloat(byte* a);
[6341]46
[6753]47    static int floatToByteArray(float x, byte* a, int length);
48    static int byteArrayToFloat(const byte* a, float* x);
49
[6634]50    static int _floatToByteArray(float x, byte* a, int length);
51    static int _byteArrayToFloat(const byte* a, float* x);
52
53
[6753]54
[6634]55    static void debug();
56    static void floatTest(float x);
[6737]57    static void ArrayfloatTest(float x);
[6634]58    static float getDenormConst();
59
60
[6106]61  private:
62    Converter();
[6981]63    virtual ~Converter();
[6106]64};
65
[6634]66#undef byte
67
[6106]68#endif /*_CONVERTER*/
Note: See TracBrowser for help on using the repository browser.