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_STORE_STORE_CONSTS_H
17 #define ZORBA_STORE_STORE_CONSTS_H
18 
19 #include <string>
20 #include <zorba/config.h>
21 
22 namespace zorba { namespace store {
23 
24 /*******************************************************************************
25   !!! ATTENTION: The order of the enum values within SchemaTypeCode is important.
26   !!! DO NOT change this order!!!!
27 ********************************************************************************/
28 enum SchemaTypeCode
29 {
30   XS_ANY_ATOMIC            = 0,
31 
32   XS_STRING                = 1,
33   XS_NORMALIZED_STRING     = 2,
34   XS_TOKEN                 = 3,
35   XS_LANGUAGE              = 4,
36   XS_NMTOKEN               = 5,
37   XS_NAME                  = 6,
38   XS_NCNAME                = 7,
39   XS_ID                    = 8,
40   XS_IDREF                 = 9,
41   XS_ENTITY                = 10,
42 
43   XS_UNTYPED_ATOMIC        = 11,
44 
45   XS_DATETIME              = 12,
46   XS_DATE                  = 13,
47   XS_TIME                  = 14,
48 
49   XS_DURATION              = 15,
50   XS_DT_DURATION           = 16,
51   XS_YM_DURATION           = 17,
52 
53   XS_FLOAT                 = 18,
54   XS_DOUBLE                = 19,
55 
56   XS_DECIMAL               = 20,
57   XS_INTEGER               = 21,
58   XS_NON_POSITIVE_INTEGER  = 22,
59   XS_NEGATIVE_INTEGER      = 23,
60   XS_LONG                  = 24,
61   XS_INT                   = 25,
62   XS_SHORT                 = 26,
63   XS_BYTE                  = 27,
64   XS_NON_NEGATIVE_INTEGER  = 28,
65   XS_UNSIGNED_LONG         = 29,
66   XS_UNSIGNED_INT          = 30,
67   XS_UNSIGNED_SHORT        = 31,
68   XS_UNSIGNED_BYTE         = 32,
69   XS_POSITIVE_INTEGER      = 33,
70 
71   XS_GYEAR_MONTH           = 34,
72   XS_GYEAR                 = 35,
73   XS_GMONTH_DAY            = 36,
74   XS_GDAY                  = 37,
75   XS_GMONTH                = 38,
76 
77   XS_BOOLEAN               = 39,
78 
79   XS_BASE64BINARY          = 40,
80   XS_HEXBINARY             = 41,
81 
82   XS_ANY_URI               = 42,
83 
84   XS_QNAME                 = 43,
85   XS_NOTATION              = 44,
86 
87   JS_NULL                  = 45,
88 
89   XS_LAST
90 };
91 
92 
93 class ZORBA_DLL_PUBLIC StoreConsts
94 {
95  public:
96 
97   enum NsScoping
98   {
99     ALL_NAMESPACES,
100     ONLY_LOCAL_NAMESPACES,
101     ONLY_PARENT_NAMESPACES
102   };
103 
104   enum NodeKind
105   {
106     anyNode        = 0,
107     documentNode   = 1,
108     elementNode    = 2,
109     attributeNode  = 3,
110     textNode       = 4,
111     piNode         = 5,
112     commentNode    = 6
113   };
114 
toString(NodeKind k)115   static std::string toString(NodeKind k)
116   {
117     switch(k)
118     {
119     case anyNode:
120       return "anyNode";
121 
122     case documentNode:
123       return "documentNode";
124 
125     case elementNode:
126       return "elementNode";
127 
128     case attributeNode:
129       return "attributeNode";
130 
131     case textNode:
132       return "textNode";
133 
134     case piNode:
135       return "piNode";
136 
137     case commentNode:
138       return "commentNode";
139 
140     default:
141       return "<unknown NodeKind>";
142     }
143   }
144 
toSchemaString(NodeKind k)145   static std::string toSchemaString(NodeKind k)
146   {
147     switch(k)
148     {
149     case anyNode:
150       return "node";
151 
152     case documentNode:
153       return "document-node";
154 
155     case elementNode:
156       return "element";
157 
158     case attributeNode:
159       return "attribute";
160 
161     case textNode:
162       return "text";
163 
164     case piNode:
165       return "processing-instruction";
166 
167     case commentNode:
168       return "comment";
169 
170     default:
171       return "<unknown NodeKind>";
172     }
173   }
174 
175 
176   /* ATTENTION: the ordering of the enum values is important. Do NOT change it! */
177   enum JSONItemKind
178   {
179     jsonItem       = 0,
180     jsonObject     = 1,
181     jsonArray      = 2
182   };
183 
184 
toString(JSONItemKind k)185   static std::string toString(JSONItemKind k)
186   {
187     switch(k)
188     {
189       case jsonItem:
190         return "json-item";
191 
192       case jsonObject:
193         return "object";
194 
195       case jsonArray:
196         return "array";
197 
198       default:
199         return "<unknown JSONItemKind>";
200     }
201   }
202 };
203 
204 } // namespace store
205 } // namespace zorba
206 #endif
207 /* vim:set et sw=2 ts=2: */
208