can compile now
This commit is contained in:
parent
168d76939b
commit
c8f18bce0c
69
Unvirt/.editorconfig
Normal file
69
Unvirt/.editorconfig
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Visual Studio 生成了具有 C++ 设置的 .editorconfig 文件。
|
||||
root = true
|
||||
|
||||
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
|
||||
|
||||
# Visual C++ 代码样式设置
|
||||
|
||||
cpp_generate_documentation_comments = doxygen_slash_star
|
||||
|
||||
# Visual C++ 格式设置
|
||||
|
||||
cpp_indent_braces = false
|
||||
cpp_indent_multi_line_relative_to = statement_begin
|
||||
cpp_indent_within_parentheses = indent
|
||||
cpp_indent_preserve_within_parentheses = true
|
||||
cpp_indent_case_contents = true
|
||||
cpp_indent_case_labels = true
|
||||
cpp_indent_case_contents_when_block = false
|
||||
cpp_indent_lambda_braces_when_parameter = true
|
||||
cpp_indent_goto_labels = one_left
|
||||
cpp_indent_preprocessor = leftmost_column
|
||||
cpp_indent_access_specifiers = false
|
||||
cpp_indent_namespace_contents = true
|
||||
cpp_indent_preserve_comments = false
|
||||
cpp_new_line_before_open_brace_namespace = same_line
|
||||
cpp_new_line_before_open_brace_type = same_line
|
||||
cpp_new_line_before_open_brace_function = same_line
|
||||
cpp_new_line_before_open_brace_block = same_line
|
||||
cpp_new_line_before_open_brace_lambda = same_line
|
||||
cpp_new_line_scope_braces_on_separate_lines = true
|
||||
cpp_new_line_close_brace_same_line_empty_type = true
|
||||
cpp_new_line_close_brace_same_line_empty_function = true
|
||||
cpp_new_line_before_catch = false
|
||||
cpp_new_line_before_else = false
|
||||
cpp_new_line_before_while_in_do_while = false
|
||||
cpp_space_before_function_open_parenthesis = remove
|
||||
cpp_space_within_parameter_list_parentheses = false
|
||||
cpp_space_between_empty_parameter_list_parentheses = false
|
||||
cpp_space_after_keywords_in_control_flow_statements = true
|
||||
cpp_space_within_control_flow_statement_parentheses = false
|
||||
cpp_space_before_lambda_open_parenthesis = false
|
||||
cpp_space_within_cast_parentheses = false
|
||||
cpp_space_after_cast_close_parenthesis = false
|
||||
cpp_space_within_expression_parentheses = false
|
||||
cpp_space_before_block_open_brace = true
|
||||
cpp_space_between_empty_braces = false
|
||||
cpp_space_before_initializer_list_open_brace = true
|
||||
cpp_space_within_initializer_list_braces = true
|
||||
cpp_space_preserve_in_initializer_list = true
|
||||
cpp_space_before_open_square_bracket = false
|
||||
cpp_space_within_square_brackets = false
|
||||
cpp_space_before_empty_square_brackets = false
|
||||
cpp_space_between_empty_square_brackets = false
|
||||
cpp_space_group_square_brackets = true
|
||||
cpp_space_within_lambda_brackets = false
|
||||
cpp_space_between_empty_lambda_brackets = false
|
||||
cpp_space_before_comma = false
|
||||
cpp_space_after_comma = true
|
||||
cpp_space_remove_around_member_operators = true
|
||||
cpp_space_before_inheritance_colon = true
|
||||
cpp_space_before_constructor_colon = true
|
||||
cpp_space_remove_before_semicolon = true
|
||||
cpp_space_after_semicolon = true
|
||||
cpp_space_remove_around_unary_operator = true
|
||||
cpp_space_around_binary_operator = insert
|
||||
cpp_space_around_assignment_operator = insert
|
||||
cpp_space_pointer_reference_alignment = left
|
||||
cpp_space_around_ternary_operator = insert
|
||||
cpp_wrap_preserve_blocks = one_liners
|
|
@ -148,12 +148,12 @@ namespace Unvirt::CmdHelper {
|
|||
friend class Literal;
|
||||
friend class AbstractArgument;
|
||||
public:
|
||||
using vType = int32_t;
|
||||
using vType = size_t;
|
||||
Choice(const char* argname, const std::initializer_list<std::string>& vocabulary);
|
||||
virtual ~Choice();
|
||||
LIBCMO_DISABLE_COPY_MOVE(Choice);
|
||||
|
||||
size_t* GetIndex();
|
||||
vType* GetIndex();
|
||||
|
||||
public:
|
||||
virtual NodeType GetNodeType() override;
|
||||
|
@ -260,9 +260,9 @@ namespace Unvirt::CmdHelper {
|
|||
AbstractNode* node = finder->second;
|
||||
switch (node->GetNodeType()) {
|
||||
case NodeType::Argument:
|
||||
return dynamic_cast<AbstractArgument*>(node)->GetData<_Ty*>();
|
||||
return reinterpret_cast<_Ty*>(dynamic_cast<AbstractArgument*>(node)->GetData<_Ty*>());
|
||||
case NodeType::Choice:
|
||||
return dynamic_cast<Choice*>(node)->GetIndex();
|
||||
return reinterpret_cast<_Ty*>(dynamic_cast<Choice*>(node)->GetIndex());
|
||||
case NodeType::Literal:
|
||||
default:
|
||||
throw std::runtime_error("No such argument type.");
|
||||
|
|
|
@ -127,4 +127,14 @@ namespace Unvirt::StructFormatter {
|
|||
fprintf(fout, "Page %zu of %zu\n", page + 1, fullpage + 1);
|
||||
}
|
||||
|
||||
void PrintCKObject(const LibCmo::CK2::ObjImpls::CKObject*) {
|
||||
fputs(UNVIRT_TERMCOL_MAGENTA(("NO IMPLEMENTS\n")), fout);
|
||||
}
|
||||
void PrintCKBaseManager(const LibCmo::CK2::MgrImpls::CKBaseManager*) {
|
||||
fputs(UNVIRT_TERMCOL_MAGENTA(("NO IMPLEMENTS\n")), fout);
|
||||
}
|
||||
void PrintCKStateChunk(const LibCmo::CK2::CKStateChunk*) {
|
||||
fputs(UNVIRT_TERMCOL_MAGENTA(("NO IMPLEMENTS\n")), fout);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,5 +8,8 @@ namespace Unvirt::StructFormatter {
|
|||
void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo);
|
||||
void PrintObjectList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileObject>& ls, size_t page, size_t pageitems);
|
||||
void PrintManagerList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileManagerData>& ls, size_t page, size_t pageitems);
|
||||
void PrintCKObject(const LibCmo::CK2::ObjImpls::CKObject*);
|
||||
void PrintCKBaseManager(const LibCmo::CK2::MgrImpls::CKBaseManager*);
|
||||
void PrintCKStateChunk(const LibCmo::CK2::CKStateChunk*);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
//if (doc)
|
||||
// Unvirt::StructFormatter::PrintCKFileInfo(doc->m_FileInfo);
|
||||
Unvirt::UnvirtContext ctx;
|
||||
Unvirt::Context::UnvirtContext ctx;
|
||||
ctx.Run();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,55 +18,101 @@ namespace Unvirt::Context {
|
|||
// create command root
|
||||
CmdHelper::CommandRoot* root = &m_Root;
|
||||
|
||||
root->Then(
|
||||
(new CmdHelper::Literal("deepload"))
|
||||
root
|
||||
->Then((new CmdHelper::Literal("load"))
|
||||
->Then((new CmdHelper::Choice("stage", { "deep", "shallow"}))
|
||||
->Comment("The stage of loading. 'deep' will load to CKObject stage. 'shallow' will load to CKStateChunk stage.")
|
||||
->Then((new CmdHelper::StringArgument("filepath"))
|
||||
->Comment("The path to loading file.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcLoad, this, true, std::placeholders::_1),
|
||||
"Load a Virtools composition deeply. Load file to CKObject stage."
|
||||
std::bind(&UnvirtContext::ProcLoad, this, std::placeholders::_1),
|
||||
"Load a Virtools composition deeply."
|
||||
)
|
||||
)
|
||||
);
|
||||
root->Then(
|
||||
(new CmdHelper::Literal("shallowload"))->Then(
|
||||
(new CmdHelper::StringArgument("filepath", "The path to loading file."))->Executes(
|
||||
std::bind(&UnvirtContext::ProcLoad, this, false, std::placeholders::_1),
|
||||
"Load a Virtools composition shallowly. Load file to CKStateChunk stage."
|
||||
)
|
||||
)
|
||||
);
|
||||
root->Then(
|
||||
(new CmdHelper::Literal("unload"))->Executes(
|
||||
->Then((new CmdHelper::Literal("unload"))
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcUnLoad, this, std::placeholders::_1),
|
||||
"Release loaded Virtools composition."
|
||||
)
|
||||
);
|
||||
root->Then(
|
||||
(new CmdHelper::Literal("info"))->Executes(
|
||||
)
|
||||
->Then((new CmdHelper::Literal("info"))
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcInfo, this, std::placeholders::_1),
|
||||
"Show the header info of loaded Virtools composition."
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
root->Then(
|
||||
(new CmdHelper::Literal("foo"))->Then(
|
||||
(new CmdHelper::Literal("bar"))->Executes([](const CmdHelper::ArgumentsMap& amap) -> void {
|
||||
fprintf(stdout, "foobar!\n");
|
||||
}, "simple foobar")
|
||||
)->Then(
|
||||
(new CmdHelper::IntArgument("bar", "the calling target 1"))->Executes([](const CmdHelper::ArgumentsMap& amap) -> void {
|
||||
fprintf(stdout, "foo%" PRIi32 "!\n", *(amap.Get("bar")->GetData<int32_t>()));
|
||||
}, "specialized foo bar")
|
||||
)
|
||||
)->Then(
|
||||
(new CmdHelper::Literal("call"))->Then(
|
||||
(new CmdHelper::IntArgument("bar", "the calling taget 2"))->Executes([](const CmdHelper::ArgumentsMap& amap) -> void {
|
||||
fprintf(stdout, "call%" PRIi32 "!\n", *(amap.Get("bar")->GetData<int32_t>()));
|
||||
}, "calling someone")
|
||||
->Then((new CmdHelper::Literal("ls"))
|
||||
->Then((new CmdHelper::Choice("part", { "obj", "mgr"}))
|
||||
->Comment("Which list you want to list.")
|
||||
->Then((new CmdHelper::IntArgument("page", [](int32_t v) -> bool { return v > 0; }))
|
||||
->Comment("The page index. Start with 1.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcLs, this, std::placeholders::_1),
|
||||
"List something about loaded Virtools composition."
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("data"))
|
||||
->Then((new CmdHelper::Choice("part", { "obj", "mgr"}))
|
||||
->Comment("Which list you want to show data.")
|
||||
->Then((new CmdHelper::IntArgument("index", [](int32_t v) -> bool { return v >= 0; }))
|
||||
->Comment("The index. Start with 0.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcData, this, std::placeholders::_1),
|
||||
"Show the specific CKObject / CKBaseManager data."
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("chunk"))
|
||||
->Then((new CmdHelper::Choice("part", { "obj", "mgr"}))
|
||||
->Comment("Which list you want to show chunk.")
|
||||
->Then((new CmdHelper::IntArgument("index", [](int32_t v) -> bool { return v >= 0; }))
|
||||
->Comment("The index. Start with 0.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcChunk, this, std::placeholders::_1),
|
||||
"Show the specific CKStateChunk data."
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("items"))
|
||||
->Then((new CmdHelper::IntArgument("count", [](int32_t v) -> bool { return v > 0; }))
|
||||
->Comment("The count of items you want to show in one page.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcItems, this, std::placeholders::_1),
|
||||
"Set up how many items should be listed in one page when using 'ls' command."
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("encoding"))
|
||||
->Then((new CmdHelper::EncodingArgument("enc"))
|
||||
->Comment("CKContext used encoding splitted by ','. Support mutiple encoding.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcEncoding, this, std::placeholders::_1),
|
||||
"Set the encoding series for CKContext."
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("temp"))
|
||||
->Then((new CmdHelper::StringArgument("temppath"))
|
||||
->Comment("The path to Temp folder.")
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcTemp, this, std::placeholders::_1),
|
||||
"Set the Temp path for CKContext."
|
||||
)
|
||||
)
|
||||
)
|
||||
->Then((new CmdHelper::Literal("temp"))
|
||||
->Executes(
|
||||
std::bind(&UnvirtContext::ProcExit, this, std::placeholders::_1),
|
||||
"Exit program."
|
||||
)
|
||||
);
|
||||
|
||||
// create help
|
||||
m_Help = root->RootHelp();
|
||||
|
||||
|
@ -167,7 +213,7 @@ namespace Unvirt::Context {
|
|||
}
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcUnLoad(const CmdHelper::ArgumentsMap* amap) {
|
||||
void UnvirtContext::ProcUnLoad(const CmdHelper::ArgumentsMap*) {
|
||||
// check pre-requirement
|
||||
if (!HasOpenedFile()) {
|
||||
this->PrintCommonError("No loaded file.");
|
||||
|
@ -178,7 +224,7 @@ namespace Unvirt::Context {
|
|||
ClearDocument();
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcInfo(const CmdHelper::ArgumentsMap* amap) {
|
||||
void UnvirtContext::ProcInfo(const CmdHelper::ArgumentsMap*) {
|
||||
// check pre-requirement
|
||||
if (!HasOpenedFile()) {
|
||||
PrintCommonError("No loaded file.");
|
||||
|
@ -196,17 +242,12 @@ namespace Unvirt::Context {
|
|||
return;
|
||||
}
|
||||
|
||||
// check requirement
|
||||
int32_t gotten_page = *amap.Get("page")->GetData<int32_t>();
|
||||
if (gotten_page <= 0) {
|
||||
PrintCommonError("Page out of range.");
|
||||
return;
|
||||
}
|
||||
size_t page = static_cast<size_t>(gotten_page) - 1;
|
||||
// get page
|
||||
size_t page = *amap->Get<CmdHelper::IntArgument::vType>("page") - 1;
|
||||
|
||||
// show list
|
||||
switch (parts) {
|
||||
case ViewPart::Objects:
|
||||
switch (*amap->Get<CmdHelper::Choice::vType>("part")) {
|
||||
case 0:
|
||||
{
|
||||
// obj list
|
||||
if (page * m_PageLen >= m_FileReader->GetFileObjects().size()) {
|
||||
|
@ -217,7 +258,7 @@ namespace Unvirt::Context {
|
|||
Unvirt::StructFormatter::PrintObjectList(m_FileReader->GetFileObjects(), page, this->m_PageLen);
|
||||
break;
|
||||
}
|
||||
case ViewPart::Managers:
|
||||
case 1:
|
||||
{
|
||||
// mgr list
|
||||
if (page * m_PageLen >= m_FileReader->GetManagersData().size()) {
|
||||
|
@ -232,38 +273,87 @@ namespace Unvirt::Context {
|
|||
}
|
||||
|
||||
void UnvirtContext::ProcData( const CmdHelper::ArgumentsMap* amap) {
|
||||
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcChunk(const CmdHelper::ArgumentsMap* amap) {
|
||||
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcItems(const CmdHelper::ArgumentsMap* amap) {
|
||||
// check requirement
|
||||
int32_t count = *amap.Get("count")->GetData<int32_t>();
|
||||
if (count <= 0) {
|
||||
PrintCommonError("Value out of range.");
|
||||
// check pre-requirement
|
||||
if (!HasOpenedFile()) {
|
||||
this->PrintCommonError("No loaded file.");
|
||||
return;
|
||||
}
|
||||
|
||||
// get index
|
||||
size_t index = *amap->Get<CmdHelper::IntArgument::vType>("index");
|
||||
|
||||
// show data
|
||||
switch (*amap->Get<CmdHelper::Choice::vType>("part")) {
|
||||
case 0:
|
||||
{
|
||||
if (index >= m_FileReader->GetFileObjects().size()) {
|
||||
PrintCommonError("Index out of range.");
|
||||
return;
|
||||
}
|
||||
Unvirt::StructFormatter::PrintCKObject(m_FileReader->GetFileObjects()[index].ObjPtr);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (index >= m_FileReader->GetManagersData().size()) {
|
||||
PrintCommonError("Index out of range.");
|
||||
return;
|
||||
}
|
||||
//Unvirt::StructFormatter::PrintCKBaseManager(m_FileReader->GetManagersData()[index].Data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcChunk(const CmdHelper::ArgumentsMap* amap) {
|
||||
// check pre-requirement
|
||||
if (!HasOpenedFile()) {
|
||||
this->PrintCommonError("No loaded file.");
|
||||
return;
|
||||
}
|
||||
|
||||
// get index
|
||||
size_t index = *amap->Get<CmdHelper::IntArgument::vType>("index");
|
||||
|
||||
// show data
|
||||
switch (*amap->Get<CmdHelper::Choice::vType>("part")) {
|
||||
case 0:
|
||||
{
|
||||
if (index >= m_FileReader->GetFileObjects().size()) {
|
||||
PrintCommonError("Index out of range.");
|
||||
return;
|
||||
}
|
||||
Unvirt::StructFormatter::PrintCKStateChunk(m_FileReader->GetFileObjects()[index].Data);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (index >= m_FileReader->GetManagersData().size()) {
|
||||
PrintCommonError("Index out of range.");
|
||||
return;
|
||||
}
|
||||
Unvirt::StructFormatter::PrintCKStateChunk(m_FileReader->GetManagersData()[index].Data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcItems(const CmdHelper::ArgumentsMap* amap) {
|
||||
// assign
|
||||
m_PageLen = static_cast<size_t>(count);
|
||||
m_PageLen = *amap->Get<CmdHelper::IntArgument::vType>("count");
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcEncoding(const CmdHelper::ArgumentsMap* amap) {
|
||||
|
||||
const auto& encodings = *amap->Get<CmdHelper::EncodingArgument::vType>("enc");
|
||||
m_Ctx->SetEncoding(encodings);
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcTemp(const CmdHelper::ArgumentsMap* amap) {
|
||||
// check requirement
|
||||
std::string temppath = *amap.Get("temppath")->GetData<std::string>();
|
||||
|
||||
// assign
|
||||
m_Ctx->SetTempPath(temppath.c_str());
|
||||
m_Ctx->SetTempPath(amap->Get<CmdHelper::StringArgument::vType>("temppath")->c_str());
|
||||
}
|
||||
|
||||
void UnvirtContext::ProcExit(const CmdHelper::ArgumentsMap* amap) {
|
||||
void UnvirtContext::ProcExit(const CmdHelper::ArgumentsMap*) {
|
||||
m_OrderExit = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user