#pragma once
#include <set>
#include <map>
#include <memory>
#include <vector>
namespace pugi
{
class xml_document;
class xml_node;
}
namespace TestToolBox
{
struct IEventReceiver;
enum EventContext;
struct SettingsBase;
typedef std::shared_ptr<SettingsBase> SettingsBaseSp;
struct XmlCheckSettings;
typedef std::shared_ptr<XmlCheckSettings> XmlCheckSettingsSp;
class XmlCheck;
typedef std::shared_ptr<XmlCheck> XmlCheckSp;
namespace XmlServices
{
typedef void(*FuncToChangeAttributeValue)(
char const * in_attributeName,
std::string & io_attributeValue);
void DoNotChangeAttributeValue(
char const * in_attributeName,
std::string & io_attributeValue);
}
class AutoRestoreXmlCheck
{
public:
AutoRestoreXmlCheck();
~AutoRestoreXmlCheck();
private:
SettingsBaseSp m_spSettings;
};
class XmlCheck
{
public:
XmlCheck() {};
virtual ~XmlCheck() {};
static XmlCheck* Get(void);
static XmlCheck* s_pXmlCheck;
virtual void Dump(EventContext in_context) const = 0;
static void Cleanup(void);
static XmlCheckSp CreateLocalInstance(IEventReceiver* in_pEventReceiver);
virtual IEventReceiver* SetEventReceiver(IEventReceiver* in_pEventReceiver) = 0;
virtual void SetDefaults(void) = 0;
virtual SettingsBaseSp CopyCurrentSettings() const = 0;
virtual void RestoreCurrentSettings(SettingsBaseSp in_spSettings) = 0;
virtual void SetOutputModeForWritingXmlContents(EventContext in_outputMode) = 0;
virtual void SetDetailedOutput(bool in_detailedOutput) = 0;
virtual void SetIgnoreDeclaration(bool in_ignoreDeclaration) = 0;
virtual void IgnoreAttribute(std::string const & in_attribute, bool in_ignore = true) = 0;
virtual bool IsAttributeToIgnore(std::string const & in_attribute) const = 0;
virtual void IgnoreNode(std::string const & in_nodeName, bool in_ignore = true) = 0;
virtual bool IsNodeToIgnore(std::string const & in_nodeName) const = 0;
virtual void UseAsDoubleAttribute(std::string const & in_attribute, bool in_useAsDouble = true, int in_precision = 4) = 0;
virtual bool IsDoubleAttribute(std::string const & in_attribute) const = 0;
virtual int GetPrecisionOfDoubleAttribute(std::string const & in_attribute) const = 0;
virtual void UseAsDoubleNode(std::string const & in_nodeName, bool in_useAsDouble = true, int in_precision = 4) = 0;
virtual bool IsDoubleNode(std::string const & in_nodeName) const = 0;
virtual int GetPrecisionOfDoubleNode(std::string const & in_nodeName) const = 0;
virtual void UseAsPointerAttribute(std::string const & in_attribute, bool in_useAsPointer = true) = 0;
virtual bool IsPointerAttribute(std::string const & in_attribute) const = 0;
virtual void UseAsPointerNode(std::string const & in_nodeName, bool in_useAsPointer = true) = 0;
virtual bool IsPointerNode(std::string const & in_nodeName) const = 0;
virtual void SetFuncToChangeAttributeValue(XmlServices::FuncToChangeAttributeValue in_func) = 0;
virtual void CheckNode(
pugi::xml_node const & in_rNode,
char const * in_file = 0,
long in_lineNum = 0
) = 0;
virtual void CheckSubNode(
pugi::xml_node const & in_rNode,
std::string const & in_xPathExpression,
char const * in_file = 0,
long in_lineNum = 0
) = 0;
virtual void CheckSubNodeWithMaxChilds(
int in_maxChilds,
pugi::xml_node const & in_rNode,
std::string const & in_xPathExpression,
char const * in_file = 0,
long in_lineNum = 0
) = 0;
virtual bool Compare(
pugi::xml_node const & in_rNodeA,
pugi::xml_node const & in_rNodeB,
char const * in_file = 0,
long in_lineNum = 0
) = 0;
virtual std::string GetCompareResult(void) const = 0;
static pugi::xml_node NodeFromXPath(
pugi::xml_node const & in_rParentNode,
std::string const & in_xPathExpression);
virtual void CheckNode(
pugi::xml_document const & in_rDoc,
char const * in_file = 0, long in_lineNum = 0) = 0;
virtual void CheckSubNode(
pugi::xml_document const & in_rDoc,
std::string const & in_xPathExpression,
char const * in_file = 0, long in_lineNum = 0) = 0;
virtual void CheckSubNodeWithMaxChilds(
int in_maxChilds,
pugi::xml_document const & in_rDoc,
std::string const & in_xPathExpression,
char const * in_file = 0, long in_lineNum = 0) = 0;
virtual bool Compare(
pugi::xml_document const & in_rDocA,
pugi::xml_document const & in_rDocB,
char const * in_file = 0, long in_lineNum = 0) = 0;
virtual void ApplyFilterToXmlTree(pugi::xml_document& io_docFromFile) = 0;
virtual void ApplyFilterToXmlTree(pugi::xml_node& io_docFromFile) = 0;
virtual pugi::xml_node ReadFromFile(pugi::xml_document& io_docFromFile, std::string const & in_xmlFilePath) = 0;
virtual bool SaveToFile(pugi::xml_document& io_docFromFile, std::string const & in_xmlFilePath) = 0;
virtual pugi::xml_node ReadFromString(pugi::xml_document& io_docFromString, std::string const & in_xmlTreeAsString) = 0;
};
XmlCheck* TheXmlCheck(void);
}