Fixed "ws2_32.lib" pragma
Initialization is now a class Started new StringConverter class and revamped the BitConverter class - WIP
This commit is contained in:
3
TODO
3
TODO
@ -2,3 +2,6 @@ initialization code for other operating systems - currently VoidNet only support
|
|||||||
initialization code for tcp client for other operating systems - "
|
initialization code for tcp client for other operating systems - "
|
||||||
handle SendNetworkMessage errors for windows
|
handle SendNetworkMessage errors for windows
|
||||||
handle ReceiveDataArray errors for windows
|
handle ReceiveDataArray errors for windows
|
||||||
|
|
||||||
|
revamped BitConverter class
|
||||||
|
new StringConverter class
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,14 +5,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
|
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
|
||||||
|
|
||||||
WSADATA wsa_data;
|
|
||||||
|
|
||||||
typedef signed char int8, sbyte;
|
typedef signed char int8, sbyte;
|
||||||
typedef unsigned char uint8, byte;
|
typedef unsigned char uint8, byte;
|
||||||
typedef signed short int16;
|
typedef signed short int16;
|
||||||
|
|||||||
@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
|
||||||
VoidCode initialize();
|
|
||||||
|
struct Initialization
|
||||||
|
{
|
||||||
|
static VoidCode initialize();
|
||||||
|
static WSADATA wsa_data;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
@ -22,6 +23,39 @@ struct Utility
|
|||||||
|
|
||||||
static byte *FromUint16(uint16 number);
|
static byte *FromUint16(uint16 number);
|
||||||
static uint16 ToUint16(byte *bytes, uint16 start_index);
|
static uint16 ToUint16(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromUint32(uint32 number);
|
||||||
|
static uint32 *ToUint32(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromUint64(uint64 number);
|
||||||
|
static uint64 ToUint64(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromInt8(int8 number);
|
||||||
|
static int8 ToInt8(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromInt16(int16 number);
|
||||||
|
static int16 ToInt16(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromInt32(int32 number);
|
||||||
|
static int32 ToInt32(byte *bytes, uint16 start_index);
|
||||||
|
|
||||||
|
static byte *FromInt64(int64 number);
|
||||||
|
static int64 ToInt64(byte *bytes, uint16 start_index);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StringConverter
|
||||||
|
{
|
||||||
|
static const std::string &ToString(bool value);
|
||||||
|
static const std::string &ToString(uint8 value);
|
||||||
|
static const std::string &ToString(uint16 value);
|
||||||
|
static const std::string &ToString(uint32 value);
|
||||||
|
static const std::string &ToString(uint64 value);
|
||||||
|
static const std::string &ToString(int8 value);
|
||||||
|
static const std::string &ToString(int16 value);
|
||||||
|
static const std::string &ToString(int32 value);
|
||||||
|
static const std::string &ToString(int64 value);
|
||||||
|
|
||||||
|
static const std::string &ToString(byte *bytes, uint16 start_index = 0, uint16 lenght = 0);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
VoidCode initialize()
|
VoidCode Initialization::initialize()
|
||||||
{
|
{
|
||||||
uint16 code = WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
uint16 code = WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
||||||
if (code != 0)
|
if (code != 0)
|
||||||
|
|||||||
126
src/Utility.cpp
126
src/Utility.cpp
@ -18,28 +18,130 @@ void Utility::DeleteArray(void *pointer)
|
|||||||
|
|
||||||
byte *Utility::BitConverter::FromUint8(uint8 number)
|
byte *Utility::BitConverter::FromUint8(uint8 number)
|
||||||
{
|
{
|
||||||
if (number == 0)
|
|
||||||
return nullptr;
|
|
||||||
return reinterpret_cast<byte*>(number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 Utility::BitConverter::ToUint8(byte *bytes, uint16 start_index)
|
uint8 Utility::BitConverter::ToUint8(byte *bytes, uint16 start_index)
|
||||||
{
|
{
|
||||||
if (bytes == nullptr)
|
|
||||||
return 0;
|
|
||||||
return reinterpret_cast<uint8>(&bytes[start_index]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte *Utility::BitConverter::FromUint16(uint16 number)
|
byte *Utility::BitConverter::FromUint16(uint16 number)
|
||||||
{
|
{
|
||||||
if (number == 0)
|
|
||||||
return nullptr;
|
|
||||||
return reinterpret_cast<byte*>(number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 Utility::BitConverter::ToUint16(byte *bytes, uint16 start_index)
|
uint16 Utility::BitConverter::ToUint16(byte *bytes, uint16 start_index)
|
||||||
{
|
{
|
||||||
if (bytes == nullptr)
|
|
||||||
return 0;
|
}
|
||||||
return reinterpret_cast<uint16>(&bytes[start_index]);
|
|
||||||
|
byte * Utility::BitConverter::FromUint32(uint32 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 * Utility::BitConverter::ToUint32(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte * Utility::BitConverter::FromUint64(uint64 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 Utility::BitConverter::ToUint64(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return uint64();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte * Utility::BitConverter::FromInt8(int8 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8 Utility::BitConverter::ToInt8(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return int8();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte * Utility::BitConverter::FromInt16(int16 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16 Utility::BitConverter::ToInt16(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return int16();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte * Utility::BitConverter::FromInt32(int32 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Utility::BitConverter::ToInt32(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return int32();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte * Utility::BitConverter::FromInt64(int64 number)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 Utility::BitConverter::ToInt64(byte * bytes, uint16 start_index)
|
||||||
|
{
|
||||||
|
return int64();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(bool value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(uint8 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(uint16 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(uint32 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(uint64 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(int8 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(int16 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(int32 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(int64 value)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & Utility::StringConverter::ToString(byte * bytes, uint16 start_index, uint16 lenght)
|
||||||
|
{
|
||||||
|
// TODO: insert return statement here
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user