00001 #ifndef _STR_X_H 00002 #define _STR_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: StrX.h,v 1.1 2004/12/16 13:36:44 sharring Exp $" 00025 * 00026 * who when what 00027 * -------- -------- ---------------------------------------------- 00028 * sharring 11/16/04 created 00029 */ 00030 00031 #include <xercesc/util/XMLString.hpp> 00032 00033 #ifndef __cplusplus 00034 #error This is a C++ include file and cannot be used from plain C 00035 #endif 00036 00037 #if defined(XERCES_NEW_IOSTREAMS) 00038 #include <iostream> 00039 #else 00040 #include <iostream.h> 00041 #endif 00042 00043 XERCES_CPP_NAMESPACE_USE 00044 00045 // --------------------------------------------------------------------------- 00046 // This is a simple class that lets us do easy (though not terribly efficient) 00047 // trancoding of XMLCh data to local code page for display. 00048 // --------------------------------------------------------------------------- 00049 class StrX 00050 { 00051 public : 00052 // ----------------------------------------------------------------------- 00053 // Constructors and Destructor 00054 // ----------------------------------------------------------------------- 00055 StrX(const XMLCh* const toTranscode) 00056 { 00057 // Call the private transcoding method 00058 fLocalForm = XMLString::transcode(toTranscode); 00059 } 00060 00061 ~StrX() 00062 { 00063 XMLString::release(&fLocalForm); 00064 } 00065 00066 00067 // ----------------------------------------------------------------------- 00068 // Getter methods 00069 // ----------------------------------------------------------------------- 00070 const char* localForm() const 00071 { 00072 return fLocalForm; 00073 } 00074 00075 00076 private : 00077 // ----------------------------------------------------------------------- 00078 // Private data members 00079 // 00080 // fLocalForm 00081 // This is the local code page form of the string. 00082 // ----------------------------------------------------------------------- 00083 char* fLocalForm; 00084 }; 00085 00086 inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump) 00087 { 00088 target << toDump.localForm(); 00089 return target; 00090 } 00091 #endif