Main Page Modules Class Hierarchy Compound List File List Compound Members

# saxparser.h

    00001 //==========================================================================
    00002 //   SAXPARSER.H -
    00003 //            part of OMNeT++
    00004 //
    00005 //==========================================================================
    00006
    00007 /*--------------------------------------------------------------*
    00008   Copyright (C) 2002-2003 Andras Varga
    00009
    00010   This file is distributed WITHOUT ANY WARRANTY. See the file
    00011   `license' for details on this and other legal matters.
    00012 *--------------------------------------------------------------*/
    00013
    00014
    00015
    00016 #ifndef __SAXPARSER_H
    00017 #define __SAXPARSER_H
    00018
    00019 #include <stdio.h>
    00020
    00021 class SAXParser;
    00022
    00023
    00034 class SAXHandler
    00035 {
    00036     friend class SAXParser;
    00037   protected:
    00038     SAXParser *parser;
    00039     virtual void setParser(SAXParser *p) {parser=p;}
    00040
    00041   public:
    00045     SAXHandler() {parser=0;}
    00046
    00050     virtual ~SAXHandler() {}
    00051
    00055     virtual void startElement(const char *name, const char **atts)  {}
    00056
    00060     virtual void endElement(const char *name)  {}
    00061
    00065     virtual void characterData(const char *s, int len)  {}
    00066
    00070     virtual void processingInstruction(const char *target, const char *data)  {}
    00071
    00075     virtual void comment(const char *data)  {}
    00076
    00080     virtual void startCdataSection()  {}
    00081
    00085     virtual void endCdataSection()  {}
    00086 };
    00087
    00088
    00096 class SAXParser
    00097 {
    00098   protected:
    00099     char errortext[512];
    00100     SAXHandler *saxhandler;
    00101     void *currentparser;
    00102
    00103   public:
    00107     SAXParser();
    00108
    00112     void setHandler(SAXHandler *sh);
    00113
    00118     int parse(FILE *f);
    00119
    00123     int getCurrentLineNumber();
    00124 };
    00125
    00126 #endif
    00127