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 {
88 
89 
90 typedef enum
91 {
95 
96 
97 typedef enum
98 {
102 
103 typedef enum {
107 
108 typedef enum {
112 
113 typedef enum {
121 
122 typedef enum {
126 
127 typedef enum {
132 
133 typedef enum {
137 
138 typedef enum {
142 
143 typedef enum {
147 
148 typedef enum {
152 /** \brief Options that configure the serialization process of a query result.
153 * See http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/.
154 *
155 * This struct defines options that can be passed to the serialization process of a query
156 * result. An instance of this class can be passed to the serialize function.
157 *
158 * File \link serialization.cpp \endlink contains examples that show how to use
159 * the SerializerOptions.
160 */
161 #ifdef __cplusplus
162 typedef struct ZORBA_DLL_PUBLIC Zorba_SerializerOptions
163 {
164  Zorba_serialization_method_t ser_method;
165  Zorba_byte_order_mark_t byte_order_mark;
166  Zorba_escape_uri_attributes_t escape_uri_attributes;
167  Zorba_include_content_type_t include_content_type;
168  Zorba_indent_t indent;
169  Zorba_normalization_form_t normalization_form;
170  Zorba_omit_xml_declaration_t omit_xml_declaration;
171  Zorba_standalone_t standalone;
172  Zorba_undeclare_prefixes_t undeclare_prefixes;
173  Zorba_encoding_t encoding;
174 
175  zorba::String media_type;
176  zorba::String doctype_system;
177  zorba::String doctype_public;
178  zorba::String cdata_section_elements;
179  zorba::String version;
180 
181 
182  /** \brief Default constructor for SerializerOptions which assigns default values to all
183  * options (C++ only).
184  *
185  * Default values:
186  * - serialization method: XML
187  * - byte-order-mark: NO
188  * - esacpe-uri-attributes: NO
189  * - include-content-type: NO
190  * - indent: NO
191  * - normalization-form: none
192  * - omit-xml-declaration: NO
193  * - standalone: omit
194  * - undeclare-prefixes: NO
195  */
196 
197  Zorba_SerializerOptions();
198 
199  /** \brief Helper function to set a serializer parameter value from a key / value string pair.
200  *
201  *
202  * \retval None
203  */
204  void SetSerializerOption(const char* parameter, const char* value);
205 
206  /** \brief Helper function to create a Zorba_SerializerOptions from a vector of key / value
207  * string pairs
208  *
209  * \retval The created Zorba_SerializerOptions structure
210  */
211  static Zorba_SerializerOptions SerializerOptionsFromStringParams(const std::vector<std::pair<std::string,std::string> >& params);
212 
214 #endif
215 
216 
217 #ifndef __cplusplus
218 struct Zorba_SerializerOptions;
219 typedef struct Zorba_SerializerOptions Zorba_SerializerOptions_t;
220 #endif
221 
222 
223 #ifdef __cplusplus
224 extern "C" {
225 #endif
226 
227 /** \brief Helper function for C to set default values ComplilerHints struct.
228  *
229  * \retval Zorba_CompilerHints_t with default member values
230  */
231 ZORBA_DLL_PUBLIC void Zorba_CompilerHints_default(Zorba_CompilerHints_t*);
232 
233 /** \brief Helper function to create a Zorba_SerializerOptions_t struct because
234  * of missing default constructor. C++ code can delete the
235  * returned Zorba_SerializerOptions_t* struct, while C code
236  * must call Zorba_SerializerOptions_free().
237  *
238  * \retval Zorba_CompilerHints_t with default member values
239  */
241 
242 /** \brief Helper function to delete a Zorba_SerializerOptions_t struct
243  *
244  * \retval Zorba_CompilerHints_t with default member values
245  */
246 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_free(Zorba_SerializerOptions_t* serializerOptions);
247 
248 /** \brief Helper function to set an option in a Zorba_SerializerOptions_t structure
249  *
250  * \param serializerOptions serializer options
251  * \param parameter the serializer parameter to be configured
252  * \param value the value to which the parameter should be set
253  * \retval Zorba_CompilerHints_t with default member values
254  */
255 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_set(Zorba_SerializerOptions_t* serializerOptions, const char* parameter, const char* value);
256 
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif
263 
264 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus