Merge branch 'pugixml_extra' of https://github.com/Arcnor/FlaxEngine into Arcnor-pugixml_extra
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
#include "Editor/ProjectInfo.h"
|
||||
#include "Editor/Cooker/GameCooker.h"
|
||||
#include "Editor/Utilities/EditorUtilities.h"
|
||||
#include <ThirdParty/pugixml/pugixml.hpp>
|
||||
|
||||
#include "pugixml/pugixml_extra.hpp"
|
||||
|
||||
using namespace pugi;
|
||||
|
||||
IMPLEMENT_SETTINGS_GETTER(MacPlatformSettings, MacPlatform);
|
||||
@@ -170,17 +172,17 @@ bool MacPlatformTools::OnPostProcess(CookingData& data)
|
||||
const String plistPath = data.DataOutputPath / TEXT("Info.plist");
|
||||
{
|
||||
xml_document doc;
|
||||
xml_node plist = doc.child_or_append(PUGIXML_TEXT("plist"));
|
||||
xml_node_extra plist = xml_node_extra(doc).child_or_append(PUGIXML_TEXT("plist"));
|
||||
plist.append_attribute(PUGIXML_TEXT("version")).set_value(PUGIXML_TEXT("1.0"));
|
||||
xml_node dict = plist.child_or_append(PUGIXML_TEXT("dict"));
|
||||
xml_node_extra dict = plist.child_or_append(PUGIXML_TEXT("dict"));
|
||||
|
||||
#define ADD_ENTRY(key, value) \
|
||||
dict.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT(key)); \
|
||||
dict.append_child(PUGIXML_TEXT("string")).set_child_value(PUGIXML_TEXT(value))
|
||||
dict.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT(key)); \
|
||||
dict.append_child_with_value(PUGIXML_TEXT("string"), PUGIXML_TEXT(value))
|
||||
#define ADD_ENTRY_STR(key, value) \
|
||||
dict.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT(key)); \
|
||||
dict.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT(key)); \
|
||||
{ std::u16string valueStr(value.GetText()); \
|
||||
dict.append_child(PUGIXML_TEXT("string")).set_child_value(pugi::string_t(valueStr.begin(), valueStr.end()).c_str()); }
|
||||
dict.append_child_with_value(PUGIXML_TEXT("string"), pugi::string_t(valueStr.begin(), valueStr.end()).c_str()); }
|
||||
|
||||
ADD_ENTRY("CFBundleDevelopmentRegion", "English");
|
||||
ADD_ENTRY("CFBundlePackageType", "APPL");
|
||||
@@ -194,22 +196,22 @@ bool MacPlatformTools::OnPostProcess(CookingData& data)
|
||||
ADD_ENTRY_STR("CFBundleVersion", projectVersion);
|
||||
ADD_ENTRY_STR("NSHumanReadableCopyright", gameSettings->CopyrightNotice);
|
||||
|
||||
dict.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT("CFBundleSupportedPlatforms"));
|
||||
xml_node CFBundleSupportedPlatforms = dict.append_child(PUGIXML_TEXT("array"));
|
||||
CFBundleSupportedPlatforms.append_child(PUGIXML_TEXT("string")).set_child_value(PUGIXML_TEXT("MacOSX"));
|
||||
dict.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT("CFBundleSupportedPlatforms"));
|
||||
xml_node_extra CFBundleSupportedPlatforms = dict.append_child(PUGIXML_TEXT("array"));
|
||||
CFBundleSupportedPlatforms.append_child_with_value(PUGIXML_TEXT("string"), PUGIXML_TEXT("MacOSX"));
|
||||
|
||||
dict.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT("LSMinimumSystemVersionByArchitecture"));
|
||||
xml_node LSMinimumSystemVersionByArchitecture = dict.append_child(PUGIXML_TEXT("dict"));
|
||||
dict.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT("LSMinimumSystemVersionByArchitecture"));
|
||||
xml_node_extra LSMinimumSystemVersionByArchitecture = dict.append_child(PUGIXML_TEXT("dict"));
|
||||
switch (_arch)
|
||||
{
|
||||
case ArchitectureType::x64:
|
||||
LSMinimumSystemVersionByArchitecture.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT("x86_64"));
|
||||
LSMinimumSystemVersionByArchitecture.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT("x86_64"));
|
||||
break;
|
||||
case ArchitectureType::ARM64:
|
||||
LSMinimumSystemVersionByArchitecture.append_child(PUGIXML_TEXT("key")).set_child_value(PUGIXML_TEXT("arm64"));
|
||||
LSMinimumSystemVersionByArchitecture.append_child_with_value(PUGIXML_TEXT("key"), PUGIXML_TEXT("arm64"));
|
||||
break;
|
||||
}
|
||||
LSMinimumSystemVersionByArchitecture.append_child(PUGIXML_TEXT("string")).set_child_value(PUGIXML_TEXT("10.15"));
|
||||
LSMinimumSystemVersionByArchitecture.append_child_with_value(PUGIXML_TEXT("string"), PUGIXML_TEXT("10.15"));
|
||||
|
||||
#undef ADD_ENTRY
|
||||
#undef ADD_ENTRY_STR
|
||||
|
||||
21
Source/ThirdParty/pugixml/pugixml.cpp
vendored
21
Source/ThirdParty/pugixml/pugixml.cpp
vendored
@@ -4799,16 +4799,6 @@ namespace pugi
|
||||
return xml_node();
|
||||
}
|
||||
|
||||
PUGI__FN xml_node xml_node::child_or_append(const char_t* name_)
|
||||
{
|
||||
if (!_root) return xml_node();
|
||||
|
||||
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
|
||||
if (i->name && impl::strequal(name_, i->name)) return xml_node(i);
|
||||
|
||||
return append_child(name_);
|
||||
}
|
||||
|
||||
PUGI__FN xml_attribute xml_node::attribute(const char_t* name_) const
|
||||
{
|
||||
if (!_root) return xml_attribute();
|
||||
@@ -4879,17 +4869,6 @@ namespace pugi
|
||||
return PUGIXML_TEXT("");
|
||||
}
|
||||
|
||||
PUGI__FN bool xml_node::set_child_value(const char_t* rhs)
|
||||
{
|
||||
if (!_root) return false;
|
||||
|
||||
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
|
||||
if (i->value && impl::is_text_node(i))
|
||||
return xml_node(i).set_value(rhs);
|
||||
|
||||
return append_child(node_pcdata).set_value(rhs);
|
||||
}
|
||||
|
||||
PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const
|
||||
{
|
||||
return child(name_).child_value();
|
||||
|
||||
2
Source/ThirdParty/pugixml/pugixml.hpp
vendored
2
Source/ThirdParty/pugixml/pugixml.hpp
vendored
@@ -452,14 +452,12 @@ namespace pugi
|
||||
|
||||
// Get child, attribute or next/previous sibling with the specified name
|
||||
xml_node child(const char_t* name) const;
|
||||
xml_node child_or_append(const char_t* name);
|
||||
xml_attribute attribute(const char_t* name) const;
|
||||
xml_node next_sibling(const char_t* name) const;
|
||||
xml_node previous_sibling(const char_t* name) const;
|
||||
|
||||
// Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
|
||||
const char_t* child_value() const;
|
||||
bool set_child_value(const char_t* rhs);
|
||||
|
||||
// Get child value of child with specified name. Equivalent to child(name).child_value().
|
||||
const char_t* child_value(const char_t* name) const;
|
||||
|
||||
63
Source/ThirdParty/pugixml/pugixml_extra.cpp
vendored
Normal file
63
Source/ThirdParty/pugixml/pugixml_extra.cpp
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "pugixml.hpp"
|
||||
#include "pugixml_extra.hpp"
|
||||
|
||||
namespace pugi
|
||||
{
|
||||
|
||||
// Compare two strings
|
||||
// This comes from pugi::impl::strequal
|
||||
bool strequal(const char_t* src, const char_t* dst)
|
||||
{
|
||||
#ifdef PUGIXML_WCHAR_MODE
|
||||
return wcscmp(src, dst) == 0;
|
||||
#else
|
||||
return strcmp(src, dst) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// This comes from pugi::impl::is_text_node
|
||||
inline bool is_text_node(const xml_node& node)
|
||||
{
|
||||
xml_node_type type = node.type();
|
||||
|
||||
return type == node_pcdata || type == node_cdata;
|
||||
}
|
||||
|
||||
xml_node_extra::xml_node_extra(xml_node child) : xml_node(child)
|
||||
{
|
||||
}
|
||||
|
||||
xml_node_extra xml_node_extra::child_or_append(const char_t* name_)
|
||||
{
|
||||
if (!name_ || !_root) return xml_node_extra();
|
||||
|
||||
for (xml_node& child : *this)
|
||||
{
|
||||
const auto *name = child.name();
|
||||
if (name && strequal(name_, name)) return xml_node_extra(child);
|
||||
}
|
||||
|
||||
return xml_node_extra(append_child(name_));
|
||||
}
|
||||
|
||||
bool xml_node_extra::set_child_value(const char_t* rhs)
|
||||
{
|
||||
if (!_root) return xml_node();
|
||||
|
||||
for (xml_node& child : *this)
|
||||
{
|
||||
if (child.value() && is_text_node(child))
|
||||
{
|
||||
return child.set_value(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
return append_child(node_pcdata).set_value(rhs);
|
||||
}
|
||||
|
||||
void xml_node_extra::append_child_with_value(const char_t* name_, const char_t* rhs)
|
||||
{
|
||||
xml_node_extra child = xml_node_extra(append_child(name_));
|
||||
child.append_child(node_pcdata).set_value(rhs);
|
||||
}
|
||||
}
|
||||
18
Source/ThirdParty/pugixml/pugixml_extra.hpp
vendored
Normal file
18
Source/ThirdParty/pugixml/pugixml_extra.hpp
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
namespace pugi
|
||||
{
|
||||
class xml_node_extra : public xml_node
|
||||
{
|
||||
public:
|
||||
xml_node_extra() = default;
|
||||
xml_node_extra(xml_node child);
|
||||
|
||||
xml_node_extra child_or_append(const char_t* name_);
|
||||
bool set_child_value(const char_t* rhs);
|
||||
void append_child_with_value(const char_t* name_, const char_t* rhs);
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user