Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 155 lines (122 sloc) 4.379 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
/*
* Copyright (C) 2002-2010 XimpleWare, info@ximpleware.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef VTDGEN_H
#define VTDGEN_H

//#include "customTypes.h"
#include "fastLongBuffer.h"
#include "fastIntBuffer.h"
#include "vtdNav.h"
#include "UTF8Char.h"
#include "XMLChar.h"
#include "decoder.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>


// define document encoding

// other constants

#define ATTR_NAME_ARRAY_SIZE 16
#define TAG_STACK_SIZE 256
#define MAX_DEPTH 254
#define MAX_TOKEN_LENGTH ((1<<20)-1)
#define MAX_PREFIX_LENGTH ((1<<9)-1)
#define MAX_QNAME_LENGTH ((1<<11)-1)

typedef struct vTDGen {
int ns,is_ns;
int VTDDepth;
encoding_t encoding;
int last_depth;
int last_l1_index;
int last_l2_index;
int last_i3_index;

int increment;
Boolean BOM_detected;
Boolean must_utf_8;
int ch;
int ch_temp;

int offset;
Boolean ws;
int temp_offset;
int length1,length2;
int depth;

int prev_offset;
int rootIndex;
UByte* XMLDoc; // byte buffer containing
int docLen; // length of XML (can be a segment of XMLDoc)
int bufLen; // length of XMLDoc (possibly bigger than docLen)

// buffers
FastLongBuffer *VTDBuffer;
FastLongBuffer *l1Buffer;
FastLongBuffer *l2Buffer;
FastIntBuffer *l3Buffer;

FastIntBuffer *nsBuffer1;
FastLongBuffer *nsBuffer2;
    FastLongBuffer *nsBuffer3;
Long currentElementRecord;

Boolean br;//buffer reuse flag
Boolean stateTransfered; // indicate whether VTDNav has received all LC and VTD buffers

int endOffset;
Long* tag_stack;
Long* attr_name_array;
int attr_count;
Long* prefixed_attr_name_array;
int* prefix_URL_array;
int prefixed_attr_count;
int anaLen;
int panaLen;
int docOffset;
} VTDGen;

// create VTDGen
VTDGen *createVTDGen();

// free VTDGen
void freeVTDGen(VTDGen *vg);

// clear the internal state of VTDGen so it can process
// the next XML file
void clear(VTDGen *vg);

// Returns the VTDNav object after parsing, it also cleans
// internal state so VTDGen can process the next file.
VTDNav *getNav(VTDGen *vg);

// Generating VTD tokens and Location cache info.
// One specifies whether the parsing is namespace aware or not.
void parse(VTDGen *vg, Boolean ns);

// Generating VTD tokens and Location cache info for an XML file
Boolean parseFile(VTDGen *vg, Boolean ns,char *fileName);

// Set the XMLDoc container.
void setDoc(VTDGen *vg, UByte *byteArray, int arrayLen);

// Set the XMLDoc container.Also set the offset and len of the document
void setDoc2(VTDGen *vg, UByte *byteArray, int arrayLen, int offset, int docLen);

// set the XML Doc container and turn on buffer reuse
void setDoc_BR(VTDGen *vg, UByte *byteArray, int arrayLen);

//Set the XMLDoc container.Also set the offset and len of the document
void setDoc_BR2(VTDGen *vg, UByte *byteArray, int arrayLen, int offset, int docLen);

/* Load VTD+XML from a FILE pointer */
VTDNav* loadIndex(VTDGen *vg, FILE *f);

/* load VTD+XML from a byte array */
VTDNav* loadIndex2(VTDGen *vg, UByte* ba,int len);

/* Write VTD+XML into a FILE pointer */
Boolean writeIndex(VTDGen *vg, FILE *f);

/* Write VTD+XML into a file of given name, this file will be created on hard disk */
Boolean writeIndex2(VTDGen *vg, char *fileName);

/* Pre-calculate the integrated VTD+XML index size without generating the actual index */
Long getIndexSize(VTDGen *vg);

/* Write the VTDs and LCs into an file*/
void writeSeparateIndex(VTDGen *vg, char *vtdIndex);

/* Load the separate VTD index and XmL file.*/
VTDNav* loadSeparateIndex(VTDGen *vg, char *XMLFile, char *VTDIndexFile);

/* configure the VTDGen to enable or disable (disabled by default) white space nodes */
void enableIgnoredWhiteSpace(VTDGen *vg, Boolean b);

#endif
Something went wrong with that request. Please try again.