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 
00019 /** \brief The optimization level used for optimizing the query. */
00020 typedef enum {
00021   ZORBA_OPT_LEVEL_O0, /**< Don't use any optimization. */
00022   ZORBA_OPT_LEVEL_O1  /**< Use basic optimizations 
00023                            (e.g.\ removing sorting, removing duplicate elimination, 
00024                            or constant folding). */
00025 } Zorba_opt_level_t;
00026 
00027 /** \brief Set of hints that can be passed to the query compiler.
00028  *
00029  * An instance of this class can be passed to the compileQuery function
00030  * of the Zorba class or the compile function of this class.
00031  * The members of this class represent hints that are passed to the
00032  * query compiler. For example, whether optimization of the query
00033  * should be done (O1) or not (O0).
00034  *
00035  * example_6 in file \link simple.cpp \endlink shows an example
00036  * how CompilerHints can be used.
00037  */
00038 typedef struct Zorba_CompilerHints {
00039   /** \brief The optimization level that is used */
00040   Zorba_opt_level_t opt_level;
00041 #ifdef __cplusplus
00042   /** \brief Default constructor for CompilerHints which assigns default values to all hints (C++ only).
00043    *
00044    * Default values:
00045    *   - optimization level: O1 
00046    */
00047   Zorba_CompilerHints();
00048 #endif
00049 } Zorba_CompilerHints_t;
00050 
00051 typedef enum {
00052   ZORBA_SERIALIZATION_METHOD_XML, 
00053   ZORBA_SERIALIZATION_METHOD_HTML
00054 } Zorba_serialization_method_t;
00055 
00056 typedef enum {
00057   ZORBA_BYTE_ORDER_MARK_YES, 
00058   ZORBA_BYTE_ORDER_MARK_NO
00059 } Zorba_byte_order_mark_t;
00060 
00061 typedef enum {
00062   ZORBA_ESCAPE_URI_ATTRIBUTES_YES, 
00063   ZORBA_ESCAPE_URI_ATTRIBUTES_NO
00064 } Zorba_escape_uri_attributes_t;
00065 
00066 typedef enum {
00067   ZORBA_INCLUDE_CONTENT_TYPE_YES, 
00068   ZORBA_INCLUDE_CONTENT_TYPE_NO
00069 } Zorba_include_content_type_t;
00070 
00071 typedef enum {
00072   ZORBA_INDENT_YES, 
00073   ZORBA_INDENT_NO
00074 } Zorba_indent_t;
00075 
00076 typedef enum {
00077   ZORBA_NORMALIZATION_FORM_NFC, 
00078   ZORBA_NORMALIZATION_FORM_NFD, 
00079   ZORBA_NORMALIZATION_FORM_NFKC, 
00080   ZORBA_NORMALIZATION_FORM_NFKD, 
00081   ZORBA_NORMALIZATION_FORM_FULLY_normalized, 
00082   ZORBA_NORMALIZATION_FORM_NONE
00083 } Zorba_normalization_form_t;
00084 
00085 typedef enum {
00086   ZORBA_OMIT_XML_DECLARATION_YES, 
00087   ZORBA_OMIT_XML_DECLARATION_NO
00088 } Zorba_omit_xml_declaration_t;
00089 
00090 typedef enum {
00091   ZORBA_STANDALONE_YES, 
00092   ZORBA_STANDALONE_NO, 
00093   ZORBA_STANDALONE_OMIT
00094 } Zorba_standalone_t;
00095 
00096 typedef enum {
00097   ZORBA_UNDECLARE_PREFIXES_YES, 
00098   ZORBA_UNDECLARE_PREFIXES_NO
00099 } Zorba_undeclare_prefixes_t;
00100 
00101 /** \brief Options that configure the serialization process of a query result.
00102 *         See http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/.
00103 *
00104 * This struct defines options that can be passed to the serialization process of a query
00105 * result. An instance of this class can be passed to the serialize function.
00106 *
00107 * File \link serialization.cpp \endlink contains examples that show how to use
00108 * the SerializerOptions.
00109 */
00110 typedef struct Zorba_SerializerOptions {
00111   Zorba_serialization_method_t  ser_method;
00112   Zorba_byte_order_mark_t       byte_order_mark;
00113   Zorba_escape_uri_attributes_t escape_uri_attributes;
00114   Zorba_include_content_type_t  include_content_type;
00115   Zorba_indent_t                indent;
00116   Zorba_normalization_form_t    normalization_form;
00117   Zorba_omit_xml_declaration_t  omit_xml_declaration;
00118   Zorba_standalone_t            standalone; 
00119   Zorba_undeclare_prefixes_t    undeclare_prefixes;
00120 
00121   /** \brief Default constructor for SerializerOptions which assigns default values to all 
00122    *         options (C++ only).
00123    *
00124    * Default values:
00125    *   - serialization method: XML
00126    *   - byte-order-mark: NO
00127    *   - esacpe-uri-attributes: NO
00128    *   - include-content-type: NO
00129    *   - indent: NO
00130    *   - normalization-form: none
00131    *   - omit-xml-declaration: NO
00132    *   - standalone: omit
00133    *   - undeclare-prefixes: NO
00134    */
00135 #ifdef __cplusplus
00136   Zorba_SerializerOptions();
00137 #endif
00138 } Zorba_SerializerOptions_t;
00139 
00140 
00141 
00142 #ifdef __cplusplus
00143 extern "C" {
00144 #endif
00145 
00146 /** \brief Helper function for C to create a Zorba_CompilerHints_t struct 
00147  *         because of missing default constructor. 
00148  *
00149  * \retval Zorba_CompilerHints_t with default member values 
00150  */
00151 Zorba_CompilerHints_t Zorba_CompilerHints_default();
00152 
00153 /** \brief Helper function for C to create a Zorba_SerializerOptions_t struct 
00154  *         because of missing default constructor. 
00155  *
00156  * \retval Zorba_CompilerHints_t with default member values 
00157  */
00158 Zorba_SerializerOptions_t Zorba_SerializerOptions_default();
00159 
00160 #ifdef __cplusplus
00161 }
00162 #endif
00163 
00164 #endif
00165