forked from billvaglienti/ProtoGen
-
Notifications
You must be signed in to change notification settings - Fork 5
/
protocolbitfield.h
45 lines (30 loc) · 1.71 KB
/
protocolbitfield.h
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
#ifndef PROTOCOLBITFIELD_H
#define PROTOCOLBITFIELD_H
/*!
* \file
* Utilities for emitting inline bitfield code and testing code
*/
#include "protocolfile.h"
#include "protocolsupport.h"
#include "protocolparser.h"
#include <string>
class ProtocolBitfield
{
public:
//! Perform the test generation, writing out the files
static void generatetest(ProtocolSupport support);
//! Compute the maximum value of a field
static uint64_t maxvalueoffield(int numbits);
//! Get the encode string for a bitfield
static std::string getEncodeString(const std::string& spacing, const std::string& argument, const std::string& dataname, const std::string& dataindex, int bitcount, int numbits);
//! Get the encode string for a bitfield
static std::string getDecodeString(const std::string& spacing, const std::string& argument, const std::string& cast, const std::string& dataname, const std::string& dataindex, int bitcount, int numbits);
//! Get the inner string that does a simple bitfield decode
static std::string getInnerDecodeString(const std::string& dataname, const std::string& dataindex, int bitcount, int numbits);
private:
//! Get the encode string for a complex bitfield (crossing byte boundaries)
static std::string getComplexEncodeString(const std::string& spacing, const std::string& argument, const std::string& dataname, const std::string& dataindex, int bitcount, int numbits);
//! Get the encode string for a complex bitfield (crossing byte boundaries)
static std::string getComplexDecodeString(const std::string& spacing, const std::string& argument, const std::string& dataname, const std::string& dataindex, int bitcount, int numbits);
};
#endif // PROTOCOLBITFIELD_H