PhoenixProtocolBuffer  1.0.1
Set of tools to decode offset from protocol buffer
Loading...
Searching...
No Matches
phoenix_varint.cpp File Reference
#include "phoenix_varint.h"
+ Include dependency graph for phoenix_varint.cpp:

Go to the source code of this file.

Functions

size_t phoenix_readVarInt (char *&iter)
 Reads and print a varint from protocol buffer.
 
void phoenix_skipVarInt (char *&iter)
 Skips a varint.
 
size_t phoenix_varIntToValue (const std::vector< uint8_t > &vecBitSize)
 Convert a varint into a value.
 

Function Documentation

◆ phoenix_readVarInt()

size_t phoenix_readVarInt ( char *& iter)

Reads and print a varint from protocol buffer.

Parameters
[out]iter: position on the current message to be used
Returns
value of the varint

Definition at line 29 of file phoenix_varint.cpp.

29 {
30 std::vector<uint8_t> vecBitSize;
31 bool isExtraByte(false);
32 do{
33 char packedSizeVal = *iter;
34 uint8_t val = packedSizeVal & 127;
35 vecBitSize.push_back(val); //Get the first 7 bytes
36 isExtraByte = packedSizeVal & 128; //Get only the strong bit
37 iter += 1lu;
38 }while(isExtraByte);
39 return phoenix_varIntToValue(vecBitSize);
40}
size_t phoenix_varIntToValue(const std::vector< uint8_t > &vecBitSize)
Convert a varint into a value.

References phoenix_varIntToValue().

Referenced by FieldParser::loadComputeFieldOffset(), FieldParser::loadComputeFieldOffsetArray(), FieldParser::loadFieldFromOffset(), phoenix_fieldPrint(), phoenix_fieldPrintArray(), and phoenix_fieldSkip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_skipVarInt()

void phoenix_skipVarInt ( char *& iter)

Skips a varint.

Parameters
[out]iter: iterator over the message to be used

Definition at line 45 of file phoenix_varint.cpp.

45 {
46 bool isExtraByte(false);
47 do{
48 char packedSizeVal = *iter;
49 isExtraByte = packedSizeVal & 128; //Get only the strong bit
50 iter += 1lu;
51 }while(isExtraByte);
52}

Referenced by phoenix_fieldSkip().

+ Here is the caller graph for this function:

◆ phoenix_varIntToValue()

size_t phoenix_varIntToValue ( const std::vector< uint8_t > & vecBitSize)

Convert a varint into a value.

Parameters
vecBitSize: vector of bytes
Returns
converted value

Definition at line 15 of file phoenix_varint.cpp.

15 {
16 size_t res(0lu), factor(1lu), nbByte(vecBitSize.size());
17 for(size_t i(0lu); i < nbByte; ++i){
18 size_t value(vecBitSize[i]);
19 res += value * factor;
20 factor *= 128lu;
21 }
22 return res;
23}

Referenced by phoenix_readVarInt().

+ Here is the caller graph for this function: