xmlsrv_plat/cxml_library_api/inc/nw_wbxml_document.h
branchRCL_3
changeset 20 889504eac4fb
equal deleted inserted replaced
19:6bcc0aa4be39 20:889504eac4fb
       
     1 /*
       
     2 * Copyright (c) 2000 - 2001 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /** ----------------------------------------------------------------------- **
       
    20     @package:     NW_WBXML
       
    21 
       
    22     @synopsis:    default
       
    23 
       
    24     @description: Definitions for WBXML document header
       
    25 
       
    26  ** ----------------------------------------------------------------------- **/
       
    27 
       
    28 #ifndef NW_PARSER_WBXML_DOCUMENT_H
       
    29 #define NW_PARSER_WBXML_DOCUMENT_H
       
    30 
       
    31 #include <xml/cxml/cxml_proj.h>
       
    32 #include <xml/cxml/nw_string_string.h>
       
    33 #include <xml/cxml/nw_encoder_stringtable.h>
       
    34 
       
    35 #ifdef __cplusplus
       
    36 extern "C" {
       
    37 #endif /* __cplusplus */
       
    38 
       
    39 
       
    40 /** ----------------------------------------------------------------------- **
       
    41     @struct:      NW_WBXML_StringTable
       
    42 
       
    43     @synopsis:    WBXML document string table.
       
    44 
       
    45     @scope:       public
       
    46     @variables:
       
    47        NW_Uint32 length
       
    48                   Length of table.
       
    49 
       
    50        NW_Byte* data
       
    51                   The table.
       
    52 
       
    53     @description: WBXML document string table.
       
    54  ** ----------------------------------------------------------------------- **/
       
    55 typedef struct NW_WBXML_StringTable_s {
       
    56   NW_Uint32 length;
       
    57   NW_Byte* data;
       
    58 }NW_WBXML_StringTable_t;
       
    59 
       
    60 
       
    61 /** ----------------------------------------------------------------------- **
       
    62     @struct:       NW_WBXML_Document
       
    63 
       
    64     @synopsis:    The document structure that describes the header of the 
       
    65                   current document.
       
    66 
       
    67     @scope:       public
       
    68     @variables:
       
    69        NW_Uint8 version
       
    70                   The version.
       
    71 
       
    72        NW_Uint32 publicid
       
    73                   The public ID.
       
    74 
       
    75        NW_String_t* doc_type
       
    76                   The document type.
       
    77 
       
    78        NW_Uint32 default_public_id
       
    79                   The public ID.
       
    80 
       
    81        NW_Uint32 charset
       
    82                   The charset (i.e. encoding)
       
    83 
       
    84        struct strtbl
       
    85                   WBXML document string table.
       
    86 
       
    87        NW_Uint32 body_len
       
    88                   Length of document.
       
    89 
       
    90        NW_Encoder_StringTable_t* strtbl_extension
       
    91                   Extension string table.
       
    92 
       
    93     @description: The document structure.
       
    94  ** ----------------------------------------------------------------------- **/
       
    95 typedef struct NW_WBXML_Document_s {
       
    96   NW_Uint8 version;
       
    97   NW_Uint32 publicid;
       
    98   NW_String_t* doc_type;
       
    99   NW_Uint32 default_public_id;
       
   100   NW_Uint32 charset;
       
   101   struct NW_WBXML_StringTable_s strtbl;
       
   102   NW_Uint32 body_len;
       
   103   /* When a document is modified, the extended table is created. */
       
   104   /* check what its being used for */
       
   105   NW_Encoder_StringTable_t* strtbl_extension;
       
   106 } NW_WBXML_Document_t;
       
   107 
       
   108 
       
   109 
       
   110 /* ----------------------------------------------------------------------- **
       
   111    Document methods 
       
   112 ** ----------------------------------------------------------------------- **/
       
   113 
       
   114 
       
   115 /** ----------------------------------------------------------------------- **
       
   116     @function:    NW_WBXML_Document_construct
       
   117 
       
   118     @synopsis:    Constructor.
       
   119 
       
   120     @scope:       public
       
   121 
       
   122     @parameters:
       
   123        [out] NW_WBXML_Document_t* doc
       
   124                   The document
       
   125 
       
   126        [in] NW_Uint32 default_public_id
       
   127                   The public ID.
       
   128 
       
   129     @description: Constructor.
       
   130 
       
   131     @returns:     NW_Status_t
       
   132                   Status of operation.
       
   133 
       
   134        [NW_STAT_SUCCESS]
       
   135                   Document constructed.
       
   136 
       
   137        [NW_STAT_FAILURE]
       
   138                   Document not constructed.
       
   139 
       
   140  ** ----------------------------------------------------------------------- **/
       
   141 IMPORT_C NW_Status_t
       
   142 NW_WBXML_Document_construct(NW_WBXML_Document_t* doc,
       
   143                             NW_Uint32 default_public_id);
       
   144 
       
   145 
       
   146 /** ----------------------------------------------------------------------- **
       
   147     @function:    NW_WBXML_Document_destruct
       
   148 
       
   149     @synopsis:    Destructor.
       
   150 
       
   151     @scope:       public
       
   152 
       
   153     @parameters:
       
   154        [in] NW_WBXML_Document_t* doc
       
   155                   The document.
       
   156 
       
   157     @description: Destructor.
       
   158  ** ----------------------------------------------------------------------- **/
       
   159 IMPORT_C void 
       
   160 NW_WBXML_Document_destruct (NW_WBXML_Document_t* doc);
       
   161 
       
   162 
       
   163 /** ----------------------------------------------------------------------- **
       
   164     @function:    NW_WBXML_Document_getTableString
       
   165 
       
   166     @synopsis:    Get table string using index.
       
   167 
       
   168     @scope:       public
       
   169 
       
   170     @parameters:
       
   171        [in] NW_WBXML_Document_t* doc
       
   172                   default
       
   173 
       
   174        [in] NW_Uint32 index
       
   175                   default
       
   176 
       
   177        [out] NW_String_t* s
       
   178                   default
       
   179 
       
   180     @description: Get table string using index.
       
   181 
       
   182     @returns:     NW_Status_t
       
   183                   Status of operation.
       
   184 
       
   185        [NW_STAT_SUCCESS]
       
   186                   Table returned.
       
   187 
       
   188        [NW_STAT_WBXML_ERROR_BYTECODE]
       
   189                   Can't find table.
       
   190 
       
   191        [NW_STAT_WBXML_ERROR_CHARSET_UNSUPPORTED]
       
   192                   Encoding not supported.
       
   193 
       
   194        [NW_STAT_FAILURE]
       
   195                   General error.
       
   196 
       
   197  ** ----------------------------------------------------------------------- **/
       
   198 IMPORT_C NW_Status_t 
       
   199 NW_WBXML_Document_getTableString(NW_WBXML_Document_t* doc, 
       
   200                                  NW_Uint32 index, NW_String_t* s);
       
   201 
       
   202 
       
   203 /** ----------------------------------------------------------------------- **
       
   204     @function:    NW_WBXML_Document_putTableString
       
   205 
       
   206     @synopsis:    Store table string returning index.
       
   207 
       
   208     @scope:       public
       
   209 
       
   210     @parameters:
       
   211        [in] NW_WBXML_Document_t* doc
       
   212                   The document.
       
   213 
       
   214        [in] NW_String_t* string
       
   215                   Addition to table.
       
   216 
       
   217        [out] NW_Uint32* index
       
   218                   Index of last entry in table after addition.
       
   219 
       
   220     @description: String table write method.  Writing a dom tree may
       
   221                   require adding strings to the string table, if one
       
   222                   exists, or creating a string table if none exists.
       
   223                   We create an extended table using the encoder
       
   224                   string table write methods if this is
       
   225                   necessary. Unfortunately, there can be some
       
   226                   duplication of strings between the two tables, because
       
   227                   there is no efficient way to look up a string by name
       
   228                   in the real string table. Therefore, any string that
       
   229                   gets added to the table gets added to the extension
       
   230                   table.  The encoder takes care of rationalizing the
       
   231                   two tables if the document gets rewritten as wbxml.
       
   232                   If the string is not already in the table, this method
       
   233                   adds it. The out parameter index returns the index of
       
   234                   the string in the extension table, offset by the size
       
   235                   of the real string table so that extension table
       
   236                   strings always have indexes bigger than real table
       
   237                   strings.
       
   238 
       
   239     @returns:     NW_Status_t
       
   240                   Status of operation.
       
   241 
       
   242        [NW_STAT_SUCCESS]
       
   243                   Table added.
       
   244 
       
   245        [NW_STAT_BAD_INPUT_PARAM]
       
   246                   Required parameter is NULL.
       
   247 
       
   248        [NW_STAT_OUT_OF_MEMORY]
       
   249                   Out of memory.
       
   250 
       
   251  ** ----------------------------------------------------------------------- **/
       
   252 IMPORT_C NW_Status_t
       
   253 NW_WBXML_Document_putTableString(NW_WBXML_Document_t* doc, 
       
   254                                  NW_String_t* string, 
       
   255                                  NW_Uint32* index);
       
   256 
       
   257 /** ----------------------------------------------------------------------- **
       
   258     @function:    NW_WBXML_Document_getVersion
       
   259 
       
   260     @synopsis:    Get document version.
       
   261 
       
   262     @scope:       public
       
   263 
       
   264     @parameters:
       
   265        [in] NW_WBXML_Document_t* document
       
   266                   The document.
       
   267 
       
   268     @description: Gets the WBXML version number.
       
   269 
       
   270     @returns:     NW_Uint8
       
   271                   The WBXML version number.
       
   272 
       
   273  ** ----------------------------------------------------------------------- **/
       
   274 NW_Uint8
       
   275 NW_WBXML_Document_getVersion(NW_WBXML_Document_t* document);
       
   276 
       
   277 
       
   278 /** ----------------------------------------------------------------------- **
       
   279     @function:    NW_WBXML_Document_getPublicID
       
   280 
       
   281     @synopsis:    Get document publicID.
       
   282 
       
   283     @scope:       public
       
   284 
       
   285     @parameters:
       
   286        [in] NW_WBXML_Document_t* document
       
   287                   The document.
       
   288 
       
   289     @description: Gets the WBXML public ID. 
       
   290 
       
   291     @returns:     NW_Uint32
       
   292                   The WBXML public ID.
       
   293 
       
   294  ** ----------------------------------------------------------------------- **/
       
   295 NW_Uint32
       
   296 NW_WBXML_Document_getPublicID(NW_WBXML_Document_t* document);
       
   297 
       
   298 
       
   299 /** ----------------------------------------------------------------------- **
       
   300     @function:    NW_WBXML_Document_getDocType
       
   301 
       
   302     @synopsis:    Get document type.
       
   303 
       
   304     @scope:       public
       
   305 
       
   306     @parameters:
       
   307        [in] NW_WBXML_Document_t* document
       
   308                   The document.
       
   309 
       
   310     @description: Get document type.
       
   311 
       
   312     @returns:     NW_String_t*
       
   313                   The address of the document type string stored in the 
       
   314                   document header. The caller must not free this string. 
       
   315 
       
   316  ** ----------------------------------------------------------------------- **/
       
   317 NW_String_t*
       
   318 NW_WBXML_Document_getDocType(NW_WBXML_Document_t* document);
       
   319 
       
   320 
       
   321 /** ----------------------------------------------------------------------- **
       
   322     @function:    NW_WBXML_Document_getEncoding
       
   323 
       
   324     @synopsis:    Get document encoding.
       
   325 
       
   326     @scope:       public
       
   327 
       
   328     @parameters:
       
   329        [in] NW_WBXML_Document_t* document
       
   330                   The document.
       
   331 
       
   332     @description: Gets the string encoding used in a document.
       
   333 
       
   334     @returns:     NW_Uint32
       
   335                   One of the string encoding constants defined in the 
       
   336                   WBXML specification. The XML engine defines the following
       
   337                   constants.
       
   338 
       
   339  ** ----------------------------------------------------------------------- **/
       
   340 NW_Uint32
       
   341 NW_WBXML_Document_getEncoding(NW_WBXML_Document_t* document);
       
   342 
       
   343 #ifdef __cplusplus
       
   344 } /* extern "C" { */
       
   345 #endif /* __cplusplus */
       
   346 
       
   347 #endif  /* NW_PARSER_WBXML_DOCUMENT_H */