refactor: refactor project

- rename LIBCMO_DISABLE_COPY_MOVE -> YYCC_DEL_CLS_COPY_MOVE and LIBCMO_DEFAULT_COPY_MOVE -> YYCC_DEF_CLS_COPY_MOVE.
- fix Vector declaration generator. throw exception when operator[] face invalid index, instead of do fallback.
- rename VTAll.hpp -> VTInternal.hpp and VYUserAll -> VTAll.hpp for easy to understand.
- fix project name error in Doxygen template.
- replace all LIBCMO_OS_WIN32 to YYCC_OS == YYCC_OS_WINDOWS.
- fix some compile error (involving utf8 encoding) but not the final result.
- use correct way to include std-image library (use <> instead of "")
- finish documentation for VTUtils.hpp and VTEncoding.hpp.
This commit is contained in:
2024-08-17 20:43:27 +08:00
parent f870d4dde3
commit e682a87d25
43 changed files with 491 additions and 337 deletions

View File

@ -26,7 +26,7 @@ namespace Unvirt::CmdHelper {
mCmdChar(0), mBuffer(nullptr), mResult(nullptr),
mState(StateType::NORMAL), mPreState(StateType::NORMAL) {}
~CmdSplitter() {}
LIBCMO_DISABLE_COPY_MOVE(CmdSplitter);
YYCC_DEL_CLS_COPY_MOVE(CmdSplitter);
std::deque<std::string> Convert(const std::string& u8cmd);
protected:
@ -47,7 +47,7 @@ namespace Unvirt::CmdHelper {
public:
HelpDocument();
~HelpDocument();
LIBCMO_DISABLE_COPY_MOVE(HelpDocument);
YYCC_DEL_CLS_COPY_MOVE(HelpDocument);
void Push(const std::string& arg_name, const std::string& arg_desc);
void Pop();
@ -58,7 +58,7 @@ namespace Unvirt::CmdHelper {
struct StackItem {
StackItem() : m_Name(), m_Desc() {}
StackItem(const std::string& name, const std::string& desc) : m_Name(name), m_Desc(desc) {}
LIBCMO_DEFAULT_COPY_MOVE(StackItem);
YYCC_DEF_CLS_COPY_MOVE(StackItem);
std::string m_Name;
std::string m_Desc;
};
@ -66,7 +66,7 @@ namespace Unvirt::CmdHelper {
struct ResultItem {
ResultItem() : m_CmdDesc(), m_ArgDesc() {}
ResultItem(const std::string& desc) : m_CmdDesc(desc), m_ArgDesc() {}
LIBCMO_DEFAULT_COPY_MOVE(ResultItem);
YYCC_DEF_CLS_COPY_MOVE(ResultItem);
std::string m_CmdDesc;
std::vector<StackItem> m_ArgDesc;
};
@ -82,7 +82,7 @@ namespace Unvirt::CmdHelper {
public:
AbstractNode();
virtual ~AbstractNode();
LIBCMO_DISABLE_COPY_MOVE(AbstractNode);
YYCC_DEL_CLS_COPY_MOVE(AbstractNode);
AbstractNode* Then(AbstractNode*);
AbstractNode* Executes(ExecutionFct, const char* = nullptr);
@ -110,7 +110,7 @@ namespace Unvirt::CmdHelper {
public:
CommandRoot();
virtual ~CommandRoot();
LIBCMO_DISABLE_COPY_MOVE(CommandRoot);
YYCC_DEL_CLS_COPY_MOVE(CommandRoot);
// Root use special consume and help functions.
bool RootConsume(std::deque<std::string>&);
@ -131,7 +131,7 @@ namespace Unvirt::CmdHelper {
public:
Literal(const char* words);
virtual ~Literal();
LIBCMO_DISABLE_COPY_MOVE(Literal);
YYCC_DEL_CLS_COPY_MOVE(Literal);
public:
virtual NodeType GetNodeType() override;
@ -151,7 +151,7 @@ namespace Unvirt::CmdHelper {
using vType = size_t;
Choice(const char* argname, const std::initializer_list<std::string>& vocabulary);
virtual ~Choice();
LIBCMO_DISABLE_COPY_MOVE(Choice);
YYCC_DEL_CLS_COPY_MOVE(Choice);
vType* GetIndex();
@ -175,7 +175,7 @@ namespace Unvirt::CmdHelper {
public:
AbstractArgument(const char* argname);
virtual ~AbstractArgument();
LIBCMO_DISABLE_COPY_MOVE(AbstractArgument);
YYCC_DEL_CLS_COPY_MOVE(AbstractArgument);
template<class T>
T GetData() {
@ -208,7 +208,7 @@ namespace Unvirt::CmdHelper {
IntArgument(const char* argname, IntLimit limit = nullptr) :
AbstractArgument(argname), m_IntLimit(limit) {}
virtual ~IntArgument() {}
LIBCMO_DISABLE_COPY_MOVE(IntArgument);
YYCC_DEL_CLS_COPY_MOVE(IntArgument);
protected:
virtual bool BeginParse(const std::string&) override;
@ -223,7 +223,7 @@ namespace Unvirt::CmdHelper {
StringArgument(const char* argname) :
AbstractArgument(argname) {}
virtual ~StringArgument() {}
LIBCMO_DISABLE_COPY_MOVE(StringArgument);
YYCC_DEL_CLS_COPY_MOVE(StringArgument);
protected:
virtual bool BeginParse(const std::string&) override;
@ -236,7 +236,7 @@ namespace Unvirt::CmdHelper {
EncodingArgument(const char* argname) :
AbstractArgument(argname) {}
virtual ~EncodingArgument() {}
LIBCMO_DISABLE_COPY_MOVE(EncodingArgument);
YYCC_DEL_CLS_COPY_MOVE(EncodingArgument);
protected:
virtual bool BeginParse(const std::string&) override;
@ -247,7 +247,7 @@ namespace Unvirt::CmdHelper {
public:
ArgumentsMap() : m_Data() {}
~ArgumentsMap() {}
LIBCMO_DISABLE_COPY_MOVE(ArgumentsMap);
YYCC_DEL_CLS_COPY_MOVE(ArgumentsMap);
void Add(const std::string& k, AbstractNode* v);
void Remove(const std::string& k);

View File

@ -1,4 +1,3 @@
#include <VTUserAll.hpp>
#include "StructFormatter.hpp"
#include "AccessibleValue.hpp"
#include "TerminalHelper.hpp"

View File

@ -1,7 +1,6 @@
#pragma once
#include <VTAll.hpp>
#include <CK2/CKFile.hpp>
namespace Unvirt::StructFormatter {

View File

@ -5,7 +5,7 @@
#include <iostream>
#include <cstdio>
#if defined(LIBCMO_OS_WIN32)
#if YYCC_OS == YYCC_OS_WINDOWS
#include <Windows.h>
#include <cstdio>
#include <io.h>
@ -19,7 +19,7 @@ namespace Unvirt {
// due to shitty Windows implementations.
bool EnsureTerminalColor(void) {
#if defined(LIBCMO_OS_WIN32)
#if YYCC_OS == YYCC_OS_WINDOWS
if (_isatty(_fileno(stdout))) {
HANDLE h_output;
DWORD dw_mode;
@ -36,7 +36,7 @@ namespace Unvirt {
}
bool EnsureTerminalEncoding(void) {
#if defined(LIBCMO_OS_WIN32)
#if YYCC_OS == YYCC_OS_WINDOWS
if (!SetConsoleCP(CP_UTF8)) return false;
if (!SetConsoleOutputCP(CP_UTF8)) return false;
@ -48,7 +48,7 @@ namespace Unvirt {
void GetCmdLine(std::string& u8cmd) {
fputs(UNVIRT_TERMCOL_LIGHT_GREEN(("Unvirt> ")), stdout);
#if defined(LIBCMO_OS_WIN32)
#if YYCC_OS == YYCC_OS_WINDOWS
std::wstring wcmd;
std::getline(std::wcin, wcmd);
LibCmo::EncodingHelper::WcharToChar(wcmd, u8cmd, CP_UTF8);

View File

@ -1,11 +1,11 @@
#pragma once
#include <VTAll.hpp>
#include "AccessibleValue.hpp"
#include "TerminalHelper.hpp"
#include "StructFormatter.hpp"
#include "CmdHelper.hpp"
#include <VTUserAll.hpp>
#include <cstdio>
#include <iostream>
@ -15,7 +15,7 @@ namespace Unvirt::Context {
public:
UnvirtContext();
~UnvirtContext();
LIBCMO_DISABLE_COPY_MOVE(UnvirtContext);
YYCC_DEL_CLS_COPY_MOVE(UnvirtContext);
void Run();