/*$cb
 *    This file is a part of libopenmhp.
 *
 *    Copyright (C) 2005 Mikko Novaro <miknov@gmail.com>
 *
 *    See main header file (libopenmhp/openmhp.h) for licensing and
 *    contact information.
 $ce*/

#ifndef _PARSER_HPP_
#define _PARSER_HPP_

#include <stdio.h>

enum eSegmentType {
  EMPTY,
  START_TAG,
  END_TAG,
  COMBO_TAG,
  PC_DATA,
  ERROR
};

/* SAX like xml parser. Largely incomplete, and has no error handling
 * to speak of. */
class cXMLParser {
private:
  FILE *in;
  // may hold the next character of the XML input:
  int readLeftover;
  // Read next XML bit into a provided buffer, and return its type:
  eSegmentType ReadSegment(char *buffer, int bf_size);
public:
  cXMLParser(const char *filename);
  virtual ~cXMLParser(void);
  // return error code
  int Parse(void);

  virtual void Characters(const char *ch, int len);
  virtual void StartElement(const char *name, const char **attrs); // use of attributes isn't implemented
  virtual void EndElement(const char *name);
};

#endif
