cmake/Source/CPack/WiX/cmWIXPatchParser.h

93 lines
1.8 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. */
2021-09-14 00:13:48 +02:00
#pragma once
2014-08-03 19:52:23 +02:00
2016-07-09 11:21:54 +02:00
#include <map>
2020-08-30 11:54:41 +02:00
#include <memory>
2017-07-20 19:35:53 +02:00
#include <vector>
2014-08-03 19:52:23 +02:00
2020-02-01 23:06:01 +01:00
#include "cmCPackLog.h"
#include "cmXMLParser.h"
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();
2020-08-30 11:54:41 +02:00
cmWIXPatchElement();
cmWIXPatchElement(const cmWIXPatchElement&) = delete;
const cmWIXPatchElement& operator=(const cmWIXPatchElement&) = delete;
2014-08-03 19:52:23 +02:00
~cmWIXPatchElement();
2020-08-30 11:54:41 +02:00
using child_list_t = std::vector<std::unique_ptr<cmWIXPatchNode>>;
2020-02-01 23:06:01 +01:00
using attributes_t = std::map<std::string, std::string>;
2014-08-03 19:52:23 +02:00
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:
2020-02-01 23:06:01 +01:00
using fragment_map_t = std::map<std::string, cmWIXPatchElement>;
2014-08-03 19:52:23 +02:00
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
};