V1 #2

Merged
rboullard merged 65 commits from V1 into Development 2026-03-29 09:30:59 +00:00
2 changed files with 27 additions and 12 deletions
Showing only changes of commit 6bfd732541 - Show all commits

View File

@@ -5,15 +5,13 @@
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime loggerLifetime;
CLI::App app {"Bin2CPP allows you to generate a C++ header containing the binary content of an input file"}; CLI::App app {"Bin2CPP allows you to generate a C++ header containing the binary content of an input file"};
argv = app.ensure_utf8(argv); argv = app.ensure_utf8(argv);
std::string input; std::string input;
app.add_option("-f,--input", input, "The input file")->required(); app.add_option("-f,--input", input, "The input file");
std::string output; std::string output;
app.add_option("-o,--output", output, "The output file")->required(); app.add_option("-o,--output", output, "The output file");
std::optional<std::string> arrayType; std::optional<std::string> arrayType;
app.add_option("--arrayType", arrayType, "The type of the array"); app.add_option("--arrayType", arrayType, "The type of the array");
std::optional<std::string> arrayInclude; std::optional<std::string> arrayInclude;
@@ -22,9 +20,14 @@ int main(int argc, char** argv)
app.add_option("--arrayName", arrayName, "The array name"); app.add_option("--arrayName", arrayName, "The array name");
std::optional<std::string> customNamespace; std::optional<std::string> customNamespace;
app.add_option("--namespace", customNamespace, "The namespace"); app.add_option("--namespace", customNamespace, "The namespace");
bool verbose = false;
app.add_option("--verbose", verbose, "Activate logging");
CLI11_PARSE(app, argc, argv); CLI11_PARSE(app, argc, argv);
std::unique_ptr<Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime> loggerLifetime =
verbose ? std::make_unique<Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime>() : nullptr;
Bin2CPP::Generator generator(input); Bin2CPP::Generator generator(input);
if (arrayType) if (arrayType)
{ {

View File

@@ -79,37 +79,49 @@ class Log
#define BIN2CPP_LOG_INFO(fmt, ...) \ #define BIN2CPP_LOG_INFO(fmt, ...) \
do \ do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \ { \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \ if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \ { \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \ } \
} \
} while (0) } while (0)
#define BIN2CPP_LOG_WARN(fmt, ...) \ #define BIN2CPP_LOG_WARN(fmt, ...) \
do \ do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \ { \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \ if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \ { \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \ } \
} \
} while (0) } while (0)
#define BIN2CPP_LOG_ERROR(fmt, ...) \ #define BIN2CPP_LOG_ERROR(fmt, ...) \
do \ do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \ { \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \ if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \ { \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \ } \
} \
} while (0) } while (0)
#define BIN2CPP_LOG_FATAL(fmt, ...) \ #define BIN2CPP_LOG_FATAL(fmt, ...) \
do \ do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \ { \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \ if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \ { \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \ } \
} \
} while (0) } while (0)
#endif #endif