Move blocklenght lookup table to Bases.h
This commit is contained in:
parent
407c0ad5bc
commit
6834ea4ad8
@ -1,6 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
// This lookup table holds how many digits a block is long
|
||||||
|
// in any iobase.
|
||||||
|
// This cannot be calculated on the fly, as it involves
|
||||||
|
// arithmetic with involving REALLY big numbers (like, 2^512).
|
||||||
|
// Here's how to calculate these numbers:
|
||||||
|
// Print an all 1's block in this format, and check the string size.
|
||||||
|
// That's it.
|
||||||
|
auto blockLengthByBase =
|
||||||
|
std::map<Configuration::IOBASE_FORMAT, std::size_t>({
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_BYTES, 64),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_2, 512),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_8, 171),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_10, 155),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_16, 128),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_64, 86),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_UWU, 125),
|
||||||
|
std::make_pair(Configuration::IOBASE_FORMAT::BASE_UGH, 125)
|
||||||
|
});
|
||||||
|
|
||||||
// Actually useful bases
|
// Actually useful bases
|
||||||
static const std::vector<std::string> BASE_2 = { "0","1" };
|
static const std::vector<std::string> BASE_2 = { "0","1" };
|
||||||
|
@ -3,34 +3,11 @@
|
|||||||
#include <GeneralUtility/BaseConversion.h>
|
#include <GeneralUtility/BaseConversion.h>
|
||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include <GCrypt/Util.h>
|
#include <GCrypt/Util.h>
|
||||||
#include <map>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace Leonetienne::GCrypt;
|
using namespace Leonetienne::GCrypt;
|
||||||
using namespace Leonetienne::StringTools;
|
using namespace Leonetienne::StringTools;
|
||||||
using namespace Leonetienne::GeneralUtility;
|
using namespace Leonetienne::GeneralUtility;
|
||||||
|
|
||||||
namespace {
|
|
||||||
// This lookup table holds how many digits a block is long
|
|
||||||
// in any iobase.
|
|
||||||
// This cannot be calculated on the fly, as it involves
|
|
||||||
// arithmetic with involving REALLY big numbers (like, 2^512).
|
|
||||||
// Here's how to calculate these numbers:
|
|
||||||
// Print an all 1's block in this format, and check the string size.
|
|
||||||
// That's it.
|
|
||||||
auto blockLengthByBase =
|
|
||||||
std::map<Configuration::IOBASE_FORMAT, std::size_t>({
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_BYTES, 64),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_2, 512),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_8, 171),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_10, 155),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_16, 128),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_64, 86),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_UWU, 125),
|
|
||||||
std::make_pair(Configuration::IOBASE_FORMAT::BASE_UGH, 125)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ModuleDataFormatter::FormatBlock(
|
std::string ModuleDataFormatter::FormatBlock(
|
||||||
const Block& block,
|
const Block& block,
|
||||||
const Configuration::IOBASE_FORMAT base
|
const Configuration::IOBASE_FORMAT base
|
||||||
|
Loading…
x
Reference in New Issue
Block a user