adbrown85/edo — Issue #13: Scanner ctor should take istream
Author: adbrown85
Created: 2011-12-15 04:04:13+00:00
State: open

Currently _Scanner_ is handling different types of input sources by having two different constructors; one for a file and one for a string. Ideally we could use named constructors like _fromFile_ and _fromString_ that both take _std::string_, but since in C++ that would require us enabling the copy constructor or assignment operator, assuming we don't want to return a pointer, it may be best to just have one constructor that takes an input stream. That way the client could create whatever stream they wish, pass it to the scanner, and it would just work.

We're not sure if the scanner should take a pointer or a reference to the stream though. Internally the scanner will have to store a pointer, obviously, so pointer makes sense, but that means we also have to check it and we're opening ourselves up to bad addresses. Taking a reference would be nice because _Scanner_ was meant to be a one-time use object that's allocated on the stack anyway, and that would help to suggest the stream would be defined right along side it.