Files
ternfs-XTXMarkets/cpp/Msgs.cpp
Francesco Mazzoli fc0cee0e07 C++ shard
Most operations apart from spans-related ones work. Using this as
a checkpoint -- the Python code is currently not really working,
I'm working to migrate to pretty much a full C++/go world.
2022-12-10 10:55:25 +00:00

39 lines
1003 B
C++

#include <unordered_map>
#include "Msgs.hpp"
std::ostream& operator<<(std::ostream& out, ShardId shard) {
out << int(shard.u8);
return out;
}
std::ostream& operator<<(std::ostream& out, InodeId id) {
const char cfill = out.fill();
out << "0x" << std::setfill('0') << std::setw(16) << std::hex << id.u64;
out << std::dec << std::setfill(cfill);
return out;
}
std::ostream& operator<<(std::ostream& out, InodeIdExtra id) {
out << "[" << (id.extra() ? 'X' : ' ') << "]" << id.id();
return out;
}
std::ostream& operator<<(std::ostream& out, Parity parity) {
if (parity.u8 == 0) {
return out << "Parity(0)";
} else {
out << "Parity(" << (int)parity.dataBlocks() << ", " << (int)parity.parityBlocks() << ")";
}
return out;
}
static const std::unordered_map<std::string, uint8_t> STORAGE_CLASSES_BY_NAME = {
{"FLASH", 2},
{"HDD", 3},
};
uint8_t storageClassByName(const char* name) {
return STORAGE_CLASSES_BY_NAME.at(name);
}