From 4ab7d84597be8dfd50c0b3bbcb0fa53448517411 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 26 Feb 2026 22:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E7=89=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-format | 20 ++ .clangd | 12 + .gitignore | 43 +++ .gitmodules | 3 + .vscode/qt5.natvis | 814 ++++++++++++++++++++++++++++++++++++++++++ .vscode/qt6.natvis | 735 ++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 144 ++++++++ CMakeLists.txt | 28 ++ REAdME.md | 3 + exec_cmd.cpp | 73 ++++ exec_cmd.h | 16 + main.cpp | 130 +++++++ read_config.cpp | 117 ++++++ read_config.h | 36 ++ thirdparty | 1 + 15 files changed, 2175 insertions(+) create mode 100644 .clang-format create mode 100644 .clangd create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 .vscode/qt5.natvis create mode 100644 .vscode/qt6.natvis create mode 100644 .vscode/settings.json create mode 100644 CMakeLists.txt create mode 100644 REAdME.md create mode 100644 exec_cmd.cpp create mode 100644 exec_cmd.h create mode 100644 main.cpp create mode 100644 read_config.cpp create mode 100644 read_config.h create mode 160000 thirdparty diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8d63d3f --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +PointerAlignment: Left +AccessModifierOffset: -4 +ReflowComments: true +SpacesBeforeTrailingComments: 3 +AllowShortFunctionsOnASingleLine: None +AllowShortEnumsOnASingleLine: false +BreakBeforeBraces: Custom +BraceWrapping: + AfterFunction: true + AfterClass: true +TabWidth: 4 +ColumnLimit: 130 +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^<.*>' + Priority: 1 + - Regex: '^".*"' + Priority: 2 diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..40557fb --- /dev/null +++ b/.clangd @@ -0,0 +1,12 @@ +Hover: + ShowAKA: Yes +Diagnostics: + UnusedIncludes: None # 禁用未使用头文件提示 + Suppress: [ + anon_type_definition, # 禁用匿名的typedef提示 + unused-variable, # 禁用未使用变量提示 + unused-function, # 禁用未使用函数提示 + unused-includes, + ] + ClangTidy: + Remove: misc-unused-alias-decls diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4250129 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Prerequisites +*.d +.qtcreator +# Compiled Object files +*.slo +*.lo +*.o +*.obj +out + +# Precompiled Headers +*.gch +*.pch + + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app +build +cmake-* +.idea +.vs +.cache +xpbuild +.xmake +compile_commands.json +build* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2c1b00b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "thirdparty"] + path = thirdparty + url = https://www.sinxmiao.cn/taynpg/ofen diff --git a/.vscode/qt5.natvis b/.vscode/qt5.natvis new file mode 100644 index 0000000..7d18567 --- /dev/null +++ b/.vscode/qt5.natvis @@ -0,0 +1,814 @@ + + + + + + + {{{data1,Xb}-{data2,Xb}-{data3,Xb}-{(data4[0]),nvoXb}{(data4[1]),nvoXb}-{(data4[2]),nvoXb}{(data4[3]),nvoXb}{(data4[4]),nvoXb}{(data4[5]),nvoXb}{(data4[6]),nvoXb}{(data4[7]),nvoXb}}} + + + + + {{ x = {xp}, y = {yp} }} + + xp + yp + + + + + {{ x = {x1}, y = {y1}, width = {x2 - x1 + 1}, height = {y2 - y1 + 1} }} + + x1 + y1 + x2 - x1 + 1 + y2 - y1 + 1 + + + + + {{ x = {xp}, y = {yp}, width = {w}, height = {h} }} + + xp + yp + w + h + + + + + + {{ width = {wd}, height = {ht} }} + + wd + ht + + + + + + {{ start point = {pt1}, end point = {pt2} }} + + + {pt1} + + pt1 + + + + {pt2} + + pt2 + + + + + + + + {{ size = {d->size} }} + + d->ref.atomic._q_value + + d->size + (QPoint*)((reinterpret_cast<char*>(d)) + d->offset) + + + + + + {{ size = {d->size} }} + + + d->size > 0 + && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).xp + == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).xp) + && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).yp + == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).yp) + + d->ref.atomic._q_value + + d->size + (QPointF*)((reinterpret_cast<char*>(d)) + d->offset) + + + + + + {{ x = {xp}, y = {yp} }} + + xp + yp + + + + + {{ x = {xp}, y = {yp}, z = {zp} }} + + xp + yp + zp + + + + + {{ x = {xp}, y = {yp}, z = {zp}, w = {wp} }} + + xp + yp + zp + wp + + + + + + {{ m11 = {_m11}, m12 = {_m12}, m21 = {_m21}, m22 = {_m22}, ... }} + + + _m11 + _m12 + _m21 + _m22 + _dx + _dy + + + + + + {{ m11 = {m[0][0]}, m12 = {m[1][0]}, m13 = {m[2][0]}, m14 = {m[3][0]}, ... }} + + + m[0][0] + m[1][0] + m[2][0] + m[3][0] + m[0][1] + m[1][1] + m[2][1] + m[3][1] + m[0][2] + m[1][2] + m[2][2] + m[3][2] + m[0][3] + m[1][3] + m[2][3] + m[3][3] + + + + + + {{ horizontal = {static_cast<Policy>(bits.horPolicy)}, vertical = {static_cast<Policy>(bits.verPolicy)}, type = {ControlType(1 << bits.ctype)} }} + + + + QSizePolicy::Policy::{static_cast<Policy>(bits.verPolicy)} + + + QSizePolicy::Policy::{static_cast<Policy>(bits.horPolicy)} + + + QSizePolicy::ControlType::{ControlType(1 << bits.ctype)} + + + + Qt::Vertical (2) + + + Qt::Horizontal (1) + + + static_cast<int>(bits.verStretch) + static_cast<int>(bits.horStretch) + bits.hfw == 1 + bits.wfh == 1 + + + + + {ucs,c} + ucs,c + + ucs > 0xff ? '\0' : char(ucs),c + ucs,c + + + + + {((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),sub} + ((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),sub + + d->size + d->ref.atomic._q_value + + d->size + ((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),c + + + + + + + {m_string,[m_size]} u"" + {offset() + m_position,[m_size]} + + m_position + m_size + + m_size + offset()+m_position + + + + + + {m_data,[m_size]} + m_data,[m_size] + + m_size + + m_size + m_data + + + + + + {((reinterpret_cast<char*>(d)) + d->offset),sb} + ((reinterpret_cast<char*>(d)) + d->offset),sb + + d->size + d->ref.atomic._q_value + + d->size + ((reinterpret_cast<char*>(d)) + d->offset),c + + + + + + + + + + + + + + + + + + + + {scheme()}://{host()}{path()} + {path()} + + scheme() + username() + password() + host() + path() + query() + fragment() + + + + + {{ size = {(d.d->size << 3) - *((reinterpret_cast<char*>(d.d)) + d.d->offset)} }} + + d.d->ref.atomic._q_value + + (d.d->size << 3) - *((reinterpret_cast<char*>(d.d)) + d.d->offset) + + (*(reinterpret_cast<const unsigned char*>((reinterpret_cast<char*>(d.d)) + d.d->offset) + 1 + + ($i >> 3)) & (1 << ($i & 7))) != 0 + + + + + + + + {{ size = {s} }} + + a + + s + ptr + + + + + + {{ julian day = {jd} }} + + + + + {{ millisecond = {mds} }} + {{ milliseconds = {mds} }} + + mds / 3600000, d + mds / 3600000, d + (mds % 3600000) / 60000, d + (mds % 3600000) / 60000, d + (mds / 1000) % 60, d + (mds / 1000) % 60, d + mds % 1000, d + mds % 1000, d + + + + + {d.pattern} + + + + + ref._q_value + + + + + strong reference to shared pointer of type {"$T1"} + + value == 0 + d->weakref._q_value + d->strongref._q_value + + + + + pointer to implicit shared object of type {"$T1"} + + d + + + + + pointer to explicit shared object of type {"$T1"} + + d + + + + + guarded pointer to subclass of QObject of type {"$T1"} + + wp.d == 0 || wp.d->strongref._q_value == 0 || wp.value == 0 + + + + + weak reference to shared pointer of type {"$T1"} + + d == 0 || d->strongref._q_value == 0 || value == 0 + d->weakref._q_value + d->strongref._q_value + + + + + scoped pointer to a dynamically allocated object of type {"$T1"} + + !d + + + + + scoped pointer to dynamically allocated array of objects of type {"$T1"} + + !d + + + + + ({first}, {second}) + + first + second + + + + + + {{ size = {d->size} }} + + d->ref.atomic._q_value + + d->size + ($T1*)((reinterpret_cast<char*>(d)) + d->offset) + + + + + + + {{ size = {d->end - d->begin} }} + + d->ref.atomic._q_value + + d->end - d->begin + *reinterpret_cast<$T1*>((sizeof($T1) > sizeof(void*)) + ? reinterpret_cast<Node*>(d->array + d->begin + $i)->v + : reinterpret_cast<$T1*>(d->array + d->begin + $i)) + + + + + + + {{ size = {d->end - d->begin} }} + + d->ref.atomic._q_value + + d->end - d->begin + + *reinterpret_cast<QString*>((sizeof(QString) > sizeof(void*)) + ? reinterpret_cast<Node*>(d->array + d->begin + $i)->v + : reinterpret_cast<QString*>(d->array + d->begin + $i)) + + + + + + + {{ size = {d->end - d->begin} }} + + d->ref.atomic._q_value + + d->end - d->begin + + *reinterpret_cast<QVariant*>((sizeof(QVariant) > sizeof(void*)) + ? reinterpret_cast<Node*>(d->array + d->begin + $i)->v + : reinterpret_cast<QVariant*>(d->array + d->begin + $i)) + + + + + + + {{ size = {d->size} }} + + d->ref.atomic._q_value + + d->size + d->n + n + (*(QLinkedListNode<$T1>*)this).t + + + + + + ({key}, {value}) + + key + value + + + + + + {{ size = {d->size} }} + + d->ref.atomic._q_value + + d->size + d->header.left + left + right + *((QMapNode<$T1,$T2>*)this) + + + + + + (empty) + ({key}, {value}) + + key + value + next + + + + + + {{ size = {d->size} }} + + + d->numBuckets + reinterpret_cast<Node **>(d->buckets) + + + + + + + d->size + + + node = *(bucket++) + --n + + + keyValuePair = reinterpret_cast<Node *>(node) + keyValuePair->value + node = node->next + + + + + + + + (empty) + ({key}) + + key + + + + + {{ size = {q_hash.d->size} }} + + q_hash + + + + + ({*keyPtr}, {*t}) + + *keyPtr + *t + + + + + {{ size = {hash.d->size} }} + + mx + total + hash.d->ref.atomic._q_value + + hash.d->size + f + n + *((Node*)this) + + + + + + + + + + + + + + {{ row count = {(*d_ptr.d).rows()}, column count = {(*d_ptr.d).columns()} }} + + d_ptr.d,! + (*d_ptr.d).rows() + (*d_ptr.d).columns() + + + + + + + Invalid + {d.data.b} + {d.data.i} + {d.data.u} + {d.data.ll} + {d.data.ull} + {d.data.d} + {d.data.c} + + {*((QMap<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QList<QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QString*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QStringList*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QByteArray*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QBitArray*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QDate*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QTime*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + DateTime + Url + Locale + + {*((QRect*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QRectF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QSize*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QSizeF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QLine*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QLineF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QPoint*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + + {*((QPointF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + RegExp + RegularExpression + + {*((QHash<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr)))} + + EasingCurve + Uuid + ModelIndex + LastCoreType + Font + Pixmap + Brush + Color + Palette + Image + Polygon + Region + Bitmap + Cursor + KeySequence + Pen + TextLength + TextFormat + Matrix + Transform + Matrix4x4 + Vector2D + Vector3D + Vector4D + Quaternion + PolygonF + Icon + LastGuiType + SizePolicy + UserType + LastType + + + + + + d.data.c + + + *((QString*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + + *((QByteArray*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + + + + + + + *((QMap<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QList<QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QString*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QStringList*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QByteArray*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QBitArray*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QDate*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QTime*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QRect*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QRectF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QSize*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QSizeF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QLine*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QLineF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QPoint*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QPointF*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + *((QHash<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr + : reinterpret_cast<const void *>(&d.data.ptr))) + + + + + + + diff --git a/.vscode/qt6.natvis b/.vscode/qt6.natvis new file mode 100644 index 0000000..94c2260 --- /dev/null +++ b/.vscode/qt6.natvis @@ -0,0 +1,735 @@ + + + + + + + {val} + + val + + + + + + + + {{ x = {x,g}, y = {y,g}, z = {_extraData().z,g}, width = {width,g}, height = {height,g} }} + {{ x = {x,g}, y = {y,g}, width = {width,g}, height = {height,g} }} + + x + y + _extraData().z + _extraData().scale + _extraData().rotation + _extraData().opacity + width + height + implicitWidth + implicitHeight + effectiveVisible + explicitEnable + _objectName(),na + parentItem + childItems, nr + + + + + {d_ptr.d,na} + + d_ptr.d + + + + + {{{data1,Xb}-{data2,Xb}-{data3,Xb}-{(data4[0]),nvoXb}{(data4[1]),nvoXb}-{(data4[2]),nvoXb}{(data4[3]),nvoXb}{(data4[4]),nvoXb}{(data4[5]),nvoXb}{(data4[6]),nvoXb}{(data4[7]),nvoXb}}} + + + + {val} + + val + + + + + {_q_value} + + _q_value + + + + + + + empty + {_q_value} + + *value() + + + + + + {{ x = {xp}, y = {yp} }} + + xp + yp + + + + + {{ x = {x1}, y = {y1}, width = {x2 - x1 + 1}, height = {y2 - y1 + 1} }} + + x1 + y1 + x2 - x1 + 1 + y2 - y1 + 1 + + + + + {{ x = {xp}, y = {yp}, width = {w}, height = {h} }} + + xp + yp + w + h + + + + + + {{ width = {wd}, height = {ht} }} + + wd + ht + + + + + + {{ start point = {pt1}, end point = {pt2} }} + + + {pt1} + + pt1 + + + + {pt2} + + pt2 + + + + + + + + {{ size={d->size} }} + + d->ref.atomic._q_value + + d->size + (QPoint*)((reinterpret_cast<char*>(d)) + d->offset) + + + + + + {{ size={d->size} }} + + + d->size > 0 + && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).xp + == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).xp) + && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).yp + == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).yp) + + d->ref.atomic._q_value + + d->size + (QPointF*)((reinterpret_cast<char*>(d)) + d->offset) + + + + + + {{ x = {xp}, y = {yp} }} + + xp + yp + + + + + {{ x = {xp}, y = {yp}, z = {zp} }} + + xp + yp + zp + + + + + {{ x = {xp}, y = {yp}, z = {zp}, w = {wp} }} + + xp + yp + zp + wp + + + + + + {{ m11 = {_m11}, m12 = {_m12}, m21 = {_m21}, m22 = {_m22}, ... }} + + + _m11 + _m12 + _m21 + _m22 + _dx + _dy + + + + + + {{ m11 = {m[0][0]}, m12 = {m[1][0]}, m13 = {m[2][0]}, m14 = {m[3][0]}, ... }} + + + m[0][0] + m[1][0] + m[2][0] + m[3][0] + m[0][1] + m[1][1] + m[2][1] + m[3][1] + m[0][2] + m[1][2] + m[2][2] + m[3][2] + m[0][3] + m[1][3] + m[2][3] + m[3][3] + + + + + + {{ horizontal = {static_cast<Policy>(bits.horPolicy)}, vertical = {static_cast<Policy>(bits.verPolicy)}, type = {ControlType(1 << bits.ctype)} }} + + + + QSizePolicy::Policy::{static_cast<Policy>(bits.verPolicy)} + + + QSizePolicy::Policy::{static_cast<Policy>(bits.horPolicy)} + + + QSizePolicy::ControlType::{ControlType(1 << bits.ctype)} + + + + Qt::Vertical (2) + + + Qt::Horizontal (1) + + + static_cast<int>(bits.verStretch) + static_cast<int>(bits.horStretch) + bits.hfw == 1 + bits.wfh == 1 + + + + + {ucs,c} + ucs,c + + ucs > 0xff ? '\0' : char(ucs),c + ucs,c + + + + + "{(reinterpret_cast<unsigned short*>(d.ptr)),sub}" + (reinterpret_cast<unsigned short*>(d.ptr)),sub + + d.size + + d.size + d.ptr + + + + + + {m_string,[m_size]} u"" + {m_string->d.ptr+m_position,[m_size]} + "" + m_string,[m_position+m_size] + + m_position + m_size + + m_size + m_string->d.ptr+m_position + + + + + + {m_data,[m_size]} + m_data,[m_size] + + m_size + + m_size + m_data + + + + + + "{((reinterpret_cast<char*>(d.ptr))),sb}" + ((reinterpret_cast<char*>(d.ptr))),sb + + d.size + + d.size + d.ptr + + + + + + + + + + + + + + + + + + + + {scheme()}://{host()}{path()} + {path()} + + scheme() + username() + password() + host() + path() + query() + fragment() + + + + + {{ julian day = {jd} }} + + + + + + + + {{ millisecond = {mds} }} + {{ milliseconds = {mds} }} + + hour(), d + hour(), d + minute(), d + minute(), d + second(), d + second(), d + millisecond(), d + millisecond(), d + + + + + ({first}, {second}) + + first + second + + + + + + {{ size={d.size} }} + + + d.size + reinterpret_cast<$T1*>(d.ptr) + + + + + + {{ size={s} }} + + a + + s + ptr + + + + + + + {{ size={d.d->m._Mypair._Myval2._Myval2._Mysize} }} + + + d.d->m._Mypair._Myval2._Myval2._Mysize + d.d->m._Mypair._Myval2._Myval2._Myhead->_Parent + _Left + _Right + _Myval,view(MapHelper) + + + + + + {second} + + + + {value} + + key + value + + + + + {value->value} + ({value->value}, {value->next->value}) + ({value->value}, {value->next->value}, ...) + + + value + next + value + + + + + + + + + + + + + + + + + + + + {{ size={d->size} }} + + + + + d->size + + + getNode(iSpan, 0) + getNode(iSpan, 1) + getNode(iSpan, 2) + getNode(iSpan, 3) + getNode(iSpan, 4) + getNode(iSpan, 5) + getNode(iSpan, 6) + getNode(iSpan, 7) + getNode(iSpan, 8) + getNode(iSpan, 9) + getNode(iSpan, 10) + getNode(iSpan, 11) + getNode(iSpan, 12) + getNode(iSpan, 13) + getNode(iSpan, 14) + getNode(iSpan, 15) + getNode(iSpan, 16) + getNode(iSpan, 17) + getNode(iSpan, 18) + getNode(iSpan, 19) + getNode(iSpan, 20) + getNode(iSpan, 21) + getNode(iSpan, 22) + getNode(iSpan, 23) + getNode(iSpan, 24) + getNode(iSpan, 25) + getNode(iSpan, 26) + getNode(iSpan, 27) + getNode(iSpan, 28) + getNode(iSpan, 29) + getNode(iSpan, 30) + getNode(iSpan, 31) + getNode(iSpan, 32) + getNode(iSpan, 33) + getNode(iSpan, 34) + getNode(iSpan, 35) + getNode(iSpan, 36) + getNode(iSpan, 37) + getNode(iSpan, 38) + getNode(iSpan, 39) + getNode(iSpan, 40) + getNode(iSpan, 41) + getNode(iSpan, 42) + getNode(iSpan, 43) + getNode(iSpan, 44) + getNode(iSpan, 45) + getNode(iSpan, 46) + getNode(iSpan, 47) + getNode(iSpan, 48) + getNode(iSpan, 49) + getNode(iSpan, 50) + getNode(iSpan, 51) + getNode(iSpan, 52) + getNode(iSpan, 53) + getNode(iSpan, 54) + getNode(iSpan, 55) + getNode(iSpan, 56) + getNode(iSpan, 57) + getNode(iSpan, 58) + getNode(iSpan, 59) + getNode(iSpan, 60) + getNode(iSpan, 61) + getNode(iSpan, 62) + getNode(iSpan, 63) + getNode(iSpan, 64) + getNode(iSpan, 65) + getNode(iSpan, 66) + getNode(iSpan, 67) + getNode(iSpan, 68) + getNode(iSpan, 69) + getNode(iSpan, 70) + getNode(iSpan, 71) + getNode(iSpan, 72) + getNode(iSpan, 73) + getNode(iSpan, 74) + getNode(iSpan, 75) + getNode(iSpan, 76) + getNode(iSpan, 77) + getNode(iSpan, 78) + getNode(iSpan, 79) + getNode(iSpan, 80) + getNode(iSpan, 81) + getNode(iSpan, 82) + getNode(iSpan, 83) + getNode(iSpan, 84) + getNode(iSpan, 85) + getNode(iSpan, 86) + getNode(iSpan, 87) + getNode(iSpan, 88) + getNode(iSpan, 89) + getNode(iSpan, 90) + getNode(iSpan, 91) + getNode(iSpan, 92) + getNode(iSpan, 93) + getNode(iSpan, 94) + getNode(iSpan, 95) + getNode(iSpan, 96) + getNode(iSpan, 97) + getNode(iSpan, 98) + getNode(iSpan, 99) + getNode(iSpan, 100) + getNode(iSpan, 101) + getNode(iSpan, 102) + getNode(iSpan, 103) + getNode(iSpan, 104) + getNode(iSpan, 105) + getNode(iSpan, 106) + getNode(iSpan, 107) + getNode(iSpan, 108) + getNode(iSpan, 109) + getNode(iSpan, 110) + getNode(iSpan, 111) + getNode(iSpan, 112) + getNode(iSpan, 113) + getNode(iSpan, 114) + getNode(iSpan, 115) + getNode(iSpan, 116) + getNode(iSpan, 117) + getNode(iSpan, 118) + getNode(iSpan, 119) + getNode(iSpan, 120) + getNode(iSpan, 121) + getNode(iSpan, 122) + getNode(iSpan, 123) + getNode(iSpan, 124) + getNode(iSpan, 125) + getNode(iSpan, 126) + getNode(iSpan, 127) + iSpan++ + + + + + + + + {{ size={q_hash.d->size} }} + + q_hash + + + + + + + + + + + + (null) + + + QObject* + + + {*(QMap<QString,QVariant>*) sharedDataStar()} + {*(QList<QVariant>*) sharedDataStar()} + {*(QHash<QString,QVariant>*) sharedDataStar()} + QVariantPair + {*(QList<QByteArray>*) sharedDataStar()} + {*(QList<QString>*) sharedDataStar()} + + + {*(bool*) dataStar()} + {*(int*) dataStar()} + {*(unsigned int*) dataStar()} + {*(long long*) dataStar()} + {*(unsigned long long*) dataStar()} + {*(double*) dataStar()} + {*(void**) dataStar()} + {*(long*) dataStar()} + {*(short*) dataStar()} + {*(char*) dataStar()} + {*(char16_t*) dataStar()} + {*(char32_t*) dataStar()} + {*(unsigned long*) dataStar()} + {*(unsigned short*) dataStar()} + {*(unsigned char*) dataStar()} + {*(float*) dataStar()} + {*(signed char*) dataStar()} + + + {*(QChar*) sharedDataStar()} + {*(QString*) sharedDataStar()} + {*(QByteArray*) sharedDataStar()} + {*(QDate*) sharedDataStar()} + {*(QTime*) sharedDataStar()} + QDateTime + QUrl + QLocale + {*(QRect*) sharedDataStar()} + {*(QRectF*) sharedDataStar()} + {*(QSize*) sharedDataStar()} + {*(QSizeF*) sharedDataStar()} + {*(QLine*) sharedDataStar()} + {*(QLineF*) sharedDataStar()} + {*(QPoint*) sharedDataStar()} + {*(QPointF*) sharedDataStar()} + EasingCurve + Uuid + RegularExpression + QJsonValue + QJsonObject + QJsonArray + QJsonDocument + QCborValue + QCborArray + QCborMap + ModelIndex + QPersistentModelIndex + + + QFont + QPixmap + QBrush + QColor + QPalette + QIcon + QImage + QPolygon + QRegion + QBitmap + QCursor + QKeySequence + QPen + QTextLength + QTextFormat + QTransform + QMatrix4x4 + QVector2D + QVector3D + QVector4D + QQuaternion + QPolygonF + QColorSpace + + + QSizePolicy + + + QMetaType::Type ({typeId()}) + + + *(QString*) sharedDataStar() + *(QByteArray*) sharedDataStar() + *(QDate*) sharedDataStar() + *(QTime*) sharedDataStar() + *(QRect*) sharedDataStar() + *(QRectF*) sharedDataStar() + *(QSize*) sharedDataStar() + *(QSizeF*) sharedDataStar() + *(QLine*) sharedDataStar() + *(QLineF*) sharedDataStar() + *(QPoint*) sharedDataStar() + *(QPointF*) sharedDataStar() + + *(QMap<QString,QVariant>*) sharedDataStar() + *(QList<QVariant>*) sharedDataStar() + *(QHash<QString,QVariant>*) sharedDataStar() + *(QList<QByteArray>*) sharedDataStar() + *(QList<QString>*) sharedDataStar() + + + + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ed421b3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,144 @@ +{ + "files.autoSave": "onFocusChange", + "editor.fontSize": 14, + "editor.fontFamily": "Consolas, 'Courier New', monospace", + "terminal.integrated.fontFamily": "Consolas", + "cmake.configureOnOpen": true, + "cmake.debugConfig": { + "console": "integratedTerminal", + "setupCommands": [ + { + "description": "-gdb-set charset utf-8", + "text": "-gdb-set charset UTF-8" + }, + { + "description": "Enable gdb pretty-printing", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "visualizerFile": "${workspaceRoot}/.vscode/qt5.natvis", + "args": [ + "-t", + "Debug", + "-r", + "D:\\A\\SimAux", + "-a", + "Clear" + ] + }, + "cmake.configureArgs": [ + "-Wno-dev" + ], + "cmake.configureSettings": { + "CMAKE_PREFIX_PATH": "C:/local/boost_1_90_0" + }, + // "cmake.environment": { + // "PATH": "${env:PATH};C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin;D:/env/ctf-win-bin/ctf/bin/Debug;R:/ctf/bin/Debug;", + // "LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:/home/taynpg/ctf-bin/ctf/bin/Debug:/home/lebo/ctf-bin/ctf/bin/Debug" + // }, + "cmake.options.statusBarVisibility": "visible", + "cmake.generator": "Ninja", + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", + "editor.inlayHints.enabled": "off", + "editor.unicodeHighlight.allowedLocales": { + "ja": true, + "zh-hant": true, + "zh-hans": true + }, + "files.associations": { + ".clang-tidy": "yaml", + "filesystem": "cpp", + "regex": "cpp", + "functional": "cpp", + "algorithm": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "coroutine": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "deque": "cpp", + "exception": "cpp", + "expected": "cpp", + "resumable": "cpp", + "format": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "queue": "cpp", + "random": "cpp", + "ratio": "cpp", + "set": "cpp", + "shared_mutex": "cpp", + "source_location": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "string": "cpp", + "system_error": "cpp", + "thread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "utility": "cpp", + "variant": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp", + "qpushbutton": "cpp", + "xmemory0": "cpp" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6cfaf37 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) + +project(cmake-vsenv LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if (MSVC) + add_compile_options(/utf-8) + add_definitions(-DWIN32_LEAN_AND_MEAN) + add_definitions(-D_WIN32_WINNT=0x0601) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/) + +add_definitions(-DFMT_HEADER_ONLY) + +set(Boost_NO_WARN_NEW_VERSIONS 1) +set(Boost_USE_STATIC_LIBS ON) +include_directories(${Boost_INCLUDE_DIR}) + +find_package(Boost COMPONENTS filesystem locale process) + +include_directories(thirdparty) +add_executable(cmake-vsenv main.cpp read_config.h read_config.cpp exec_cmd.h exec_cmd.cpp) +target_link_libraries(cmake-vsenv PRIVATE ${Boost_LIBRARIES} ntdll) diff --git a/REAdME.md b/REAdME.md new file mode 100644 index 0000000..31fa6af --- /dev/null +++ b/REAdME.md @@ -0,0 +1,3 @@ +# cmake-vsenv + +在visual studio environment中运行cmake。 \ No newline at end of file diff --git a/exec_cmd.cpp b/exec_cmd.cpp new file mode 100644 index 0000000..bdea75b --- /dev/null +++ b/exec_cmd.cpp @@ -0,0 +1,73 @@ +#include "exec_cmd.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace proc = boost::process; +namespace asio = boost::asio; +namespace fs = boost::filesystem; + +ExecCMD::ExecCMD() +{ +} + +int ExecCMD::ExecuteCmd(const std::string& exe, std::vector& args, const std::string& workDir) +{ + // std::vector args = {"/c", "call", vsBat, "&&", "set"}; + asio::io_context ctx; + try { + // + asio::readable_pipe rp{ctx}; + proc::process c{ctx, exe, args, proc::process_stdio{{}, rp, {}}, boost::process::process_start_dir(workDir)}; + + std::string line; + boost::system::error_code ec; + asio::streambuf buffer; + + while (true) { + asio::read_until(rp, buffer, '\n', ec); + if (!ec) { + std::istream is(&buffer); + std::getline(is, line); + std::cout << line << "\n"; + continue; + } + if (ec == asio::error::eof) { + std::istream is(&buffer); + std::getline(is, line); + std::cout << line << "\n"; + break; + } else { +#if defined(_WIN32) + std::cerr << boost::locale::conv::between(ec.message(), "UTF-8", "GBK") << std::endl; +#else + std::cerr << ec.message() << std::endl; +#endif + break; + } + } + c.wait(); + int exit_code = c.exit_code(); + return exit_code; + + } catch (const std::exception& e) { +#if defined(_WIN32) + std::cerr << "异常: " << boost::locale::conv::between(e.what(), "UTF-8", "GBK") << std::endl; +#else + std::cerr << e.what() << std::endl; +#endif + return 1; + } +} diff --git a/exec_cmd.h b/exec_cmd.h new file mode 100644 index 0000000..fc46d4c --- /dev/null +++ b/exec_cmd.h @@ -0,0 +1,16 @@ +#ifndef EXEC_CMD +#define EXEC_CMD + +#include +#include + +class ExecCMD +{ +public: + ExecCMD(); + +public: + static int ExecuteCmd(const std::string& exe, std::vector& args, const std::string& workDir); +}; + +#endif diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..bb7f984 --- /dev/null +++ b/main.cpp @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#include +#endif + +#include "exec_cmd.h" +#include "read_config.h" + +namespace fs = boost::filesystem; + +constexpr auto spitLinePre = "\n---------------------------------------------------"; +constexpr auto spitLine = "---------------------------------------------------"; +constexpr auto spitLineLn = "---------------------------------------------------\n"; + +int Clear(CmdInfo& info, const std::string& root, const std::string& operType) +{ + const auto& cfg = info.data[operType]; + if (cfg.size() != 1) { + std::cout << "Clear未匹配到唯一配置:" << operType << std::endl; + return 6; + } + std::cout << spitLineLn; + std::cout << "执行命令[" << operType << "]:\n"; + std::cout << spitLineLn; + const auto& ags = cfg[0]; + for (const auto& item : ags.args) { + if (item.empty()) { + continue; + } + fs::path p(root); + p.append(item); + if (fs::exists(p)) { + std::cout << "移除目录 => " << p.string() << std::endl; + fs::remove_all(p); + } + else { + std::cout << "目录不存在 => " << p.string() << std::endl; + } + } + std::cout << spitLineLn; + return 0; +} + +int ConfigBuild(CmdInfo& info, const std::string& root, const std::string& operType) +{ + auto cmdExe = boost::process::environment::find_executable("cmd"); + + std::vector args = {"/c", "call"}; + std::string vsbat = info.vsbat; + + args.push_back(vsbat); + args.emplace_back("&&"); + args.emplace_back("cmake"); + + const auto& cfg = info.data[operType]; + if (cfg.size() != 1) { + std::cout << "ConfigBuild未匹配到唯一配置:" << operType << std::endl; + return 6; + } + + const auto& ags = cfg[0]; + for (const auto& arg : ags.args) { + args.push_back(arg); + } + + std::cout << spitLineLn; + std::cout << "执行命令[" << operType << "]:\n"; + std::cout << spitLineLn; + for (int i = 4; i < args.size(); i++) { + if (i > 4 && i % 2 == 0) { + std::cout << std::endl; + } + std::cout << args[i] << " "; + } + std::cout << spitLinePre << std::endl; + return ExecCMD::ExecuteCmd(cmdExe.string(), args, root); +} + +int main(int argc, char** argv) +{ +#if defined(_WIN32) + SetConsoleOutputCP(CP_UTF8); +#endif + + CLI::App app{"cmake-vsenv构建工具。"}; + argv = app.ensure_utf8(argv); + + std::string rootDir; + app.add_option("-r, --root", rootDir, "项目根目录。"); + + std::string operType; + app.add_option("-t, --type", operType, "模式。")->required()->check(CLI::IsMember({"Debug", "Release"})); + + std::string actionName; + app.add_option("-a, --action", actionName, "动作。")->required()->check(CLI::IsMember({"Config", "Build", "Clear"})); + + CLI11_PARSE(app, argc, argv); + + fs::path p(rootDir); + p.append("cmake-vsenv.json"); + if (!fs::exists(p)) { + std::cerr << "不存在=>" << p.string() << std::endl; + return 2; + } + + auto config = std::make_shared(); + + CmdInfo info; + auto acType = config->GetType(actionName); + if (!config->Read(info, acType, p.string())) { + std::cerr << "解析配置失败=>" << p.string() << std::endl; + return 3; + } + + if (!info.data.count(operType)) { + std::cout << "获取" << operType << "配置失败。" << std::endl; + return 5; + } + + if (actionName == "Clear") { + return Clear(info, rootDir, operType); + } + return ConfigBuild(info, rootDir, operType); +} diff --git a/read_config.cpp b/read_config.cpp new file mode 100644 index 0000000..cc5cabd --- /dev/null +++ b/read_config.cpp @@ -0,0 +1,117 @@ +#include "read_config.h" + +#include +#include +#include + +using json = nlohmann::json; + +ReadConfig::ReadConfig() +{ +} + +bool ReadConfig::Read(CmdInfo& info, ActionType type, const std::string& path) +{ + try { + // 1. 读取JSON文件 + std::ifstream file(path); + if (!file.is_open()) { + std::cerr << "Error: Cannot open config file: " << path << std::endl; + return false; + } + + // 2. 解析JSON + json j; + file >> j; + + // 3. 检查必须的键 + if (!j.contains("vsbat") || !j["vsbat"].is_string()) { + std::cerr << "Error: Missing or invalid 'vsbat' field" << std::endl; + return false; + } + + // 定义固定配置键 + const std::vector requiredKeys = {"Debug", "Release"}; + + // 检查所有必须的键是否存在 + for (const auto& key : requiredKeys) { + if (!j.contains(key) || !j[key].is_array()) { + std::cerr << "Error: Missing or invalid '" << key << "' field" << std::endl; + return false; + } + } + + // 4. 清空之前的数据 + info.data.clear(); + + // 5. 读取vsbat路径 + info.vsbat = j["vsbat"].get(); + + // 6. 读取Debug和Release配置 + for (const auto& key : requiredKeys) { + std::vector cmds; + + for (const auto& cmd_item : j[key]) { + // 验证命令对象结构 + if (!cmd_item.is_object() || !cmd_item.contains("type") || !cmd_item["type"].is_string()) { + std::cerr << "Error: Invalid command object in '" << key << "'" << std::endl; + return false; + } + + std::string cmd_type_str = cmd_item["type"].get(); + if (cmd_type_str != "config" && cmd_type_str != "build" && cmd_type_str != "clear") { + std::cerr << "Error: Invalid command type '" << cmd_type_str << "' in '" << key + << "'. Must be 'config' or 'build'." << std::endl; + return false; + } + + CMakeCmd cmd; + cmd.type = GetType(cmd_type_str); + // 修改:从读取单个字符串改为读取字符串数组 + if (cmd_item.contains("args") && cmd_item["args"].is_array()) { + // 新格式:使用 args 数组 + for (const auto& arg_item : cmd_item["args"]) { + if (arg_item.is_string()) { + cmd.args.push_back(arg_item.get()); + } else { + std::cerr << "Error: Invalid argument type in 'args' array" << std::endl; + return false; + } + } + } else if (cmd_item.contains("arg") && cmd_item["arg"].is_string()) { + // 向后兼容:支持旧的单字符串格式 + cmd.args.push_back(cmd_item["arg"].get()); + } else { + std::cerr << "Error: Missing or invalid 'args' or 'arg' field in command" << std::endl; + return false; + } + + if (cmd.type == type) { + cmds.push_back(cmd); + } + } + + info.data[key] = cmds; + } + + return true; + + } catch (const json::exception& e) { + std::cerr << "JSON parsing error: " << e.what() << std::endl; + return false; + } catch (const std::exception& e) { + std::cerr << "Error reading config file: " << e.what() << std::endl; + return false; + } +} + +ActionType ReadConfig::GetType(const std::string& action) +{ + if (action == "Config" || action == "config") { + return ActionType::CT_CONFIG; + } else if (action == "Build" || action == "build") { + return ActionType::CT_BUILD; + } else { + return ActionType::CT_CLEAR; + } +} diff --git a/read_config.h b/read_config.h new file mode 100644 index 0000000..90abc2b --- /dev/null +++ b/read_config.h @@ -0,0 +1,36 @@ +#ifndef READ_CONFIG +#define READ_CONFIG + +#include +#include + +enum class ActionType { + CT_CONFIG, + CT_BUILD, + CT_CLEAR +}; + +struct CMakeCmd { + ActionType type; + std::vector args; +}; + +struct CmdInfo { + std::string vsbat; + std::unordered_map> data; +}; + +class ReadConfig +{ +public: + ReadConfig(); + +public: + bool Read(CmdInfo& info, ActionType type, const std::string& path); + ActionType GetType(const std::string& action); + +public: + std::string mainRoot_; +}; + +#endif diff --git a/thirdparty b/thirdparty new file mode 160000 index 0000000..bc92823 --- /dev/null +++ b/thirdparty @@ -0,0 +1 @@ +Subproject commit bc928233f0bc8facd6e0ea8e8bead146e5850844