Goby Underwater Autonomy Project
Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
|
00001 // copyright 2008, 2009 t. schneider tes@mit.edu 00002 // 00003 // this file is part of goby-acomms, a collection of libraries for acoustic underwater networking 00004 // 00005 // This program is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This software is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this software. If not, see <http://www.gnu.org/licenses/>. 00017 00018 // this xml code based largely on work in C++ Cookbook by D. Ryan Stephens, Christopher Diggins, Jonathan Turkanis, and Jeff Cogswell. Copyright 2006 O'Reilly Media, INc., 0-596-00761-2. 00019 00020 // these functions define an easy way to convert from and to the XercesString 00021 // unicode format to the native (ASCII in our case) string format. 00022 00023 #ifndef XERCES_STRINGS20091211H 00024 #define XERCES_STRINGS20091211H 00025 00026 #include <string> 00027 00028 #include <boost/scoped_ptr.hpp> 00029 #include <xercesc/util/XMLString.hpp> 00030 00031 // typedef std::basic_string<XMLCh> XercesString; 00032 00033 /* // Converts from a narrow-character string to a wide-character string. */ 00034 inline const XMLCh* fromNative(const char* str) 00035 { 00036 return xercesc::XMLString::transcode(str); 00037 } 00038 00039 /* // Converts from a narrow-character string to a wide-charactr string. */ 00040 /* inline XercesString fromNative(const std::string& str) */ 00041 /* { */ 00042 /* return fromNative(str.c_str()); */ 00043 /* } */ 00044 00045 // Converts from a wide-character string to a narrow-character string. 00046 inline std::string toNative(const XMLCh* str) 00047 { 00048 boost::scoped_ptr<char> ptr(xercesc::XMLString::transcode(str)); 00049 return std::string(ptr.get()); 00050 } 00051 00052 /* // Converts from a wide-character string to a narrow-character string. */ 00053 /* inline std::string toNative(const XercesString& str) */ 00054 /* { */ 00055 /* return toNative(str.c_str()); */ 00056 /* } */ 00057 00058 #endif // #ifndef XERCES_STRINGS_HPP_INCLUDED