Stream-based IO
关于stream,参见工程discrete的Relation-structure-computation\Model\Stream
章节。
Stream抽象了数据的流动(流出、流入),stream模型可以抽象 input/output device,它能够抽象file、network device、custom adaptor device,所以使用stream模型构建的程序,允许我们实现使用抽象的stream来完成对多种device的IO。这个思想就是abstraction思想。
stream模型基本上统治了IO领域:
- 在Everything-is-a-file中,我们其实已经探讨了linux的file descriptor其实代表的就是一个stream,它使用的就是stream模型,并且维基百科Everything is a file描述的思想和上一段中的思想一致。
- C++的Input/output library就是基于stream模型创建的。
IO即输入、输出,就是典型的可以使用stream来进行描述的。
wikipedia Stream (computing) # Examples
2) On Unix and related systems based on the C language, a stream is a source or sink of data, usually individual bytes or characters. Streams are an abstraction used when reading or writing files, or communicating over network sockets. The standard streams are three streams made available to all programs.
3) I/O devices can be interpreted as streams, as they produce or consume potentially unlimited data over time.
wikipedia C file input/output
C++ IO library
参见工程programming-language的C-family-language\C++\Library\Standard-library\IO-library
章节。