pmt: reformat code
This commit is contained in:
134
include/PartitionManager/PartitionManager.hpp
Executable file → Normal file
134
include/PartitionManager/PartitionManager.hpp
Executable file → Normal file
@@ -17,105 +17,109 @@
|
||||
#ifndef LIBPMT_LIB_HPP
|
||||
#define LIBPMT_LIB_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <libhelper/lib.hpp>
|
||||
#include <libpartition_map/lib.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#include <CLI/CLI11.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#define PMT "libpmt"
|
||||
#define PMT "libpmt"
|
||||
#define PMTE "pmt"
|
||||
#define PMTF "libpmt-function-manager"
|
||||
|
||||
namespace PartitionManager {
|
||||
// All function classes must inherit from this class.
|
||||
class basic_function {
|
||||
public:
|
||||
CLI::App *cmd = nullptr;
|
||||
// All function classes must inherit from this class.
|
||||
class basic_function {
|
||||
public:
|
||||
CLI::App *cmd = nullptr;
|
||||
|
||||
virtual bool init(CLI::App &_app) = 0;
|
||||
virtual bool run() = 0;
|
||||
virtual bool init(CLI::App &_app) = 0;
|
||||
virtual bool run() = 0;
|
||||
|
||||
[[nodiscard]] virtual bool isUsed() const = 0;
|
||||
[[nodiscard]] virtual const char *name() const = 0;
|
||||
[[nodiscard]] virtual bool isUsed() const = 0;
|
||||
[[nodiscard]] virtual const char *name() const = 0;
|
||||
|
||||
virtual ~basic_function() = default;
|
||||
};
|
||||
virtual ~basic_function() = default;
|
||||
};
|
||||
|
||||
// A class for function management.
|
||||
class basic_function_manager final {
|
||||
private:
|
||||
std::vector<std::unique_ptr<basic_function> > _functions;
|
||||
// A class for function management.
|
||||
class basic_function_manager final {
|
||||
private:
|
||||
std::vector<std::unique_ptr<basic_function>> _functions;
|
||||
|
||||
public:
|
||||
void registerFunction(std::unique_ptr<basic_function> _func, CLI::App &_app);
|
||||
public:
|
||||
void registerFunction(std::unique_ptr<basic_function> _func, CLI::App &_app);
|
||||
|
||||
[[nodiscard]] bool handleAll() const;
|
||||
};
|
||||
[[nodiscard]] bool handleAll() const;
|
||||
};
|
||||
|
||||
class basic_variables final {
|
||||
public:
|
||||
basic_variables();
|
||||
~basic_variables();
|
||||
class basic_variables final {
|
||||
public:
|
||||
basic_variables();
|
||||
~basic_variables();
|
||||
|
||||
PartitionMap::BuildMap *PartMap;
|
||||
PartitionMap::BuildMap *PartMap;
|
||||
|
||||
std::string searchPath, logFile;
|
||||
bool onLogical;
|
||||
bool quietProcess;
|
||||
bool verboseMode;
|
||||
bool viewVersion;
|
||||
bool forceProcess;
|
||||
};
|
||||
std::string searchPath, logFile;
|
||||
bool onLogical;
|
||||
bool quietProcess;
|
||||
bool verboseMode;
|
||||
bool viewVersion;
|
||||
bool forceProcess;
|
||||
};
|
||||
|
||||
class variableProtect final {
|
||||
private:
|
||||
basic_variables* _ptr = nullptr;
|
||||
class variableProtect final {
|
||||
private:
|
||||
basic_variables *_ptr = nullptr;
|
||||
|
||||
public:
|
||||
variableProtect();
|
||||
~variableProtect();
|
||||
public:
|
||||
variableProtect();
|
||||
~variableProtect();
|
||||
|
||||
void setVariablePointer(basic_variables* &_ptr);
|
||||
};
|
||||
void setVariablePointer(basic_variables *&_ptr);
|
||||
};
|
||||
|
||||
using FunctionBase = basic_function;
|
||||
using FunctionManager = basic_function_manager;
|
||||
using VariableTable = basic_variables;
|
||||
using Error = Helper::Error;
|
||||
using FunctionBase = basic_function;
|
||||
using FunctionManager = basic_function_manager;
|
||||
using VariableTable = basic_variables;
|
||||
using Error = Helper::Error;
|
||||
|
||||
extern VariableTable *Variables;
|
||||
extern VariableTable *Variables;
|
||||
|
||||
int Main(int argc, char **argv);
|
||||
int Main(int argc, char **argv);
|
||||
|
||||
// Print messages if not using quiet mode
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
void print(const char *format, ...);
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
void println(const char *format, ...);
|
||||
// Print messages if not using quiet mode
|
||||
__attribute__((format(printf, 1, 2))) void print(const char *format, ...);
|
||||
__attribute__((format(printf, 1, 2))) void println(const char *format, ...);
|
||||
|
||||
// Format it input and return as std::string
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
std::string format(const char *format, ...);
|
||||
// Format it input and return as std::string
|
||||
__attribute__((format(printf, 1, 2))) std::string format(const char *format,
|
||||
...);
|
||||
|
||||
// If there is a delimiter in the string, CLI::detail::split returns; if not, an empty vector is returned. And checks duplicate arguments.
|
||||
std::vector<std::string> splitIfHasDelim(const std::string &s, char delim, bool checkForBadUsage = false);
|
||||
// If there is a delimiter in the string, CLI::detail::split returns; if not, an
|
||||
// empty vector is returned. And checks duplicate arguments.
|
||||
std::vector<std::string> splitIfHasDelim(const std::string &s, char delim,
|
||||
bool checkForBadUsage = false);
|
||||
|
||||
// Process vectors with input strings. Use for [flag(s)]-[other flag(s)] situations
|
||||
void processCommandLine(std::vector<std::string> &vec1, std::vector<std::string> &vec2, const std::string &s1,
|
||||
const std::string &s2, char delim, bool checkForBadUsage = false);
|
||||
// Process vectors with input strings. Use for [flag(s)]-[other flag(s)]
|
||||
// situations
|
||||
void processCommandLine(std::vector<std::string> &vec1,
|
||||
std::vector<std::string> &vec2, const std::string &s1,
|
||||
const std::string &s2, char delim,
|
||||
bool checkForBadUsage = false);
|
||||
|
||||
// Setting ups buffer size
|
||||
void setupBufferSize(int &size, const std::string &partition);
|
||||
// Setting ups buffer size
|
||||
void setupBufferSize(int &size, const std::string &partition);
|
||||
|
||||
std::string getLibVersion();
|
||||
std::string getLibVersion();
|
||||
|
||||
std::string getAppVersion(); // Not Android app version (an Android app is planned!), tells pmt version.
|
||||
std::string getAppVersion(); // Not Android app version (an Android app is
|
||||
// planned!), tells pmt version.
|
||||
} // namespace PartitionManager
|
||||
|
||||
#endif // #ifndef LIBPMT_LIB_HPP
|
||||
|
||||
Reference in New Issue
Block a user