typeident.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef ZORBA_TYPES_TYPEIDENT_H
17 #define ZORBA_TYPES_TYPEIDENT_H
18 
19 #include <zorba/config.h>
20 #include <zorba/api_shared_types.h>
21 #include <zorba/identtypes.h>
22 #include <zorba/zorba_string.h>
23 #include <iostream>
24 
25 namespace zorba {
26 
27 /** \brief Type identifiers
28  *
29  * The type identifiers are not used, yet.
30  *
31  * Note: This class is reference counted. When writing multi-threaded clients,
32  * it is the responibility of the client code to synchronize assignments to the
33  * SmartPtr holding this object.
34  */
35 class ZORBA_DLL_PUBLIC TypeIdentifier : public SmartObject
36 {
37  public:
38  /** \brief Destructor
39  */
40  ~TypeIdentifier();
41 
42  static TypeIdentifier_t
43  createNamedType(
44  const String& uri,
45  const String& localName,
47 
48  static TypeIdentifier_t
49  createElementType(
50  const String& uri,
51  bool uriWildcard,
52  const String& localName,
53  bool localNameWildcard,
54  TypeIdentifier_t contentType,
56 
57  static TypeIdentifier_t
58  createAttributeType(
59  const String& uri,
60  bool uriWildcard,
61  const String& localName,
62  bool localNameWildcard,
63  TypeIdentifier_t contentType,
65 
66  static TypeIdentifier_t
67  createDocumentType(
68  TypeIdentifier_t contentType,
70 
71  static TypeIdentifier_t
73 
74  static TypeIdentifier_t
75  createNamespaceType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
76 
77  static TypeIdentifier_t
79 
80  static TypeIdentifier_t
81  createCommentType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
82 
83  static TypeIdentifier_t
84  createAnyNodeType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
85 
86  static TypeIdentifier_t
87  createStructuredItemType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
88 
89 #ifdef ZORBA_WITH_JSON
90  static TypeIdentifier_t
91  createJSONItemType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
92 
93  static TypeIdentifier_t
94  createJSONObjectType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
95 
96  static TypeIdentifier_t
97  createJSONArrayType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
98 #endif
99 
100  static TypeIdentifier_t
102 
103  static TypeIdentifier_t
104  createEmptyType();
105 
106  static TypeIdentifier_t
107  createSchemaElementType(
108  const String& uri,
109  const String& localName,
111 
112  static TypeIdentifier_t
113  createSchemaAttributeType(
114  const String& uri,
115  const String& localName,
117 
119  getKind() const;
120 
122  getQuantifier() const;
123 
124  const String&
125  getUri() const;
126 
127  bool
128  isUriWildcard() const;
129 
130  const String&
131  getLocalName() const;
132 
133  bool
134  isLocalNameWildcard() const;
135 
137  getContentType() const;
138 
139  std::ostream&
140  emit(std::ostream&) const;
141 
142  private:
143  TypeIdentifier();
144 
145  std::ostream&
146  emitItemType(std::ostream&) const;
147 
148  std::ostream&
149  emitName(std::ostream&) const;
150 
151  IdentTypes::kind_t m_kind;
152  IdentTypes::quantifier_t m_quantifier;
153  String m_uri;
154  bool m_uriWildcard;
155  String m_localName;
156  bool m_localNameWildcard;
157  TypeIdentifier_t m_contentType;
158 };
159 
160 #ifdef WIN32
161  template class ZORBA_DLL_PUBLIC zorba::SmartPtr<TypeIdentifier>;
162 #endif
163 
164 
165 } /* namespace zorba */
166 
167 namespace std {
168 
169 ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::TypeIdentifier& ti);
170 ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::TypeIdentifier_t ti);
171 
172 }
173 
174 #endif /* ZORBA_TYPES_TYPEIDENT_H */
175 /* vim:set et sw=2 ts=2: */