1 #ifndef MHO_EncodeValue_HH__
2 #define MHO_EncodeValue_HH__
38 std::string encoded_value =
"";
39 std::stack< char > cstack;
40 uint64_t
base = character_set.size();
49 cstack.push(character_set[r]);
53 while(cstack.size() != 0)
55 encoded_value += cstack.top();
69 inline uint64_t
decode_value(
const std::string& code,
const std::string& character_set)
71 uint64_t decoded_value = 0;
72 std::stack< char > cstack;
73 uint64_t
base = character_set.size();
75 for(
auto it = code.rbegin(); it != code.rend(); it++)
77 uint64_t place_value = character_set.find(*it);
78 if(place_value != std::string::npos)
80 decoded_value += place_value * bpower;
149 if(label.size() == 1)
157 return extended_value;
Class MHO_ChannelIndexLabeler.
Definition: MHO_EncodeDecodeValue.hh:96
void SetExtendedChannelChars(const std::string &ex_set)
Setter for extended channel chars.
Definition: MHO_EncodeDecodeValue.hh:121
MHO_ChannelIndexLabeler()
Definition: MHO_EncodeDecodeValue.hh:98
uint64_t DecodeLabelToValue(const std::string &label) const
Decodes a channel label to its corresponding value.
Definition: MHO_EncodeDecodeValue.hh:147
void SetDefaultChannelChars(const std::string &ch_set)
Setter for channel chars - provides the option to use different character sets.
Definition: MHO_EncodeDecodeValue.hh:114
std::string fExtendedChannelChars
Definition: MHO_EncodeDecodeValue.hh:164
std::string fDefaultChannelChars
Definition: MHO_EncodeDecodeValue.hh:163
virtual ~MHO_ChannelIndexLabeler()
Definition: MHO_EncodeDecodeValue.hh:107
std::string EncodeValueToLabel(const uint64_t &value) const
Encodes a uint64_t value into a label string using default and extended encoding schemes.
Definition: MHO_EncodeDecodeValue.hh:130
int base
Definition: fourfit3.c:62
#define max(a, b)
Definition: max555.c:10
Definition: MHO_ChannelLabeler.hh:17
std::string encode_value(const uint64_t &value, const std::string &character_set)
Function encode_value.
Definition: MHO_EncodeDecodeValue.hh:36
uint64_t decode_value(const std::string &code, const std::string &character_set)
Function decode_value.
Definition: MHO_EncodeDecodeValue.hh:69