cmake/Source/CPack/WiX/cmWIXPatchParser.h

91 lines
1.7 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2014-08-03 19:52:23 +02:00
#ifndef cmCPackWIXPatchParser_h
#define cmCPackWIXPatchParser_h
2017-07-20 19:35:53 +02:00
#include "cmCPackLog.h"
2014-08-03 19:52:23 +02:00
2017-07-20 19:35:53 +02:00
#include "cmXMLParser.h"
2016-07-09 11:21:54 +02:00
#include <map>
2017-07-20 19:35:53 +02:00
#include <vector>
2014-08-03 19:52:23 +02:00
2016-03-13 13:35:51 +01:00
struct cmWIXPatchNode
2014-08-03 19:52:23 +02:00
{
2016-03-13 13:35:51 +01:00
enum Type
{
TEXT,
ELEMENT
};
virtual ~cmWIXPatchNode();
virtual Type type() = 0;
};
struct cmWIXPatchText : public cmWIXPatchNode
{
virtual Type type();
std::string text;
};
struct cmWIXPatchElement : cmWIXPatchNode
{
virtual Type type();
2014-08-03 19:52:23 +02:00
~cmWIXPatchElement();
2017-07-20 19:35:53 +02:00
typedef std::vector<cmWIXPatchNode*> child_list_t;
2014-08-03 19:52:23 +02:00
typedef std::map<std::string, std::string> attributes_t;
std::string name;
child_list_t children;
attributes_t attributes;
};
/** \class cmWIXPatchParser
* \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE)
*/
class cmWIXPatchParser : public cmXMLParser
{
public:
typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
private:
2016-07-09 11:21:54 +02:00
virtual void StartElement(const std::string& name, const char** atts);
2014-08-03 19:52:23 +02:00
2016-07-09 11:21:54 +02:00
void StartFragment(const char** attributes);
2014-08-03 19:52:23 +02:00
2015-04-27 22:25:09 +02:00
virtual void EndElement(const std::string& name);
2016-03-13 13:35:51 +01:00
virtual void CharacterDataHandler(const char* data, int length);
2014-08-03 19:52:23 +02:00
virtual void ReportError(int line, int column, const char* msg);
2015-04-27 22:25:09 +02:00
void ReportValidationError(std::string const& message);
2014-08-03 19:52:23 +02:00
bool IsValid() const;
cmCPackLog* Logger;
enum ParserState
{
BEGIN_DOCUMENT,
BEGIN_FRAGMENTS,
INSIDE_FRAGMENT
};
ParserState State;
bool Valid;
fragment_map_t& Fragments;
2017-07-20 19:35:53 +02:00
std::vector<cmWIXPatchElement*> ElementStack;
2014-08-03 19:52:23 +02:00
};
#endif