Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #pragma once
00015
00019 #include <list>
00020 #include <string>
00021
00022 #include "Types.h"
00023
00024 namespace kNet
00025 {
00026
00028 typedef bool bit;
00029
00032 enum BasicSerializedDataType
00033 {
00035 SerialInvalid = 0,
00036
00037 SerialBit,
00038 SerialU8,
00039 SerialS8,
00040 SerialU16,
00041 SerialS16,
00042 SerialU32,
00043 SerialS32,
00044 SerialU64,
00045 SerialS64,
00046 SerialFloat,
00047 SerialDouble,
00048 SerialString,
00049 SerialStruct,
00050 SerialDynamicCount,
00051
00053 NumSerialTypes
00054 };
00055
00057 const char *SerialTypeToString(BasicSerializedDataType type);
00059 BasicSerializedDataType StringToSerialType(const char *type);
00061 size_t SerialTypeSize(BasicSerializedDataType type);
00062
00064 template<typename T>
00065 struct SerializedDataTypeTraits
00066 {
00067
00068
00069
00070 };
00071
00072 template<> struct SerializedDataTypeTraits<bit> { static const BasicSerializedDataType type = SerialBit; static const int bitSize = 1; };
00073 template<> struct SerializedDataTypeTraits<u8> { static const BasicSerializedDataType type = SerialU8; static const int bitSize = 8; };
00074 template<> struct SerializedDataTypeTraits<s8> { static const BasicSerializedDataType type = SerialS8; static const int bitSize = 8; };
00075 template<> struct SerializedDataTypeTraits<u16> { static const BasicSerializedDataType type = SerialU16; static const int bitSize = 16; };
00076 template<> struct SerializedDataTypeTraits<s16> { static const BasicSerializedDataType type = SerialS16; static const int bitSize = 16; };
00077 template<> struct SerializedDataTypeTraits<u32> { static const BasicSerializedDataType type = SerialU32; static const int bitSize = 32; };
00078 template<> struct SerializedDataTypeTraits<s32> { static const BasicSerializedDataType type = SerialS32; static const int bitSize = 32; };
00079 template<> struct SerializedDataTypeTraits<u64> { static const BasicSerializedDataType type = SerialU64; static const int bitSize = 64; };
00080 template<> struct SerializedDataTypeTraits<s64> { static const BasicSerializedDataType type = SerialS64; static const int bitSize = 64; };
00081 template<> struct SerializedDataTypeTraits<float> { static const BasicSerializedDataType type = SerialFloat; static const int bitSize = 32; };
00082 template<> struct SerializedDataTypeTraits<double> { static const BasicSerializedDataType type = SerialDouble; static const int bitSize = 64; };
00083 template<> struct SerializedDataTypeTraits<char*> { static const BasicSerializedDataType type = SerialString; static const int bitSize = 0; };
00084 template<> struct SerializedDataTypeTraits<const char*> { static const BasicSerializedDataType type = SerialString; static const int bitSize = 0; };
00085 template<> struct SerializedDataTypeTraits<std::string> { static const BasicSerializedDataType type = SerialString; static const int bitSize = 0; };
00086
00087 }