00001 /*
00002 * This file is one big nasty kludge because the older
00003 * libstdc++ libraries (before v3) have the old strstream
00004 * but I want to use the new, and much improved sstream.
00005 * - Barnaby
00006 *
00007 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00008 *
00009 * This library is free software; you can redistribute it and/or
00010 * modify it under the terms of the GNU Lesser General Public
00011 * License as published by the Free Software Foundation; either
00012 * version 2.1 of the License, or (at your option) any later version.
00013 *
00014 * This library is distributed in the hope that it will be useful,
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 * Lesser General Public License for more details.
00018 *
00019 * You should have received a copy of the GNU Lesser General Public
00020 * License along with this library; if not, write to the Free Software
00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 *
00023 */
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #ifdef HAVE_SSTREAM
00030 # include <sstream>
00031 #elif HAVE_STRSTREAM
00032 # define USE_STRSTREAM_WRAPPERS
00033 #else
00034 # error "No sstream/strstream implementation"
00035 #endif
00036
00037 #if defined(USE_STRSTREAM_WRAPPERS) && !defined(SSTREAM_FIX_H)
00038 #define SSTREAM_FIX_H
00039
00040 #include <string>
00041 #include <strstream>
00042
00043 namespace std
00044 {
00045
00046 /*
00047 * Only limited functionality from ostringstream
00048 * is implemented
00049 */
00050 class ostringstream : public ostrstream {
00051 public:
00052 string str() {
00053 char *cstr = ostrstream::str();
00054 freeze(0);
00055 if (cstr == 0) return string();
00056 return string(cstr,pcount());
00057 }
00058 };
00059
00060 /*
00061 * Only limited functionality from istringstream
00062 * is implemented
00063 */
00064 class istringstream : public istrstream {
00065 public:
00066 istringstream(const string& str)
00067 : istrstream(str.c_str()) { }
00068 };
00069
00070 }
00071
00072 #endif
1.2.16