00001 /* Copyright (c) 2006, Gennady Bystritsky <bystr@mac.com> 00002 * 00003 * Distributed under the MIT Licence. 00004 * This is free software. See 'LICENSE' for details. 00005 * You must read and accept the license prior to use. 00006 */ 00007 00008 #ifndef _SK_IO_BYTEARRAYOUTPUTSTREAM_ 00009 #define _SK_IO_BYTEARRAYOUTPUTSTREAM_ 00010 00011 #include <sk/io/AbstractOutputStream.h> 00012 #include <vector> 00013 00014 namespace sk { 00015 namespace io { 00016 class ByteArrayOutputStream 00017 : public sk::io::AbstractOutputStream 00018 { 00019 public: 00020 ByteArrayOutputStream(std::vector<char>& buffer); 00021 virtual ~ByteArrayOutputStream(); 00022 00023 // sk::util::Object re-implementation. 00024 const sk::util::Class getClass() const; 00025 00026 // sk::io::OutputStream implementation. 00027 int write(const char* buffer, int offset, int length); 00028 using AbstractOutputStream::write; 00029 void close(); 00030 00031 private: 00032 ByteArrayOutputStream(const ByteArrayOutputStream& other); 00033 ByteArrayOutputStream& operator = (const ByteArrayOutputStream& other); 00034 00035 std::vector<char>& _buffer; 00036 bool _closed; 00037 }; 00038 } 00039 } 00040 00041 #endif /* _SK_IO_BYTEARRAYOUTPUTSTREAM_ */