/* Copyright (C) 2004 Garrett A. Kajmowicz This file is part of the uClibc++ Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #ifdef __UCLIBCXX_HAS_WCHAR__ #include #include #endif #ifndef __HEADER_STD_STRING_IOSTREAM #define __HEADER_STD_STRING_IOSTREAM 1 namespace std{ template _UCXXEXPORT basic_ostream& operator<<(basic_ostream& os, const basic_string& str) { return os.write(str.data(), str.length()); } template _UCXXEXPORT basic_istream& operator>>(basic_istream& is, basic_string& str) { typename basic_istream::sentry s(is); if(s == false){ return is; } str.clear(); typename basic_istream::int_type c; typename Allocator::size_type n = is.width(); bool exitnow = false; if(n == 0){ n = str.max_size(); } // //Clear out preliminary spaces first // c = is.get(); // while(isspace(c)){ // c = is.get(); // } // // is.putback(c); do{ c = is.get(); if(c == traits::eof() || isspace(c) || n == 0){ is.putback(c); exitnow = true; }else{ str.append(1, traits::to_char_type(c) ); --n; } }while(exitnow == false); return is; } template _UCXXEXPORT basic_istream& getline(basic_istream& is, basic_string& str, charT delim) { typename basic_istream::sentry s(is); if(s == false){ return is; } str.erase(); streamsize i = 0; typename basic_istream::int_type c_i; charT c; unsigned int n = str.max_size(); for(i=0;i _UCXXEXPORT basic_istream& getline(basic_istream& is, basic_string& str) { return getline(is, str, '\n'); } #ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ #ifndef __UCLIBCXX_COMPILE_STRING__ #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ template<> _UCXXEXPORT basic_istream >& operator>>( basic_istream >& is, basic_string, allocator >& str); #endif #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ template<> _UCXXEXPORT basic_ostream >& operator<<(basic_ostream >& os, const basic_string, std::allocator >& str); #endif #endif #endif } #endif