options.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ZORBA_OPTIONS_H
00017 #define ZORBA_OPTIONS_H
00018 #include <zorba/config.h>
00019 
00020 #ifdef __cplusplus
00021 #include <vector>
00022 #include <zorba/zorba_string.h>
00023 #endif
00024 
00025 
00026 /** \brief The optimization level used for optimizing the query. */
00027 typedef enum {
00028   ZORBA_OPT_LEVEL_O0, /**< Don't use any optimization. */
00029   ZORBA_OPT_LEVEL_O1,  /**< Use basic optimizations
00030                            (e.g.\ removing sorting, removing duplicate elimination,
00031                            or constant folding). */
00032   ZORBA_OPT_LEVEL_O2  /** Use basic optimizations (like O1) and some
00033                         * more optimizations (like not to generate an iterator
00034                         * for inlined functions) - call stacks in case of
00035                         * an exception are not generated.
00036                         */
00037 } Zorba_opt_level_t;
00038 
00039 #if !defined(__cplusplus)
00040   typedef enum { false = 0, true = 1 } bool;
00041 #endif
00042 
00043 /** \brief Set of hints that can be passed to the query compiler.
00044  *
00045  * An instance of this class can be passed to the compileQuery function
00046  * of the Zorba class or the compile function of this class.
00047  * The members of this class represent hints that are passed to the
00048  * query compiler. For example, whether optimization of the query
00049  * should be done (O1) or not (O0).
00050  *
00051  * example_6 in file \link simple.cpp \endlink shows an example
00052  * how CompilerHints can be used.
00053  */
00054 typedef struct Zorba_CompilerHints {
00055   /** \brief The optimization level that is used */
00056   Zorba_opt_level_t opt_level;
00057   /** \brief Treat the query as a library module */
00058   bool lib_module;
00059 #ifdef __cplusplus
00060   /** \brief Default constructor for CompilerHints which assigns default values to all hints (C++ only).
00061    *
00062    * Default values:
00063    *   - optimization level: O1
00064    *   - library module: false
00065    */
00066   ZORBA_DLL_PUBLIC Zorba_CompilerHints();
00067 #endif
00068 } Zorba_CompilerHints_t;
00069 
00070 typedef enum {
00071   ZORBA_SERIALIZATION_METHOD_XML,
00072   ZORBA_SERIALIZATION_METHOD_HTML,
00073   ZORBA_SERIALIZATION_METHOD_XHTML,
00074   ZORBA_SERIALIZATION_METHOD_TEXT,
00075   ZORBA_SERIALIZATION_METHOD_BINARY
00076 } Zorba_serialization_method_t;
00077 
00078 typedef enum {
00079   ZORBA_BYTE_ORDER_MARK_YES,
00080   ZORBA_BYTE_ORDER_MARK_NO
00081 } Zorba_byte_order_mark_t;
00082 
00083 typedef enum {
00084   ZORBA_ESCAPE_URI_ATTRIBUTES_YES,
00085   ZORBA_ESCAPE_URI_ATTRIBUTES_NO
00086 } Zorba_escape_uri_attributes_t;
00087 
00088 typedef enum {
00089   ZORBA_INCLUDE_CONTENT_TYPE_YES,
00090   ZORBA_INCLUDE_CONTENT_TYPE_NO
00091 } Zorba_include_content_type_t;
00092 
00093 typedef enum {
00094   ZORBA_INDENT_YES,
00095   ZORBA_INDENT_NO
00096 } Zorba_indent_t;
00097 
00098 typedef enum {
00099   ZORBA_NORMALIZATION_FORM_NFC,
00100   ZORBA_NORMALIZATION_FORM_NFD,
00101   ZORBA_NORMALIZATION_FORM_NFKC,
00102   ZORBA_NORMALIZATION_FORM_NFKD,
00103   ZORBA_NORMALIZATION_FORM_FULLY_normalized,
00104   ZORBA_NORMALIZATION_FORM_NONE
00105 } Zorba_normalization_form_t;
00106 
00107 typedef enum {
00108   ZORBA_OMIT_XML_DECLARATION_YES,
00109   ZORBA_OMIT_XML_DECLARATION_NO
00110 } Zorba_omit_xml_declaration_t;
00111 
00112 typedef enum {
00113   ZORBA_STANDALONE_YES,
00114   ZORBA_STANDALONE_NO,
00115   ZORBA_STANDALONE_OMIT
00116 } Zorba_standalone_t;
00117 
00118 typedef enum {
00119   ZORBA_UNDECLARE_PREFIXES_YES,
00120   ZORBA_UNDECLARE_PREFIXES_NO
00121 } Zorba_undeclare_prefixes_t;
00122 
00123 typedef enum {
00124   ZORBA_ENCODING_UTF8,
00125   ZORBA_ENCODING_UTF16
00126 } Zorba_encoding_t;
00127 
00128 typedef enum {
00129   ZORBA_USE_BINARY_ARCHIVE,
00130   ZORBA_USE_XML_ARCHIVE
00131 } Zorba_binary_plan_format_t;
00132 
00133 typedef enum {
00134   DONT_SAVE_UNUSED_FUNCTIONS = 0,
00135   SAVE_UNUSED_FUNCTIONS = 1
00136 } Zorba_save_plan_options_t;
00137 /** \brief Options that configure the serialization process of a query result.
00138 *         See http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/.
00139 *
00140 * This struct defines options that can be passed to the serialization process of a query
00141 * result. An instance of this class can be passed to the serialize function.
00142 *
00143 * File \link serialization.cpp \endlink contains examples that show how to use
00144 * the SerializerOptions.
00145 */
00146 #ifdef __cplusplus
00147 typedef struct ZORBA_DLL_PUBLIC Zorba_SerializerOptions
00148 {
00149   Zorba_serialization_method_t  ser_method;
00150   Zorba_byte_order_mark_t       byte_order_mark;
00151   Zorba_escape_uri_attributes_t escape_uri_attributes;
00152   Zorba_include_content_type_t  include_content_type;
00153   Zorba_indent_t                indent;
00154   Zorba_normalization_form_t    normalization_form;
00155   Zorba_omit_xml_declaration_t  omit_xml_declaration;
00156   Zorba_standalone_t            standalone;
00157   Zorba_undeclare_prefixes_t    undeclare_prefixes;
00158   Zorba_encoding_t              encoding;
00159 
00160   zorba::String                 media_type;
00161   zorba::String                 doctype_system;
00162   zorba::String                 doctype_public;
00163   zorba::String                 cdata_section_elements;
00164   zorba::String                 version;
00165 
00166 
00167   /** \brief Default constructor for SerializerOptions which assigns default values to all
00168    *         options (C++ only).
00169    *
00170    * Default values:
00171    *   - serialization method: XML
00172    *   - byte-order-mark: NO
00173    *   - esacpe-uri-attributes: NO
00174    *   - include-content-type: NO
00175    *   - indent: NO
00176    *   - normalization-form: none
00177    *   - omit-xml-declaration: NO
00178    *   - standalone: omit
00179    *   - undeclare-prefixes: NO
00180    */
00181 
00182   Zorba_SerializerOptions();
00183 
00184   /** \brief Helper function to set a serializer parameter value from a key / value string pair.
00185    *
00186    *
00187    * \retval None
00188    */
00189   void SetSerializerOption(const char* parameter, const char* value);
00190 
00191   /** \brief Helper function to create a Zorba_SerializerOptions from a vector of key / value
00192    *         string pairs
00193    *
00194    * \retval The created Zorba_SerializerOptions structure
00195    */
00196   static Zorba_SerializerOptions SerializerOptionsFromStringParams(const std::vector<std::pair<std::string,std::string> >& params);
00197 
00198 } Zorba_SerializerOptions_t;
00199 #endif
00200 
00201 
00202 #ifndef __cplusplus
00203 struct Zorba_SerializerOptions;
00204 typedef struct Zorba_SerializerOptions Zorba_SerializerOptions_t;
00205 #endif
00206 
00207 
00208 #ifdef __cplusplus
00209 extern "C" {
00210 #endif
00211 
00212 /** \brief Helper function for C to set default values ComplilerHints struct.
00213  *
00214  * \retval Zorba_CompilerHints_t with default member values
00215  */
00216 ZORBA_DLL_PUBLIC void Zorba_CompilerHints_default(Zorba_CompilerHints_t*);
00217 
00218 /** \brief Helper function to create a Zorba_SerializerOptions_t struct because
00219  *         of missing default constructor. C++ code can delete the
00220  *         returned Zorba_SerializerOptions_t* struct, while C code
00221  *         must call Zorba_SerializerOptions_free().
00222  *
00223  * \retval Zorba_CompilerHints_t with default member values
00224  */
00225 ZORBA_DLL_PUBLIC Zorba_SerializerOptions_t* Zorba_SerializerOptions_default();
00226 
00227 /** \brief Helper function to delete a Zorba_SerializerOptions_t struct
00228  *
00229  * \retval Zorba_CompilerHints_t with default member values
00230  */
00231 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_free(Zorba_SerializerOptions_t* serializerOptions);
00232 
00233 /** \brief Helper function to set an option in a Zorba_SerializerOptions_t structure
00234  *
00235  * \param serializerOptions serializer options
00236  * \param parameter the serializer parameter to be configured
00237  * \param value the value to which the parameter should be set
00238  * \retval Zorba_CompilerHints_t with default member values
00239  */
00240 ZORBA_DLL_PUBLIC void Zorba_SerializerOptions_set(Zorba_SerializerOptions_t* serializerOptions, const char* parameter, const char* value);
00241 
00242 
00243 #ifdef __cplusplus
00244 }
00245 #endif
00246 
00247 #endif
00248 
00249 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus