options.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_OPTIONS_H
17 #define ZORBA_OPTIONS_H
18 #include <zorba/config.h>
19 
20 #ifdef __cplusplus
21 #include <vector>
22 #include <zorba/zorba_string.h>
23 #endif
24 
25 
26 /** \brief The optimization level used for optimizing the query. */
27 typedef enum {
28  ZORBA_OPT_LEVEL_O0, /**< Don't use any optimization. */
29  ZORBA_OPT_LEVEL_O1, /**< Use basic optimizations
30  (e.g.\ removing sorting, removing duplicate elimination,
31  or constant folding). */
32  ZORBA_OPT_LEVEL_O2 /** Use basic optimizations (like O1) and some
33  * more optimizations (like not to generate an iterator
34  * for inlined functions) - call stacks in case of
35  * an exception are not generated.
36  */
38 
39 #if !defined(__cplusplus)
40  typedef enum { false = 0, true = 1 } bool;
41 #endif
42 
43 /** \brief Set of hints that can be passed to the query compiler.
44  *
45  * An instance of this class can be passed to the compileQuery function
46  * of the Zorba class or the compile function of this class.
47  * The members of this class represent hints that are passed to the
48  * query compiler. For example, whether optimization of the query
49  * should be done (O1) or not (O0).
50  *
51  * example_6 in file \link simple.cpp \endlink shows an example
52  * how CompilerHints can be used.
53  */
54 typedef struct Zorba_CompilerHints
55 {
56  /** \brief The optimization level that is used */
58  /** \brief Treat the query as a library module */
59  bool lib_module;
60 
61  /**
62  * \brief By default, this flag is set to false. Applications may set it to
63  * true if they plan to execute the query only via one of the methods that
64  * serialize the query result.
65  */
67 
68 #ifdef __cplusplus
69  /** \brief Default constructor for CompilerHints which assigns default values to all hints (C++ only).
70  *
71  * Default values:
72  * - optimization level: O1
73  * - library module: false
74  */
75  ZORBA_DLL_PUBLIC Zorba_CompilerHints();
76 #endif
78 
79 
80 typedef enum
81 {
87 #ifdef ZORBA_WITH_JSON
88  ZORBA_SERIALIZATION_METHOD_JSON,
89  ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID
90 #endif
92 
93 
94 typedef enum
95 {
99 
100 
101 typedef enum
102 {
106 
107 typedef enum {
111 
112 typedef enum {
116 
117 typedef enum {
125 
126 typedef enum {
130 
131 typedef enum {
136 
137 typedef enum {
141 
142 typedef enum {
146 
147 typedef enum {
151 
152 typedef enum {
156 
157 typedef enum {
161 
162 typedef enum {
166 
167 
168 /** \brief Options that configure the serialization process of a query result.
169 * See http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/.
170 *
171 * This struct defines options that can be passed to the serialization process of a query
172 * result. An instance of this class can be passed to the serialize function.
173 *
174 * File \link serialization.cpp \endlink contains examples that show how to use
175 * the SerializerOptions.
176 */
177 #ifdef __cplusplus
178 typedef struct ZORBA_DLL_PUBLIC Zorba_SerializerOptions
179 {
180  Zorba_serialization_method_t ser_method;
181  Zorba_byte_order_mark_t byte_order_mark;
182  Zorba_escape_uri_attributes_t escape_uri_attributes;
183  Zorba_include_content_type_t include_content_type;
184  Zorba_indent_t indent;
185  Zorba_normalization_form_t normalization_form;
186  Zorba_omit_xml_declaration_t omit_xml_declaration;
187  Zorba_standalone_t standalone;
188  Zorba_undeclare_prefixes_t undeclare_prefixes;
189  Zorba_encoding_t encoding;
190 
191  zorba::String media_type;
192  zorba::String doctype_system;
193  zorba::String doctype_public;
194  zorba::String cdata_section_elements;
195  zorba::String version;
196 
197 #ifdef ZORBA_WITH_JSON
198  Zorba_jsoniq_multiple_items_t jsoniq_multiple_items;
199  Zorba_serialization_method_t jsoniq_xdm_method;
200 #endif /* ZORBA_WITH_JSON */
201 
202  /** \brief Default constructor for SerializerOptions which assigns default values to all
203  * options (C++ only).
204  *
205  * Default values:
206  * - serialization method: XML
207  * - byte-order-mark: NO
208  * - esacpe-uri-attributes: NO
209  * - include-content-type: NO
210  * - indent: NO
211  * - normalization-form: none
212  * - omit-xml-declaration: NO
213  * - standalone: omit
214  * - undeclare-prefixes: NO
215  */
216 
217  Zorba_SerializerOptions();
218 
219  /** \brief Helper function to set a serializer parameter value from a key / value string pair.
220  *
221  *
222  * \retval None
223  */
224  void SetSerializerOption(const char* parameter, const char* value);
225 
226  /** \brief Helper function to create a Zorba_SerializerOptions from a vector of key / value
227  * string pairs
228  *
229  * \retval The created Zorba_SerializerOptions structure
230  */
231  static Zorba_SerializerOptions SerializerOptionsFromStringParams(const std::vector<std::pair<std::string,std::string> >& params);
232 
234 #endif
235 
236 
237 #ifndef __cplusplus
238 struct Zorba_SerializerOptions;
239 typedef struct Zorba_SerializerOptions Zorba_SerializerOptions_t;
240 #endif
241 
242 
243 #ifdef __cplusplus
244 extern "C" {
245 #endif
246 
247 /** \brief Helper function for C to set default values ComplilerHints struct.
248  *
249  * \retval Zorba_CompilerHints_t with default member values
250  */
251 ZORBA_DLL_PUBLIC void Zorba_CompilerHints_default(Zorba_CompilerHints_t*);
252 
253 /** \brief Helper function to create a Zorba_SerializerOptions_t struct because
254  * of missing default constructor. C++ code can delete the
255  * returned Zorba_SerializerOptions_t* struct, while C code
256  * must call Zorba_SerializerOptions_free().
257  *
258  * \retval Zorba_CompilerHints_t with default member values
259  */
261 
262 /** \brief Helper function to delete a Zorba_SerializerOptions_t struct
263  *
264  * \retval Zorba_CompilerHints_t with default member values
265  */
266 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_free(Zorba_SerializerOptions_t* serializerOptions);
267 
268 /** \brief Helper function to set an option in a Zorba_SerializerOptions_t structure
269  *
270  * \param serializerOptions serializer options
271  * \param parameter the serializer parameter to be configured
272  * \param value the value to which the parameter should be set
273  * \retval Zorba_CompilerHints_t with default member values
274  */
275 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_set(Zorba_SerializerOptions_t* serializerOptions, const char* parameter, const char* value);
276 
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif
283 
284 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus