x2t builds (not complete)

This commit is contained in:
Oleg Korshul
2018-04-18 12:42:54 +03:00
parent 8d750adb7b
commit 2682eda9c6
214 changed files with 1457 additions and 1437 deletions

View File

@ -33,6 +33,7 @@
#define _BUILD_XMLUTILS_CROSSPLATFORM_H_
#include <vector>
#include <list>
#include <map>
#include <string>
@ -136,6 +137,7 @@ namespace XmlUtils
public:
CXmlNodes();
~CXmlNodes();
bool IsValid();
int GetCount();
bool GetAt(int nIndex, CXmlNode& oXmlNode);
@ -174,6 +176,10 @@ namespace XmlUtils
std::wstring ReadAttribute(const std::wstring& strAttibuteName);
int GetAttributesCount();
void GetAllAttributes(std::vector<std::wstring>& names, std::vector<std::wstring>& values);
void GetAllAttributes(std::vector<std::string>& names, std::vector<std::string>& values);
void GetAllAttributes(std::list<std::wstring>& names, std::list<std::wstring>& values);
void GetAllAttributes(std::list<std::string>& names, std::list<std::string>& values);
std::string GetAttributeA(const std::string& sName, const std::string& _default = "");
std::string GetAttributeA(const std::wstring& sName, const std::string& _default = "");
@ -218,26 +224,12 @@ namespace XmlUtils
CXmlNode& operator=(const CXmlNode& oSrc);
public:
public:
std::wstring private_GetXml();
std::wstring private_GetXml(const std::wstring& strDefaultValue = L"");
std::wstring private_GetXmlFast();
std::wstring private_GetXmlFast(const std::wstring& strDefaultValue);
public:
template <typename T>
void LoadArray(const std::wstring& sName, std::vector<T>& arList);
template <typename T>
void LoadArray(const std::wstring& sName, const std::wstring& sSubName, std::vector<T>& arList);
template<typename T>
void ReadAttributeBase(const wchar_t* bsName, T& value);
template<typename T>
void ReadAllAttributes(T& strNames, T& strValues);
template<typename T>
void ReadAllAttributesA(T& strNames, T& strValues);
template <typename T>
void ReadNodeValueBase(const wchar_t* bsName, T& value);
private:
void SetBase(CXmlNodeBase* pBase);
std::wstring GetNamespace(const std::wstring& strNodeName);
@ -274,6 +266,38 @@ public:
std::wstring KERNEL_DECL GetNameNoNS(const std::wstring & strNodeName);
std::wstring KERNEL_DECL GetNamespace(const std::wstring& strNodeName);
#define XmlMacroLoadArray(node, name, list, type) \
{ \
XmlUtils::CXmlNodes oNodes; \
if (node.GetNodes(name, oNodes)) \
{ \
int nCount = oNodes.GetCount(); \
for (int i = 0; i < nCount; ++i) \
{ \
XmlUtils::CXmlNode oItem; \
oNodes.GetAt(i, oItem); \
list.push_back(type()); \
list[i].fromXML(oItem); \
} \
} \
}
#define XmlMacroLoadArrayS(node, name, subname, list, type) \
{ \
XmlUtils::CXmlNode oNode; \
if (node.GetNode(sName, oNode)) \
LoadArrayMacro(oNode, subname, list, type); \
}
#define XmlMacroReadAttributeBase(node, name, value) \
{ \
std::wstring sAttr; \
if (node.GetAttributeIfExist(name, sAttr)) \
value = sAttr; \
}
#define XmlMacroReadNodeValueBase(node, name, value) \
{ \
value = node.ReadNodeTextBase(name); \
}
}
#endif // _BUILD_XMLUTILS_CROSSPLATFORM_H_

View File

@ -147,6 +147,9 @@ namespace XmlUtils
CXmlNodes::CXmlNodes() : m_nodes()
{
}
CXmlNodes::~CXmlNodes()
{
}
bool CXmlNodes::IsValid()
{
return true;
@ -490,6 +493,38 @@ namespace XmlUtils
else
return 0;
}
void CXmlNode::GetAllAttributes(std::vector<std::wstring>& names, std::vector<std::wstring>& values)
{
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
names.push_back(UTF8_TO_U(p->first));
values.push_back(UTF8_TO_U(p->second));
}
}
void CXmlNode::GetAllAttributes(std::vector<std::string>& names, std::vector<std::string>& values)
{
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
names.push_back(p->first);
values.push_back(p->second);
}
}
void CXmlNode::GetAllAttributes(std::list<std::wstring>& names, std::list<std::wstring>& values)
{
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
names.push_back(UTF8_TO_U(p->first));
values.push_back(UTF8_TO_U(p->second));
}
}
void CXmlNode::GetAllAttributes(std::list<std::string>& names, std::list<std::string>& values)
{
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
names.push_back(p->first);
values.push_back(p->second);
}
}
bool CXmlNode::GetAttributeIfExist(const std::wstring& sName, std::wstring& sOutput)
{
bool bRes = false;
@ -795,70 +830,7 @@ namespace XmlUtils
NSStringUtils::CStringBuilder oWriter;
m_pBase->GetXml(oWriter);
return oWriter.GetData();
}
template <typename T>
void CXmlNode::LoadArray(const std::wstring& sName, std::vector<T>& arList)
{
CXmlNodes oNodes;
if (GetNodes(sName, oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
CXmlNode oItem;
oNodes.GetAt(i, oItem);
arList.push_back(T());
arList[i].fromXML(oItem);
}
}
}
template <typename T>
void CXmlNode::LoadArray(const std::wstring& sName, const std::wstring& sSubName, std::vector<T>& arList)
{
CXmlNode oNode;
if (GetNode(sName, oNode))
oNode.LoadArray(sSubName, arList);
}
template<typename T>
void CXmlNode::ReadAttributeBase(const wchar_t* bsName, T& value)
{
std::wstring sAttr;
if (GetAttributeIfExist(bsName, sAttr))
value = sAttr;
}
template<typename T>
void CXmlNode::ReadAllAttributes(T& strNames, T& strValues)
{
if (!IsValid())
return;
std::map<std::string, std::string>::iterator p;
for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
strNames.push_back (NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->first.c_str(), (long)p->first.length()));
strValues.push_back (NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->second.c_str(), (long)p->second.length()));
}
}
template<typename T>
void CXmlNode::ReadAllAttributesA(T& strNames, T& strValues)
{
if (!IsValid())
return;
std::map<std::string, std::string>::iterator p;
for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{
strNames.push_back(p->first);
strValues.push_back(p->second);
}
}
template <typename T>
void CXmlNode::ReadNodeValueBase(const wchar_t* bsName, T& value)
{
value = ReadNodeTextBase(bsName);
}
}
void CXmlNode::SetBase(CXmlNodeBase* pBase)
{