1 /* -*- c++ -*- */ 2 /* 3 * Copyright (C) 2010 The Android Open Source Project 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef ANDROID_ASTL_BASIC_IOS_H__ 31 #define ANDROID_ASTL_BASIC_IOS_H__ 32 33 #include <ios_base.h> 34 35 namespace std { 36 37 // basic_ios holds the streambuf instance used to perform th I/O 38 // operations. 39 // A concrete stream implementation does its work and calls rdbuf() to 40 // access the streambuf when it is ready to output the date (if the 41 // stream is an ostream). 42 // The standard says that basic_ios should deal with the state of the 43 // stream (good,eof,fail, etc), currently this is not implemented. 44 45 class streambuf; 46 class basic_ios: public ios_base { 47 public: 48 typedef int io_state; 49 typedef int open_mode; 50 typedef int seek_dir; 51 typedef std::streampos streampos; 52 typedef std::streamoff streamoff; 53 54 protected: 55 basic_ios(); 56 57 public: 58 // No op, does NOT destroy mStreambuf. 59 virtual ~basic_ios(); 60 61 /** 62 * Change the unlying buffer. 63 * @param sb The new buffer. 64 * @return The previous stream buffer. 65 */ 66 streambuf* rdbuf(streambuf *sb); 67 /** 68 * @return the underlying buffer associated with this stream. 69 */ 70 streambuf* rdbuf() const { return mStreambuf; } 71 72 protected: 73 void init(streambuf* sb); 74 streambuf* mStreambuf; 75 }; 76 77 } // namespace std 78 79 #endif 80