use std::ostream/std::ostringstream instead of StringStream