update:导入数据功能进度更新(未完成)。

This commit is contained in:
2024-05-19 00:48:03 +08:00
parent a89ef1e677
commit 2bc368c781
7 changed files with 103 additions and 27 deletions

View File

@@ -101,6 +101,61 @@ Element_t* CXmlOpr::copy_element(Element_t* ele)
return ret;
}
bool CXmlOpr::check_valid_xml_data(const std::string& data)
{
tinyxml2::XMLDocument doc;
doc.Parse(data.c_str());
if (doc.Error()) {
return false;
}
return true;
}
bool CXmlOpr::check_same_struct(const std::string& data)
{
auto* own_ele = parent_node_->FirstChildElement(opr_base_.the_node.c_str());
if (own_ele == nullptr) {
return true;
}
tinyxml2::XMLDocument doc;
doc.Parse(data.c_str());
if (doc.Error()) {
return false;
}
const auto* import_ele = doc.FirstChildElement(opr_base_.the_node.c_str());
if (import_ele == nullptr) {
return false;
}
const auto* attribute = own_ele->FirstAttribute();
int own_cnt = 0;
while (attribute) {
++own_cnt;
if (import_ele->FindAttribute(attribute->Name()) == nullptr) {
return true;
}
attribute = attribute->Next();
}
const auto* attr_import = import_ele->FirstAttribute();
int import_cnt = 0;
while (attr_import) {
++import_cnt;
attr_import = attr_import->Next();
}
if (import_cnt != own_cnt) {
return false;
}
return true;
}
bool CXmlOpr::import_newer_data(const std::vector<std::string>& vec)
{
return false;
}
void CXmlOpr::del_element(Element_t* ele)
{
parent_node_->DeleteChild(ele);