-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.h
More file actions
44 lines (30 loc) · 1.18 KB
/
Copy pathHelper.h
File metadata and controls
44 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <vector>
#include <string>
#include <WinSock2.h>
using std::string;
class Helper
{
public:
static int getMessageTypeCode(SOCKET sc);
static char* getPartFromSocket(SOCKET sc, int bytesNum, int flags);
static int getIntPartFromSocket(SOCKET sc, int bytesNum);
static string getStringPartFromSocket(SOCKET sc, int bytesNum);
static void sendData(SOCKET sc, std::string message);
static string getPaddedNumber(int num, int digits);
private:
static char* Helper::getPartFromSocket(SOCKET sc, int bytesNum);
};
#ifdef _DEBUG // vs add this define in debug mode
#include <stdio.h>
// Q: why do we need traces ?
// A: traces are a nice and easy way to detect bugs without even debugging
// or to understand what happened in case we miss the bug in the first time
#define TRACE(msg, ...) printf(msg "\n", __VA_ARGS__);
// for convenient reasons we did the traces in stdout
// at general we would do this in the error stream like that
// #define TRACE(msg, ...) fprintf(stderr, msg "\n", __VA_ARGS__);
#else // we want nothing to be printed in release version
#define TRACE(msg, ...) printf(msg "\n", __VA_ARGS__);
#define TRACE(msg, ...) // do nothing
#endif