Main Page | File List | File Members

parser.h File Reference

SCEW parser type declaration. More...

#include "types.h"
#include <expat.h>
#include <stdio.h>

Go to the source code of this file.

Functions

scew_parserscew_parser_create ()
void scew_parser_free (scew_parser *parser)
unsigned int scew_parser_load_file (scew_parser *parser, char const *file_name)
unsigned int scew_parser_load_file_fp (scew_parser *parser, FILE *in)
unsigned int scew_parser_load_buffer (scew_parser *parser, char const *buffer, unsigned int size)
unsigned int scew_parser_load_stream (scew_parser *parser, char const *buffer, unsigned int size)
void scew_parser_set_stream_callback (scew_parser *parser, SCEW_CALLBACK *cb)
scew_treescew_parser_tree (scew_parser const *parser)
XML_Parser scew_parser_expat (scew_parser *parser)
void scew_parser_ignore_whitespaces (scew_parser *parser, int ignore)


Detailed Description

SCEW parser type declaration.

Author:
Aleix Conchillo Flaque <aleix@member.fsf.org>
Date:
Mon Nov 25, 2002 00:57
Id
parser.h,v 1.2 2004/05/25 20:23:05 aleix Exp

These are the parser functions that allow to read an XML tree from a file or a memory buffer.


Function Documentation

scew_parser* scew_parser_create  ) 
 

Creates a new parser. The parser is needed to load XML documents.

void scew_parser_free scew_parser parser  ) 
 

Frees a parser memory structure. This function will not free the scew_tree generated by the parser, so it is important that you keep a pointer to it and remember to free it.

See also:
scew_tree_free

unsigned int scew_parser_load_file scew_parser parser,
char const *  file_name
 

Loads an XML tree from the specified file name using the given parser.

Parameters:
parser the SCEW parser.
file_name the file to load the XML from.
See also:
scew_parser_create
Returns:
1 if file was successfully loaded, 0 otherwise.

unsigned int scew_parser_load_file_fp scew_parser parser,
FILE *  in
 

Loads an XML tree from the specified file pointer using the given parser.

Parameters:
parser the SCEW parser.
in the file pointer to load the XML from.
See also:
scew_parser_create
Returns:
1 if file was successfully loaded, 0 otherwise.

unsigned int scew_parser_load_buffer scew_parser parser,
char const *  buffer,
unsigned int  size
 

Loads an XML tree from the specified memory buffer of the specified size using the given parser.

Parameters:
parser the SCEW parser.
buffer memory buffer to load XML from.
size size in bytes of the memory buffer.
See also:
scew_parser_create
Returns:
1 if buffer was successfully loaded, 0 otherwise.

unsigned int scew_parser_load_stream scew_parser parser,
char const *  buffer,
unsigned int  size
 

Loads an XML tree from the specified stream buffer. Will call the callback (set using scew_parser_set_stream_callback) at the end of each message.

Parameters:
parser the SCEW parser.
buffer memory buffer to load XML from.
size size in bytes of the memory buffer.
See also:
scew_parser_create

scew_parser_set_stream_callback

Returns:
1 if buffer was successfully loaded, 0 otherwise.

void scew_parser_set_stream_callback scew_parser parser,
SCEW_CALLBACK cb
 

Sets the callback for use when reading streams.

Parameters:
parser the SCEW parser
cb the callback function

scew_tree* scew_parser_tree scew_parser const *  parser  ) 
 

Returns the XML tree read by the parser. Remember that scew_parser_free does not free the scew_tree read.

See also:
tree.h

XML_Parser scew_parser_expat scew_parser parser  ) 
 

Returns the internal Expat parser. Probably some low-level Expat functions need to be called. This function gives you access to the Expat parser so you will be able to call those functions. If you modify the Expat parser event handling routines, SCEW will not be able to load the XML tree.

void scew_parser_ignore_whitespaces scew_parser parser,
int  ignore
 

Tells the parser how to treat white spaces. The default is to ignore heading and trailing white spaces.

There is a new section in XML specification which talks about how to handle white spaces in XML. One can set an optional attribtue to an element, this attribute is called 'xml:space', and it can be set to 'default' or 'preserve', and it inherits its value from parent elements. 'preserve' means to leave white spaces as their are found, and 'default' means that white spaces are handled by the XML processor (Expat in our case) the way it wants to.

This function gives the possibility to change the XML processor behaviour.

Parameters:
parser the parser to set the option to.
ignore 0 if you do not want to ignore white spaces, any other value otherwise.


Generated on Tue May 25 23:38:29 2004 for Simple C Expat Wrapper by doxygen 1.3.7