tools.hxx

00001 // tools.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2007, 2008 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 //
00017 
00018 #ifndef VCSN_XML_TOOLS_HXX
00019 # define VCSN_XML_TOOLS_HXX
00020 
00021 # include <vaucanson/xml/strings.hh>
00022 
00023 namespace vcsn
00024 {
00025   namespace xml
00026   {
00027     namespace tools
00028     {
00033       inline
00034       bool
00035       has_attribute (const xercesc::Attributes& attrs,
00036                      const char* key,
00037                      const XMLCh* const uri)
00038       {
00039         return (get_attribute(attrs, key, uri) != 0);
00040       }
00041 
00042       inline
00043       const XMLCh*
00044       get_attribute (const xercesc::Attributes& attrs,
00045                      const char* key,
00046                      const XMLCh* const uri)
00047       {
00048         XMLCh* xkey = transcode(key);
00049         const XMLCh* tmp = attrs.getValue(uri, xkey);
00050         xercesc::XMLString::release(&xkey);
00051         return tmp;
00052       }
00053 
00057       void
00058       set_attribute (xercesc::DOMElement* e,
00059                      const std::string& k, const std::string& v)
00060       {
00061         if (v != "")
00062           e->setAttribute (transcode(k), transcode(v));
00063       }
00067       xercesc::DOMElement*
00068       create_element(xercesc::DOMDocument* doc,
00069                      const std::string& e)
00070       {
00071         return doc->createElement(transcode(e));
00072       }
00073     } // !tools
00074   } // !xml
00075 } // !vcsn
00076 
00077 #endif // !VCSN_XML_TOOLS_HXX

Generated on Thu Oct 9 20:22:42 2008 for Vaucanson by  doxygen 1.5.1