[[藤井のスタートページ]]

* C++のiostream [#fafbd692]
** C++のiostreamの感想など、、 [#a35196fb]
- [[C++のiostream感想-その1-]]
- [[C++のiostream感想-その2-]]
- [[C++のiostream感想-その3-]] - rdbuf() の謎
- [[C++のiostream感想-その3-]]  rdbuf() の謎

** C++ iostream の実装 [#h411c29c]
TCP/IP で connect した socket を iostream 化する実装例を示す。
- [[C++ iostream 実装例 その 1]] - 1 octet 入出力だけで書いてみる
- [[C++ iostream 実装例 その 2]] - streambuf を iostream で使う
- [[C++ iostream 実装例 その 3]] - buffer 利用で streambuf と連携
- [[C++ iostream 実装例 その 4]] - backup 列の導入
- [[C++ iostream 実装例 その 5]] - streambuf から iostream への考察
- [[C++ iostream 実装例 その 6]] - iostream化 への streambuf 追加機能
- [[C++ iostream 実装例 その 7]] - iostream化

実装にあたって規格を読んでの考察や規格の抜粋、(私の)解釈を示す。
- [[C++ iostream 実装資料1]]
- [[C++ iostream 実装資料2]]
- [[C++ iostream 実装資料3]]

** その他、雑メモ [#eaf4862e]
- [[標準入出力のバイナリモード]]
- [[iostream と streambuf]]
- [[tcp を C++ iostream 化する]]
- [[getline()とget()]]
- [[iostreamの例外の制御]]
- [[tcp を iostream化して速度を比較]]

大雑把に言うと
- iostream(istream、ostream も)は基本的に
入出力を streambuf で行っている。つまり入出力は実はstreambuf が本体。
- streambuf と iostream を結びつけるのは iostream の constractor。
iostream の constractor は streambuf object の pointer を引数に持つ。

実際には streambuf も iostream も template なので、

 template <class Ch, class Tr=std::char_traits<Ch> >
 class basic_mystrembuf : basic_streambuf<Ch, Tr>
 {
 public:
   basic_mystream()
   virtual ~basic_mystream();
       :
 };

 template <class Ch, class Tr=std::char_traits<Ch> >
 class basic_mystream : public std::basic_iostream<Ch,Tr>
 {
 public:  
   basic_mystream() 
        : std::basic_iostream<Ch,Tr>(new basic_mystreambuf<Ch,Tr>())
   {
   }
 
   ~basic_mystream()
   {
   }
 };

 typedef basic_mystreambuf<char> mystreambuf;
 typedef basic_mystream<char> mystream;

とすればよいらしい。でも fstream を覗いてみると、ifstream と ofstream も
作っているようだ。

C++でiostreamを拡張したい時の参考 URL。当初、参考にしよう
としたが、結局は規格を調べざるを得なかった(上記「実証資料」の項
参照)。
- http://www.jah.ne.jp/~naoyuki/Writings/ExtIos.html
- http://www.kab-studio.biz/Programing/Codian/iostream/06.html

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS