diff orange/util/io.d @ 1:11a31bd929f9

Removed dependency on private library
author Jacob Carlborg <doob@me.com>
date Mon, 31 May 2010 16:06:36 +0200
parents f7b078e85f7f
children 99c52d46822a
line wrap: on
line diff
--- a/orange/util/io.d	Wed May 26 17:19:13 2010 +0200
+++ b/orange/util/io.d	Mon May 31 16:06:36 2010 +0200
@@ -1,3 +1,82 @@
+/**
+ * Copyright: Copyright (c) 2007-2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2007
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ * 
+ */
 module orange.util.io;
 
-public import mambo.io;
\ No newline at end of file
+version (Tango)
+{
+	import tango.io.Stdout;
+	import tango.io.Console;
+	
+	import orange.util.string;
+}
+
+else 
+	import std.stdio;
+
+/**
+ * Print to the standard output
+ * 
+ * Params:
+ *     args = what to print
+ */
+void print (A...)(A args)
+{
+	version (Tango)
+	{
+		const string fmt = "{}{}{}{}{}{}{}{}"
+					        "{}{}{}{}{}{}{}{}"
+					        "{}{}{}{}{}{}{}{}";
+				
+		static assert (A.length <= fmt.length / 2, "mambo.io.print :: too many arguments");
+		
+		Stdout.format(fmt[0 .. args.length * 2], args).flush;
+	}
+		
+	
+	else
+		foreach(t ; a)
+			writef(t);
+}
+
+/**
+ * Print to the standard output, adds a new line
+ * 
+ * Params:
+ *     args = what to print
+ */
+void println (A...)(A args)
+{
+	version (Tango)
+	{
+		const string fmt = "{}{}{}{}{}{}{}{}"
+					        "{}{}{}{}{}{}{}{}"
+					        "{}{}{}{}{}{}{}{}";
+
+		static assert (A.length <= fmt.length / 2, "mambo.io.println :: too many arguments");
+		
+		Stdout.formatln(fmt[0 .. args.length * 2], args);
+	}
+
+	else
+	{
+		foreach(t ; args)
+			writef(t);
+		
+		writef("\n");
+	}
+}
+
+/**
+ * Read from the standard input
+ * 
+ * Returns: what was read
+ */
+string read ()
+{
+	return Cin.get;
+}