• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

ParamStrX.h

Go to the documentation of this file.
00001 #ifndef _PARAMSTR_X_H
00002 #define _PARAMSTR_X_H
00003 /*******************************************************************************
00004 *    ALMA - Atacama Large Millimiter Array
00005 *    (c) Associated Universities Inc., 2002 
00006 *    (c) European Southern Observatory, 2002
00007 *    Copyright by ESO (in the framework of the ALMA collaboration)
00008 *    and Cosylab 2002, All rights reserved
00009 *
00010 *    This library is free software; you can redistribute it and/or
00011 *    modify it under the terms of the GNU Lesser General Public
00012 *    License as published by the Free Software Foundation; either
00013 *    version 2.1 of the License, or (at your option) any later version.
00014 *
00015 *    This library 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 GNU
00018 *    Lesser General Public License for more details.
00019 *
00020 *    You should have received a copy of the GNU Lesser General Public
00021 *    License along with this library; if not, write to the Free Software
00022 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00023 *
00024 * "@(#) $Id: ParamStrX.h,v 1.1 2010/04/27 12:20:58 htischer Exp $"
00025 *
00026 * who       when      what
00027 * --------  --------  ----------------------------------------------
00028 * sharring  11/16/04  created
00029 */
00030 
00031 #include <xercesc/util/XercesDefs.hpp>
00032 #include <xercesc/util/XMLString.hpp>
00033 
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037 
00038 #if defined(XERCES_NEW_IOSTREAMS)
00039 #include <iostream>
00040 #else
00041 #include <iostream.h>
00042 #endif
00043 
00044 namespace Parameters {
00045 
00046         //using XERCES_CPP_NAMESPACE_QUALIFIER XMLString;
00047 
00048         // ---------------------------------------------------------------------------
00049         //  This is a simple class that lets us do easy (though not terribly efficient)
00050         //  trancoding of XMLCh data to local code page for display.
00051         // ---------------------------------------------------------------------------
00052         class StrX
00053         {
00054                 public :
00055 
00056                 // -----------------------------------------------------------------------
00057                 //  Constructors and Destructor
00058                 // -----------------------------------------------------------------------
00059                 StrX(const char* const toTranscode)
00060                 {
00061                         // Call the private transcoding method
00062                         fUnicodeForm = XERCES_CPP_NAMESPACE::XMLString::transcode(toTranscode);
00063                         fLocalForm =  XERCES_CPP_NAMESPACE::XMLString::transcode(fUnicodeForm);
00064                 }
00065 
00066                 StrX(const XMLCh * const toTranscode)
00067                 {
00068                         // Call the private transcoding method
00069                         fLocalForm =  XERCES_CPP_NAMESPACE::XMLString::transcode(toTranscode);
00070                         fUnicodeForm = XERCES_CPP_NAMESPACE::XMLString::transcode(fLocalForm);
00071                 }
00072 
00073                 ~StrX()
00074                 {
00075                         if(NULL != fLocalForm) {
00076                                 XERCES_CPP_NAMESPACE::XMLString::release(&fLocalForm);
00077                         }
00078                         if(NULL != fUnicodeForm) {
00079                                 XERCES_CPP_NAMESPACE::XMLString::release(&fUnicodeForm);
00080                         }
00081                 }
00082 
00083 
00084                 // -----------------------------------------------------------------------
00085                 //  Getter methods
00086                 // -----------------------------------------------------------------------
00087                 const char* localForm() const
00088                 {
00089                         return fLocalForm;
00090                 }
00091 
00092                 const XMLCh* unicodeForm() const
00093                 {
00094                         return fUnicodeForm;
00095                 }
00096 
00097 
00098                 private :
00099 
00100                 // -----------------------------------------------------------------------
00101                 //  Private data members
00102                 //
00103                 //  fLocalForm
00104                 //      This is the local code page form of the string.
00105                 // -----------------------------------------------------------------------
00106                 char*   fLocalForm;
00107                 XMLCh*  fUnicodeForm;
00108         };
00109 
00110         inline XERCES_STD_QUALIFIER ostream& operator<<(std::ostream& target, const Parameters::StrX& toDump)
00111         {
00112                 if(NULL != toDump.localForm()) {
00113                         target << toDump.localForm();
00114                 }
00115                 else if(NULL != toDump.unicodeForm()) {
00116                         target << toDump.unicodeForm();
00117                 }
00118                 return target;
00119         }
00120 }
00121 
00122 #endif 

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0