mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-07 05:23:02 +00:00
chore: update code style in ZoneCodeGenerator entrypoint
This commit is contained in:
@@ -13,11 +13,39 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class ZoneCodeGenerator::Impl
|
||||
class ZoneCodeGeneratorImpl : public ZoneCodeGenerator
|
||||
{
|
||||
ZoneCodeGeneratorArguments m_args;
|
||||
std::unique_ptr<IDataRepository> m_repository;
|
||||
public:
|
||||
ZoneCodeGeneratorImpl()
|
||||
: m_repository(std::make_unique<InMemoryRepository>())
|
||||
{
|
||||
}
|
||||
|
||||
int Run(const int argc, const char** argv) override
|
||||
{
|
||||
auto shouldContinue = true;
|
||||
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||
return 1;
|
||||
|
||||
if (!shouldContinue)
|
||||
return 0;
|
||||
|
||||
if (!ReadHeaderData() || !ReadCommandsData())
|
||||
return 1;
|
||||
|
||||
if (m_args.ShouldPrint())
|
||||
PrintData();
|
||||
|
||||
if (m_args.ShouldGenerate())
|
||||
{
|
||||
if (!GenerateCode())
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ReadHeaderData()
|
||||
{
|
||||
for (const auto& headerFile : m_args.m_header_paths)
|
||||
@@ -56,51 +84,11 @@ class ZoneCodeGenerator::Impl
|
||||
return codeGenerator.GenerateCode(m_repository.get());
|
||||
}
|
||||
|
||||
public:
|
||||
Impl()
|
||||
{
|
||||
m_repository = std::make_unique<InMemoryRepository>();
|
||||
}
|
||||
|
||||
int Run(const int argc, const char** argv)
|
||||
{
|
||||
auto shouldContinue = true;
|
||||
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||
return 1;
|
||||
|
||||
if (!shouldContinue)
|
||||
return 0;
|
||||
|
||||
if (!ReadHeaderData() || !ReadCommandsData())
|
||||
return 1;
|
||||
|
||||
if (m_args.ShouldPrint())
|
||||
{
|
||||
PrintData();
|
||||
}
|
||||
|
||||
if (m_args.ShouldGenerate())
|
||||
{
|
||||
if (!GenerateCode())
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
ZoneCodeGeneratorArguments m_args;
|
||||
std::unique_ptr<IDataRepository> m_repository;
|
||||
};
|
||||
|
||||
ZoneCodeGenerator::ZoneCodeGenerator()
|
||||
std::unique_ptr<ZoneCodeGenerator> ZoneCodeGenerator::Create()
|
||||
{
|
||||
m_impl = new Impl();
|
||||
}
|
||||
|
||||
ZoneCodeGenerator::~ZoneCodeGenerator()
|
||||
{
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
int ZoneCodeGenerator::Run(const int argc, const char** argv) const
|
||||
{
|
||||
return m_impl->Run(argc, argv);
|
||||
return std::make_unique<ZoneCodeGeneratorImpl>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user