pmt: reformat code
This commit is contained in:
@@ -75,6 +75,7 @@ static Helper::garbageCollector collector;
|
|||||||
int Main(int argc, char **argv) {
|
int Main(int argc, char **argv) {
|
||||||
try {
|
try {
|
||||||
// try-catch start
|
// try-catch start
|
||||||
|
Helper::LoggingProperties::setProgramName("pmt");
|
||||||
collector.closeAfterProgress(pstdout);
|
collector.closeAfterProgress(pstdout);
|
||||||
collector.closeAfterProgress(pstderr);
|
collector.closeAfterProgress(pstderr);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
bool cls::isUsed() const { return cmd->parsed(); }
|
bool cls::isUsed() const { return cmd->parsed(); }
|
||||||
#define NAME(cls) const char *cls::name() const
|
#define NAME(cls) const char *cls::name() const
|
||||||
|
|
||||||
#define COMMON_LAMBDA_PARAMS \
|
#define COMMON_LAMBDA_PARAMS \
|
||||||
(std::string partition, const PartitionMap::Map_t::BasicInf props)
|
(std::string partition, const PartitionMap::Map_t::BasicInf props)
|
||||||
#define COMMON_FUNCTION_BODY() \
|
#define COMMON_FUNCTION_BODY() \
|
||||||
CLI::App *cmd = nullptr; \
|
CLI::App *cmd = nullptr; \
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <tuple>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility> // for std::pair
|
#include <utility> // for std::pair
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace PartitionMap {
|
namespace PartitionMap {
|
||||||
struct _entry {
|
struct _entry {
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
basic_partition_map(const std::string &name, uint64_t size, bool logical);
|
basic_partition_map(const std::string &name, uint64_t size, bool logical);
|
||||||
basic_partition_map(const basic_partition_map &other);
|
basic_partition_map(const basic_partition_map &other);
|
||||||
basic_partition_map(basic_partition_map&& other) noexcept;
|
basic_partition_map(basic_partition_map &&other) noexcept;
|
||||||
basic_partition_map();
|
basic_partition_map();
|
||||||
~basic_partition_map();
|
~basic_partition_map();
|
||||||
|
|
||||||
@@ -348,7 +348,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get map contents as vector (std::tuple type).
|
* Get map contents as vector (std::tuple type).
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] operator std::vector<std::tuple<std::string, uint64_t, bool>>() const;
|
[[nodiscard]]
|
||||||
|
operator std::vector<std::tuple<std::string, uint64_t, bool>>() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get total partition count in map (int type).
|
* Get total partition count in map (int type).
|
||||||
@@ -413,7 +414,6 @@ std::string formatMagic(uint64_t magic);
|
|||||||
#define T_NAME 0
|
#define T_NAME 0
|
||||||
#define T_TYPE 1
|
#define T_TYPE 1
|
||||||
#define T_SIZE 2
|
#define T_SIZE 2
|
||||||
#define T_VEC_DECL_TYPE \
|
#define T_VEC_DECL_TYPE std::vector<std::tuple<std::string, uint64_t, bool>>
|
||||||
std::vector<std::tuple<std::string, uint64_t, bool>>
|
|
||||||
|
|
||||||
#endif // #ifndef LIBPARTITION_MAP_LIB_HPP
|
#endif // #ifndef LIBPARTITION_MAP_LIB_HPP
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ void basic_partition_map_builder::_insert_logicals(Map_t &&logicals) {
|
|||||||
<< "merging created logical partition list to this object's variable."
|
<< "merging created logical partition list to this object's variable."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
_current_map.merge(logicals);
|
_current_map.merge(logicals);
|
||||||
LOGN(MAP, INFO) << "Cleaning created logical partition because not need more." << std::endl;
|
LOGN(MAP, INFO) << "Cleaning created logical partition because not need more."
|
||||||
|
<< std::endl;
|
||||||
logicals.clear();
|
logicals.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +162,8 @@ basic_partition_map_builder::basic_partition_map_builder(
|
|||||||
_map_builded = true;
|
_map_builded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map_builder::basic_partition_map_builder(basic_partition_map_builder&& other) noexcept {
|
basic_partition_map_builder::basic_partition_map_builder(
|
||||||
|
basic_partition_map_builder &&other) noexcept {
|
||||||
_current_map = Map_t(std::move(other._current_map));
|
_current_map = Map_t(std::move(other._current_map));
|
||||||
_workdir = std::move(other._workdir);
|
_workdir = std::move(other._workdir);
|
||||||
_any_generating_error = other._any_generating_error;
|
_any_generating_error = other._any_generating_error;
|
||||||
@@ -386,17 +388,14 @@ const Map_t &basic_partition_map_builder::operator*() const {
|
|||||||
return _current_map;
|
return _current_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map_builder::operator std::vector<std::tuple<std::string, uint64_t, bool>>() const {
|
basic_partition_map_builder::operator std::vector<
|
||||||
|
std::tuple<std::string, uint64_t, bool>>() const {
|
||||||
return _current_map;
|
return _current_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map_builder::operator int() const {
|
basic_partition_map_builder::operator int() const { return _current_map; }
|
||||||
return _current_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
basic_partition_map_builder::operator std::string() const {
|
basic_partition_map_builder::operator std::string() const { return _workdir; }
|
||||||
return _workdir;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getLibVersion() { MKVERSION("libpartition_map"); }
|
std::string getLibVersion() { MKVERSION("libpartition_map"); }
|
||||||
} // namespace PartitionMap
|
} // namespace PartitionMap
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ basic_partition_map::basic_partition_map(const basic_partition_map &other)
|
|||||||
std::copy(other._data, other._data + _count, _data);
|
std::copy(other._data, other._data + _count, _data);
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map::basic_partition_map(basic_partition_map&& other) noexcept
|
basic_partition_map::basic_partition_map(basic_partition_map &&other) noexcept
|
||||||
: _data(new _entry[other._capacity]), _count(other._count),
|
: _data(new _entry[other._capacity]), _count(other._count),
|
||||||
_capacity(other._capacity) {
|
_capacity(other._capacity) {
|
||||||
std::copy(other._data, other._data + _count, _data);
|
std::copy(other._data, other._data + _count, _data);
|
||||||
@@ -229,17 +229,17 @@ bool basic_partition_map::operator!=(const basic_partition_map &other) const {
|
|||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map::operator std::vector<std::tuple<std::string, uint64_t, bool>>() const {
|
basic_partition_map::operator std::vector<
|
||||||
|
std::tuple<std::string, uint64_t, bool>>() const {
|
||||||
std::vector<std::tuple<std::string, uint64_t, bool>> v;
|
std::vector<std::tuple<std::string, uint64_t, bool>> v;
|
||||||
if (_count == 0) return {};
|
if (_count == 0) return {};
|
||||||
for (size_t i = 0; i < _count; i++)
|
for (size_t i = 0; i < _count; i++)
|
||||||
v.emplace_back(_data[i].name, _data[i].props.size, _data[i].props.isLogical);
|
v.emplace_back(_data[i].name, _data[i].props.size,
|
||||||
|
_data[i].props.isLogical);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_partition_map::operator int() const{
|
basic_partition_map::operator int() const { return static_cast<int>(_count); }
|
||||||
return static_cast<int>(_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
basic_partition_map::iterator basic_partition_map::begin() const {
|
basic_partition_map::iterator basic_partition_map::begin() const {
|
||||||
return iterator(_data);
|
return iterator(_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user