#include <base_converter.h>
Definition at line 18 of file base_converter.h.
Definition at line 7 of file base_converter.cc.
11 if (sourceBaseSet.empty() || targetBaseSet.empty())
12 throw std::invalid_argument(
"Invalid base character set");
std::string source_base_set_
std::string target_base_set_
Definition at line 107 of file base_converter.cc.
110 unsigned int numberBase = (
unsigned int)baseDigits.length();
112 for (
size_t i = 0; i <
value.length(); ++i) {
113 result *= numberBase;
114 size_t c = baseDigits.find(
value[i]);
115 if (c == std::string::npos)
116 throw std::runtime_error(
"base_converter::Invalid character");
118 result += (
unsigned int)c;
Definition at line 23 of file base_converter.cc.
static constexpr char const * binary_set()
static constexpr char const * decimal_set()
bool bin2dec(std::string const &input, std::string const &wanted)
static constexpr char const* cet::base_converter::binary_set |
( |
| ) |
|
|
inlinestaticprivate |
Definition at line 44 of file base_converter.cc.
52 }
while (!
value.empty() &&
static unsigned int divide(std::string const &baseDigits, std::string &x, unsigned int y)
std::string source_base_set_
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
unsigned int get_target_base() const
std::string target_base_set_
Definition at line 93 of file base_converter.cc.
95 unsigned int numberBase = (
unsigned int)baseDigits.length();
98 result.push_back(baseDigits[
value % numberBase]);
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
Definition at line 16 of file base_converter.cc.
static constexpr char const * binary_set()
static constexpr char const * decimal_set()
bool dec2bin(std::string const &input, std::string const &wanted)
Definition at line 30 of file base_converter.cc.
bool dec2hex(std::string const &input, std::string const &wanted)
static constexpr char const * decimal_set()
static constexpr char const * hex_set()
static constexpr char const* cet::base_converter::decimal_set |
( |
| ) |
|
|
inlinestaticprivate |
Definition at line 60 of file base_converter.cc.
66 size_t length =
x.length();
67 for (
size_t i = 0; i < length; ++i) {
68 size_t j = i + 1 +
x.length() - length;
74 quotient.push_back(baseDigits[value /
y]);
79 unsigned int remainder =
base2dec(baseDigits,
x);
82 size_t n = quotient.find_first_not_of(baseDigits[0]);
83 if (n != std::string::npos) {
84 x = quotient.substr(n);
static unsigned int base2dec(std::string const &baseDigits, std::string const &value)
static std::string dec2base(std::string const &baseDigits, unsigned int value)
unsigned int cet::base_converter::get_source_base |
( |
| ) |
const |
|
inline |
std::string const & cet::base_converter::get_source_base_set |
( |
| ) |
const |
|
inline |
unsigned int cet::base_converter::get_target_base |
( |
| ) |
const |
|
inline |
std::string const & cet::base_converter::get_target_base_set |
( |
| ) |
const |
|
inline |
static constexpr char const* cet::base_converter::hex_set |
( |
| ) |
|
|
inlinestaticprivate |
Definition at line 37 of file base_converter.cc.
static constexpr char const * decimal_set()
static constexpr char const * hex_set()
bool hex2dec(std::string const &input, std::string const &wanted)
The documentation for this class was generated from the following files: