Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

pana_xml_parser.h

00001 /* BEGIN_COPYRIGHT                                                        */
00002 /*                                                                        */
00003 /* Open Diameter: Open-source software for the Diameter and               */
00004 /*                Diameter related protocols                              */
00005 /*                                                                        */
00006 /* Copyright (C) 2002-2004 Open Diameter Project                          */
00007 /*                                                                        */
00008 /* This library is free software; you can redistribute it and/or modify   */
00009 /* it under the terms of the GNU Lesser General Public License as         */
00010 /* published by the Free Software Foundation; either version 2.1 of the   */
00011 /* License, or (at your option) any later version.                        */
00012 /*                                                                        */
00013 /* This library is distributed in the hope that it will be useful,        */
00014 /* but WITHOUT ANY WARRANTY; without even the implied warranty of         */
00015 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      */
00016 /* Lesser General Public License for more details.                        */
00017 /*                                                                        */
00018 /* You should have received a copy of the GNU Lesser General Public       */
00019 /* License along with this library; if not, write to the Free Software    */
00020 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307    */
00021 /* USA.                                                                   */
00022 /*                                                                        */
00023 /* In addition, when you copy and redistribute some or the entire part of */
00024 /* the source code of this software with or without modification, you     */
00025 /* MUST include this copyright notice in each copy.                       */
00026 /*                                                                        */
00027 /* If you make any changes that are appeared to be useful, please send    */
00028 /* sources that include the changed part to                               */
00029 /* diameter-developers@lists.sourceforge.net so that we can reflect your  */
00030 /* changes to one unified version of this software.                       */
00031 /*                                                                        */
00032 /* END_COPYRIGHT                                                          */
00033 
00034 #ifndef __XML_PARSER_H__
00035 #define __XML_PARSER_H__
00036 
00037 #include <string>
00038 #include <xercesc/dom/DOM.hpp>
00039 #include "ace/OS.h"
00040 
00041 #if defined(XERCES_HAS_CPP_NAMESPACE)
00042 using namespace xercesc;
00043 #endif
00044 
00045 class PANA_XMLElementParser {
00046    public:
00047       PANA_XMLElementParser(std::string &tagName);
00048       virtual ~PANA_XMLElementParser() { }
00049 
00050       virtual int svc(DOMNode *n) = 0;
00051 
00052       std::string &name() { return name_; }
00053 
00054       int populate(DOMNode *n, DOMNode **found = NULL);
00055 
00056       char *getTextContent(DOMNode *n);
00057 
00058    protected:
00059       std::string name_;
00060 };
00061 
00062 class PANA_XMLTreeParser {
00063    public:
00064       int open(std::string &filename, PANA_XMLElementParser &root);
00065       void close();
00066 };
00067 
00068 class PANA_XMLDataString : public PANA_XMLElementParser {
00069    public:
00070       PANA_XMLDataString(std::string &name, std::string &data) : 
00071                        PANA_XMLElementParser(name),
00072                        payload(data) { }
00073 
00074       virtual int svc(DOMNode *n);
00075 
00076    protected:
00077       std::string &payload;
00078 };
00079 
00080 class PANA_XMLDataUInt32 : public PANA_XMLElementParser {
00081    public:
00082       PANA_XMLDataUInt32(std::string &name, ACE_UINT32 &data) : 
00083                          PANA_XMLElementParser(name),
00084                          payload(data) { }
00085 
00086       virtual int svc(DOMNode *n);
00087 
00088    protected:
00089       ACE_UINT32 &payload;
00090 };
00091 
00092 #endif // __XML_PARSER_H__

Generated on Fri Jun 25 19:18:30 2004 for PANA by doxygen 1.3.5