]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/input.cpp
Add files
[libs/datafile.git] / source / input.cpp
diff --git a/source/input.cpp b/source/input.cpp
new file mode 100644 (file)
index 0000000..5b2d63b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+This file is part of libmspparser
+Copyright © 2006 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+#include "input.h"
+
+namespace Msp {
+namespace Parser {
+
+Input::Input(std::istream &i):
+       in(i),
+       line(1),
+       next(-1)
+{ }
+
+int Input::get()
+{
+       int c=next;
+       next=-1;
+       if(c<0) c=in.get();
+       
+       if(c=='\n')
+               ++line;
+
+       return c;
+}
+
+int Input::peek()
+{
+       if(next<0)
+               next=in.get();
+       return next;
+}
+
+} // namespace Parser
+} // namespace Msp