summaryrefslogtreecommitdiffstats
path: root/code/utility.h
blob: 32120cb0345b25475cdb814df477d17d3454534b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once
#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));
}