summaryrefslogtreecommitdiffstats
path: root/utility.h
blob: bb2b623699a019eb15a5fc5206159033cc61de08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// Created by lag1924 on 24.03.17.
//

#ifndef PROJECT_UTILITY_H
#define PROJECT_UTILITY_H

#include <algorithm>

int VarIntRead(unsigned char *data, size_t &readed);

size_t VarIntWrite(unsigned int value, unsigned char *data);

long long int ReadVarLong(unsigned char *data, int &readed);

unsigned char *WriteVarLong(unsigned long long int value, int &len);

template<class T>
void endswap(T *objp) {
    unsigned char *memp = reinterpret_cast<unsigned char *>(objp);
    std::reverse(memp, memp + sizeof(T));
}

#endif //PROJECT_UTILITY_H