Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / XML

VTD-XML: XML Processing for the Future (Part I)

Rate me:
Please Sign up or sign in to vote.
4.50/5 (17 votes)
17 Apr 2008CPOL10 min read 96K   1.1K   59  
Introduce VTD-XML, the future of XML processing
/* 
 * Copyright (C) 2002-2008 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 LONGBUFFER_H
#define LONGBUFFER_H
// Header file for FastLongBuffer
// Long is a 64 bit int, so in C it is really long long
#include "arrayList.h"
#include "customTypes.h"
#include <stdlib.h>

typedef struct fastLongBuffer{
	ArrayList *al;
	int capacity;
	int exp;
	int pageSize;
	int r;
	int size;
} FastLongBuffer;


// create FastLongBuffer with default page size of 1024 longs 
FastLongBuffer *createFastLongBuffer();

// create FastLongBuffer with page size of (1<<e) longs
FastLongBuffer *createFastLongBuffer2(int e);

// create FastLongBuffer with page size of (1<<e) longs and initial capciaty of c longs
FastLongBuffer *createFastLongBuffer3(int e, int c);

// free FastLongBuffer 
void freeFastLongBuffer(FastLongBuffer *flb);

// append a long array to the end of FastLongBuffer
void appendLongArray(FastLongBuffer *flb, Long *longArray, int len);

// append a long to the end of FastLongBuffer
void appendLong(FastLongBuffer *flb, Long i);

// get the capacity of FastLongBuffer
//int getCapacityFLB(FastLongBuffer *flb);
#define getCapacityFLB(flb) flb->capacity

// Return a selected chuck of long buffer as a long array.
Long *getLongArray(FastLongBuffer *flb, int offset, int len);

// get the page size of FastLongBuffer
//int getPageSizeFLB(FastLongBuffer *flb);
#define getPageSizeFLB(flb) flb->pageSize

// get the long at the index position from FastLongBuffer
//Long longAt(FastLongBuffer *flb, int index);
extern inline Long longAt(FastLongBuffer *flb, int index);

// get the lower 32 bits from the index position from FastLongBuffer
extern inline int lower32At(FastLongBuffer *flb, int index);


// get the upper 32 bits from the index position from FastLongBuffer 
extern inline int upper32At(FastLongBuffer *flb, int index);

// replace the entry at the index position of FastLongBuffer with l
extern inline void modifyEntryFLB(FastLongBuffer *flb, int index, Long l);

// convert FastLongBuffer into a Long array 
Long* toLongArray(FastLongBuffer *flb);

// set the buffer size to zero, capacity untouched,
void clearFastLongBuffer (FastLongBuffer *flb);

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer XimpleWare
United States United States
Jimmy Zhang is a cofounder of XimpleWare, a provider of high performance XML processing solutions. He has working experience in the fields of electronic design automation and Voice over IP for a number of Silicon Valley high-tech companies. He holds both a BS and MS from the department of EECS from U.C. Berkeley.

Comments and Discussions