Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ustl::fdistringstream Class Reference
[Device Streams]

A string stream that reads from an fd. Implements cin. More...

#include <ustl.h>

Inheritance diagram for ustl::fdistringstream:

ustl::istringstream ustl::istream ustl::cmemlink List of all members.

Public Member Functions

 fdistringstream (int fd)
 Constructs a stream to read from fd.

Protected Member Functions

virtual size_t underflow (size_t n=1)

Detailed Description

A string stream that reads from an fd. Implements cin.

I would discourage the use of cin in general. As a quick-n-dirty hack to read a configuration file it is ok, but if you want to do real user input, it becomes much less acceptable. The problem is not really the implementation, but the way it is used, expecting the completely unverified information coming from the user to be magically converted to numbers, strings, etc. Bounds checking and filter adaptors like utf8 are damn hard to do directly over cin. Furthermore, you are sitting there, blocking on user input, when you could be doing something useful. Instead, implement a nonblocking block reading routine (I cannot provide you with one, since it depends on your event framework), which reads all available data and sends it through a series of validation filters. UTF8 format checking should be done this way for maximum simplicity. Then later you can use istringstream directly on the buffer, which allows you to restart reading in case of errors, for instance, whereas cin will simply drop the offending characters (this implementation will keep some, but you are not supposed to know that). Anyway, this class is here only because it is really very very small and does next to nothing.


The documentation for this class was generated from the following files:
Generated on Mon Jan 17 14:35:02 2005 for uSTL by 1.3.9 Doxygen Hosted on SourceForge.net