Rewrite C++ part

RMID #55 Let the user choose output (either file or stdout).
RMID #56 Use stream class instead of hack "stuff" macro.