blob: 190ac0cf9ea9ce5b3c76bb84f7927fa690293853 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/**
* @file
* @author 2012-2015 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
* @copyright Simplified BSD
*
* @cond
* This program is free software: you can redistribute it and/or modify
* it under the terms of the FreeBSD license as published by the FreeBSD
* project.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the FreeBSD license along with this
* program. If not, see <http://www.opensource.org/licenses/bsd-license>.
* @endcond
*/
#ifndef INTERPRETERINFO_H_CED68EFF
#define INTERPRETERINFO_H_CED68EFF
#include <iostream>
#include "uscxml/plugins/IOProcessor.h"
#include "uscxml/plugins/Invoker.h"
#include <XPath/XPath.hpp>
#include <DOM/Document.hpp>
namespace uscxml {
class USCXML_API NameSpaceInfo {
public:
NameSpaceInfo() : nsContext(NULL) {
init(std::map<std::string, std::string>());
}
NameSpaceInfo(const std::map<std::string, std::string>& nsInfo) : nsContext(NULL) {
init(nsInfo);
}
NameSpaceInfo(const NameSpaceInfo& other) : nsContext(NULL) {
init(other.nsInfo);
}
virtual ~NameSpaceInfo() {
if (nsContext)
delete nsContext;
}
NameSpaceInfo& operator=( const NameSpaceInfo& other ) {
init(other.nsInfo);
return *this;
}
void setPrefix(Arabica::DOM::Element<std::string> element) {
if (nsURL.size() > 0)
element.setPrefix(nsToPrefix[nsURL]);
}
void setPrefix(Arabica::DOM::Attr<std::string> attribute) {
if (nsURL.size() > 0)
attribute.setPrefix(nsToPrefix[nsURL]);
}
std::string getXMLPrefixForNS(const std::string& ns) const {
if (nsToPrefix.find(ns) != nsToPrefix.end() && nsToPrefix.at(ns).size())
return nsToPrefix.at(ns) + ":";
return "";
}
const Arabica::XPath::StandardNamespaceContext<std::string>* getNSContext() {
return nsContext;
}
std::string nsURL; // ough to be "http://www.w3.org/2005/07/scxml" but maybe empty
std::string xpathPrefix; // prefix mapped for xpath, "scxml" is _xmlNSPrefix is empty but _nsURL set
std::string xmlNSPrefix; // the actual prefix for elements in the xml file
std::map<std::string, std::string> nsToPrefix; // prefixes for a given namespace
std::map<std::string, std::string> nsInfo; // all xmlns mappings
private:
Arabica::XPath::StandardNamespaceContext<std::string>* nsContext;
void init(const std::map<std::string, std::string>& nsInfo);
};
class USCXML_API InterpreterInfo {
public:
virtual NameSpaceInfo getNameSpaceInfo() const = 0;
virtual const std::string& getName() = 0;
virtual const std::string& getSessionId() = 0;
virtual const std::map<std::string, IOProcessor>& getIOProcessors() = 0;
virtual bool isInState(const std::string& stateId) = 0;
virtual Arabica::DOM::Document<std::string> getDocument() const = 0;
virtual const std::map<std::string, Invoker>& getInvokers() = 0;
};
}
#endif /* end of include guard: INTERPRETERINFO_H_CED68EFF */
|