XercesEncodings.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 #ifndef XERCES_ENCODINGS_HXX
00022 #define XERCES_ENCODINGS_HXX
00023 
00024 
00025 #include <xercesc/util/XMLString.hpp>
00026 
00027 namespace xercesc=XERCES_CPP_NAMESPACE;
00028 
00029 namespace CLAM
00030 {
00035 class XercesLocal2Unicode
00036 {
00037 public :
00038         XercesLocal2Unicode(const char* const toTranscode)
00039         {
00040                 // Call the private transcoding method
00041                 _unicodeForm = xercesc::XMLString::transcode(toTranscode);
00042         }
00043 
00044         ~XercesLocal2Unicode()
00045         {
00046                 xercesc::XMLString::release(&_unicodeForm);
00047         }
00048 
00049         const XMLCh* unicodeForm() const
00050         {
00051                 return _unicodeForm;
00052         }
00053 
00054 private :
00055         XMLCh*   _unicodeForm;
00056 };
00057 
00062 class XercesUnicode2Local
00063 {
00064 public :
00065         XercesUnicode2Local(const XMLCh* const toTranscode)
00066         {
00067                 // Call the private transcoding method
00068                 _localForm = xercesc::XMLString::transcode(toTranscode);
00069         }
00070 
00071         ~XercesUnicode2Local()
00072         {
00073                 xercesc::XMLString::release(&_localForm);
00074         }
00075 
00076         const char* localForm() const
00077         {
00078                 return _localForm;
00079         }
00080 
00081 private :
00082         char*   _localForm;
00083 };
00084 
00085 #define U(str) ::CLAM::XercesLocal2Unicode(str).unicodeForm()
00086 #define L(str) ::CLAM::XercesUnicode2Local(str).localForm()
00087 
00088 }
00089 
00090 #endif// XERCES_ENCODINGS_HXX
00091 
Generated by  doxygen 1.6.3