SourceForge.net Logo
StaticType.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001, 2008,
3 * DecisionSoft Limited. All rights reserved.
4 * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef _STATICTYPE_HPP
21#define _STATICTYPE_HPP
22
23#include <xqilla/framework/XQillaExport.hpp>
26
27#include <xercesc/framework/XMLBuffer.hpp>
29
33class XQILLA_API StaticType : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory {
34public:
39 DOCUMENT_TYPE = 0x00000001,
40 ELEMENT_TYPE = 0x00000002,
41 ATTRIBUTE_TYPE = 0x00000004,
42 TEXT_TYPE = 0x00000008,
43 PI_TYPE = 0x00000010,
44 COMMENT_TYPE = 0x00000020,
45 NAMESPACE_TYPE = 0x00000040,
46
47 ANY_SIMPLE_TYPE = 0x00000080,
48 ANY_URI_TYPE = 0x00000100,
49 BASE_64_BINARY_TYPE = 0x00000200,
50 BOOLEAN_TYPE = 0x00000400,
51 DATE_TYPE = 0x00000800,
52 DATE_TIME_TYPE = 0x00001000,
54 DECIMAL_TYPE = 0x00004000,
55 DOUBLE_TYPE = 0x00008000,
56 DURATION_TYPE = 0x00010000,
57 FLOAT_TYPE = 0x00020000,
58 G_DAY_TYPE = 0x00040000,
59 G_MONTH_TYPE = 0x00080000,
60 G_MONTH_DAY_TYPE = 0x00100000,
61 G_YEAR_TYPE = 0x00200000,
62 G_YEAR_MONTH_TYPE = 0x00400000,
63 HEX_BINARY_TYPE = 0x00800000,
64 NOTATION_TYPE = 0x01000000,
65 QNAME_TYPE = 0x02000000,
66 STRING_TYPE = 0x04000000,
67 TIME_TYPE = 0x08000000,
68 UNTYPED_ATOMIC_TYPE = 0x10000000,
70
71 FUNCTION_TYPE = 0x40000000,
72
75
77
80
84
86
88
90 };
91
92 static const unsigned int UNLIMITED;
93
96 // Constructor for normal types
97 StaticType(StaticTypeFlags f, unsigned int min = 1, unsigned int max = 1);
99 StaticType(XPath2MemoryManager *mm, unsigned int numArgs, const StaticType &returnType, unsigned int min = 1, unsigned int max = 1);
101 StaticType(XPath2MemoryManager *mm, unsigned int minArgs, unsigned int maxArgs, const StaticType &returnType,
102 unsigned int min = 1, unsigned int max = 1);
103
107
108 static StaticType create(const XMLCh *uri, const XMLCh *name, const StaticContext *context,
109 bool &isExact);
111
112 void typeUnion(const StaticType &st);
113 void typeIntersect(const StaticType &st);
114 void typeExcept(const StaticType &st);
115
116 void typeConcat(const StaticType &st);
118
121
124
125 StaticType &substitute(const StaticType &from, const StaticType &to);
126 StaticType &multiply(unsigned int min, unsigned int max);
127 void setCardinality(unsigned int min, unsigned int max);
128
129 bool containsType(const StaticType &type) const;
131 bool isType(const StaticType &type) const;
132
139
144
145 TypeMatch matches(const StaticType &actual) const;
146
147 unsigned int getMin() const { return min_; }
148 unsigned int getMax() const { return max_; }
149
150 unsigned int getMinArgs() const { return minArgs_; }
151 unsigned int getMaxArgs() const { return maxArgs_; }
152 const StaticType *getReturnType() const { return returnType_; }
153
154 void typeToBuf(XERCES_CPP_NAMESPACE_QUALIFIER XMLBuffer &buf) const;
155
156private:
157 TypeMatchEnum matchesFunctionType(const StaticType &type) const;
158 TypeMatchEnum matchesType(const StaticType &type) const;
159
160 unsigned int flags_;
161 unsigned int min_;
162 unsigned int max_;
163
165 unsigned int minArgs_;
166 unsigned int maxArgs_;
167 StaticType *returnType_;
168};
169
172
173#endif
StaticType::StaticTypeFlags operator|(StaticType::StaticTypeFlags a, StaticType::StaticTypeFlags b)
StaticType::StaticTypeFlags operator&(StaticType::StaticTypeFlags a, StaticType::StaticTypeFlags b)
AtomicObjectType
Definition AnyAtomicType.hpp:34
The parse time static context interface.
Definition StaticContext.hpp:58
static StaticType create(const XMLCh *uri, const XMLCh *name, const StaticContext *context, bool &isExact)
unsigned int getMinArgs() const
Definition StaticType.hpp:150
void typeNodeIntersect(const StaticType &st)
StaticType(XPath2MemoryManager *mm, unsigned int numArgs, const StaticType &returnType, unsigned int min=1, unsigned int max=1)
Constructor for a function type.
StaticType & multiply(unsigned int min, unsigned int max)
StaticType & operator=(const StaticType &o)
StaticType()
Constructor for an empty type.
const StaticType * getReturnType() const
Definition StaticType.hpp:152
void typeToBuf(xercesc::XMLBuffer &buf) const
TypeMatch matches(const StaticType &actual) const
void typeExcept(const StaticType &st)
void setCardinality(unsigned int min, unsigned int max)
unsigned int getMax() const
Definition StaticType.hpp:148
StaticType & operator&=(const StaticType &st)
StaticType(const StaticType &o)
StaticType operator|(const StaticType &st) const
void typeUnion(const StaticType &st)
StaticType(StaticTypeFlags f, unsigned int min=1, unsigned int max=1)
void typeConcat(const StaticType &st)
bool containsType(const StaticType &type) const
bool isType(const StaticType &type) const
TypeMatchEnum
Definition StaticType.hpp:133
@ MAYBE
Definition StaticType.hpp:136
@ PROBABLY_NOT
Definition StaticType.hpp:135
@ NEVER
Definition StaticType.hpp:134
@ ALWAYS
Definition StaticType.hpp:137
StaticTypeFlags
Flags that determine what item types are returned from an expression.
Definition StaticType.hpp:38
@ PI_TYPE
Definition StaticType.hpp:43
@ TYPED_ATOMIC_TYPE
Definition StaticType.hpp:81
@ DECIMAL_TYPE
Definition StaticType.hpp:54
@ ATTRIBUTE_TYPE
Definition StaticType.hpp:41
@ DURATION_TYPE
Definition StaticType.hpp:56
@ G_DAY_TYPE
Definition StaticType.hpp:58
@ HEX_BINARY_TYPE
Definition StaticType.hpp:63
@ FLOAT_TYPE
Definition StaticType.hpp:57
@ TIME_TYPE
Definition StaticType.hpp:67
@ NOTATION_TYPE
Definition StaticType.hpp:64
@ STRING_TYPE
Definition StaticType.hpp:66
@ NODE_TYPE
Definition StaticType.hpp:73
@ ELEMENT_TYPE
Definition StaticType.hpp:40
@ NUMERIC_TYPE
Definition StaticType.hpp:76
@ DATE_TIME_TYPE
Definition StaticType.hpp:52
@ YEAR_MONTH_DURATION_TYPE
Definition StaticType.hpp:69
@ EMPTY_TYPE
Definition StaticType.hpp:89
@ DATE_TYPE
Definition StaticType.hpp:51
@ DOUBLE_TYPE
Definition StaticType.hpp:55
@ DAY_TIME_DURATION_TYPE
Definition StaticType.hpp:53
@ QNAME_TYPE
Definition StaticType.hpp:65
@ G_MONTH_TYPE
Definition StaticType.hpp:59
@ BASE_64_BINARY_TYPE
Definition StaticType.hpp:49
@ ANY_URI_TYPE
Definition StaticType.hpp:48
@ ANY_SIMPLE_TYPE
Definition StaticType.hpp:47
@ TEXT_TYPE
Definition StaticType.hpp:42
@ COMMENT_TYPE
Definition StaticType.hpp:44
@ G_MONTH_DAY_TYPE
Definition StaticType.hpp:60
@ G_YEAR_TYPE
Definition StaticType.hpp:61
@ DOCUMENT_TYPE
Definition StaticType.hpp:39
@ ITEM_TYPE
Definition StaticType.hpp:87
@ ANY_ATOMIC_TYPE
Definition StaticType.hpp:85
@ TIMEZONE_TYPE
Definition StaticType.hpp:78
@ NAMESPACE_TYPE
Definition StaticType.hpp:45
@ UNTYPED_ATOMIC_TYPE
Definition StaticType.hpp:68
@ G_YEAR_MONTH_TYPE
Definition StaticType.hpp:62
@ FUNCTION_TYPE
Definition StaticType.hpp:71
@ BOOLEAN_TYPE
Definition StaticType.hpp:50
StaticType & operator|=(const StaticType &st)
static StaticType create(AnyAtomicType::AtomicObjectType primitiveType)
bool containsType(StaticType::StaticTypeFlags flags) const
StaticType operator&(const StaticType &st) const
unsigned int getMin() const
Definition StaticType.hpp:147
unsigned int getMaxArgs() const
Definition StaticType.hpp:151
StaticType(XPath2MemoryManager *mm, unsigned int minArgs, unsigned int maxArgs, const StaticType &returnType, unsigned int min=1, unsigned int max=1)
Constructor for a function type.
StaticType & substitute(const StaticType &from, const StaticType &to)
static const unsigned int UNLIMITED
Definition StaticType.hpp:92
void typeIntersect(const StaticType &st)
Definition XPath2MemoryManager.hpp:46
Definition StaticType.hpp:141
TypeMatchEnum cardinality
Definition StaticType.hpp:142
TypeMatchEnum type
Definition StaticType.hpp:142