xmlReader.h

Go to the documentation of this file.
00001 
00004 /* the present version relies on libxml++
00005 */
00006 
00007 /* Copyright (C) 2005 - 2006, Bernd Speiser */
00008 /* This file is part of BSUtilities.
00009 
00010 BSUtilities is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 BSUtilities is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019   
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00023 02111-1307, USA.
00024 */
00025 
00026 
00027 #ifndef _xmlReader_h
00028 #define _xmlReader_h
00029 
00030 #include "BSUtilitiesError.h"
00031 
00032 #include <tinyxml/tinyxml.h>
00033 
00034 #include <string>
00035 
00036 namespace BSUtilities {
00038   namespace xmlr {
00039 
00041 
00044 class XmlReadError : public BSUtilitiesError
00045 {
00046 private:
00048   static const std::string XMLREADERROR;
00049 
00050 public:
00052 
00054   XmlReadError (void) : BSUtilitiesError (XMLREADERROR) {}
00055 
00057 
00059   XmlReadError (const std::string message)
00060                                          : BSUtilitiesError (message) {}
00061 };
00062 
00063 TiXmlHandle xmlInit (const std::string &filename);
00064 
00065 void xmlFinish (TiXmlHandle &element);
00066 
00068 
00072 template<class X>
00073   void xmlLoad (const std::string &filename, X &obj)
00074   {
00075     TiXmlHandle root = xmlInit (filename);
00076     obj.load (root);
00077     xmlFinish (root);
00078   }
00079 
00080 
00081   } // end namespace xmlr
00082 }
00083 #endif /* _xmlReader_h */

Generated on Sun Jul 26 16:51:58 2009 for BSUtilities by  doxygen 1.5.3