diff options
author | Nils Gladitz <nilsgladitz@gmail.com> | 2015-10-12 19:53:08 (GMT) |
---|---|---|
committer | Nils Gladitz <nilsgladitz@gmail.com> | 2015-10-12 19:53:08 (GMT) |
commit | 5a266095ee778fb700c067c55ff0b59777a72c50 (patch) | |
tree | 5b714661965f0787330de044fc4e196f4b54b90f /Source/CPack/WiX/cmWIXPatchParser.cxx | |
parent | e5fb30fb5bdff2913cc9382649984da89e882b25 (diff) | |
download | CMake-5a266095ee778fb700c067c55ff0b59777a72c50.zip CMake-5a266095ee778fb700c067c55ff0b59777a72c50.tar.gz CMake-5a266095ee778fb700c067c55ff0b59777a72c50.tar.bz2 |
CPackWIX: Handle text nodes in XML patch content
Diffstat (limited to 'Source/CPack/WiX/cmWIXPatchParser.cxx')
-rw-r--r-- | Source/CPack/WiX/cmWIXPatchParser.cxx | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index e066c28..14c5413 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -16,6 +16,21 @@ #include <cm_expat.h> +cmWIXPatchNode::Type cmWIXPatchText::type() +{ + return cmWIXPatchNode::TEXT; +} + +cmWIXPatchNode::Type cmWIXPatchElement::type() +{ + return cmWIXPatchNode::ELEMENT; +} + +cmWIXPatchNode::~cmWIXPatchNode() +{ + +} + cmWIXPatchElement::~cmWIXPatchElement() { for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) @@ -63,20 +78,20 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char **atts) { cmWIXPatchElement &parent = *ElementStack.back(); - parent.children.resize(parent.children.size() + 1); - cmWIXPatchElement*& currentElement = parent.children.back(); - currentElement = new cmWIXPatchElement; - currentElement->name = name; + cmWIXPatchElement *element = new cmWIXPatchElement; + parent.children.push_back(element); + + element->name = name; for(size_t i = 0; atts[i]; i += 2) { std::string key = atts[i]; std::string value = atts[i+1]; - currentElement->attributes[key] = value; + element->attributes[key] = value; } - ElementStack.push_back(currentElement); + ElementStack.push_back(element); } } @@ -117,11 +132,34 @@ void cmWIXPatchParser::EndElement(const std::string& name) } else { - ElementStack.pop_back(); + ElementStack.pop_back(); } } } +void cmWIXPatchParser::CharacterDataHandler(const char* data, int length) +{ + const char* whitespace = "\x20\x09\x0d\x0a"; + + if(State == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *ElementStack.back(); + + std::string text(data, length); + + std::string::size_type first = text.find_first_not_of(whitespace); + std::string::size_type last = text.find_last_not_of(whitespace); + + if(first != std::string::npos && last != std::string::npos) + { + cmWIXPatchText *text_node = new cmWIXPatchText; + text_node->text = text.substr(first, last - first + 1); + + parent.children.push_back(text_node); + } + } +} + void cmWIXPatchParser::ReportError(int line, int column, const char* msg) { cmCPackLogger(cmCPackLog::LOG_ERROR, |