-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvarlength.hpp
47 lines (36 loc) · 979 Bytes
/
varlength.hpp
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
45
46
47
/*
Copyright (c) 2014 Auston Sterling
See LICENSE for copying permissions.
-----Variable Length Number Header-----
Auston Sterling
MIDI's variable-length number format. Big-endian, where the most significant bit
in each byte indicates whether or not there are more bytes to read. The maximum
length is four bytes.
*/
#ifndef _varlength_hpp_
#define _varlength_hpp_
#include <cstdint>
#include <string>
namespace midi
{
const int VARLENGTH_MAX_SIZE = 4;
class VarLength
{
public:
//Constructors
VarLength();
VarLength(const VarLength& vl);
VarLength(std::uint32_t in);
//Operators and typecasts
operator std::uint32_t() const;
VarLength& operator=(const VarLength& vl);
std::uint8_t operator[](unsigned char index) const;
//Other useful functions
std::size_t size() const;
private:
//The number itself
std::uint8_t data_[VARLENGTH_MAX_SIZE];
};
} //Namespace
#endif