console.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Kenneth Gangstoe
00028 **    Mark Page
00029 */
00030 
00033 
00034 #pragma once
00035 
00036 // 'kbhit' was declared deprecated
00037 #ifdef WIN32
00038 #pragma warning(disable: 4996)
00039 #endif
00040 
00041 #include "../api_core.h"
00042 #include "string_format.h"
00043 #include "string_help.h"
00044 #ifdef WIN32
00045 #include <conio.h>
00046 #else
00047 #include <unistd.h>
00048 #endif
00049 
00053 class CL_Console
00054 {
00057 
00058 public:
00060         static void write(const CL_StringRef &text);
00061 
00062         template <class Arg1>
00063 
00068         static void write(const CL_StringRef &format, Arg1 arg1)
00069         {
00070                 CL_StringFormat f(format);
00071                 f.set_arg(1, arg1);
00072                 write(f.get_result());
00073         }
00074 
00075         template <class Arg1, class Arg2>
00076 
00082         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2)
00083         {
00084                 CL_StringFormat f(format);
00085                 f.set_arg(1, arg1);
00086                 f.set_arg(2, arg2);
00087                 write(f.get_result());
00088         }
00089 
00090         template <class Arg1, class Arg2, class Arg3>
00091 
00098         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3)
00099         {
00100                 CL_StringFormat f(format);
00101                 f.set_arg(1, arg1);
00102                 f.set_arg(2, arg2);
00103                 f.set_arg(3, arg3);
00104                 write(f.get_result());
00105         }
00106 
00107         template <class Arg1, class Arg2, class Arg3, class Arg4>
00108 
00116         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
00117         {
00118                 CL_StringFormat f(format);
00119                 f.set_arg(1, arg1);
00120                 f.set_arg(2, arg2);
00121                 f.set_arg(3, arg3);
00122                 f.set_arg(4, arg4);
00123                 write(f.get_result());
00124         }
00125 
00126         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00127 
00136         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
00137         {
00138                 CL_StringFormat f(format);
00139                 f.set_arg(1, arg1);
00140                 f.set_arg(2, arg2);
00141                 f.set_arg(3, arg3);
00142                 f.set_arg(4, arg4);
00143                 f.set_arg(arg5);
00144                 write(f.get_result());
00145         }
00146 
00147         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
00148 
00158         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
00159         {
00160                 CL_StringFormat f(format);
00161                 f.set_arg(1, arg1);
00162                 f.set_arg(2, arg2);
00163                 f.set_arg(3, arg3);
00164                 f.set_arg(4, arg4);
00165                 f.set_arg(arg5);
00166                 f.set_arg(arg6);
00167                 write(f.get_result());
00168         }
00169 
00170         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
00171 
00182         static void write(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7)
00183         {
00184                 CL_StringFormat f(format);
00185                 f.set_arg(1, arg1);
00186                 f.set_arg(2, arg2);
00187                 f.set_arg(3, arg3);
00188                 f.set_arg(4, arg4);
00189                 f.set_arg(arg5);
00190                 f.set_arg(arg6);
00191                 f.set_arg(arg7);
00192                 write(f.get_result());
00193         }
00194 
00196         static void write_line(const CL_StringRef &text)
00197         {
00198                 write(text);
00199         #ifdef WIN32
00200                 write("\r\n");
00201         #else
00202                 write("\n");
00203         #endif
00204         }
00205 
00206         template <class Arg1>
00207 
00212         static void write_line(const CL_StringRef &format, Arg1 arg1)
00213         {
00214                 CL_StringFormat f(format);
00215                 f.set_arg(1, arg1);
00216                 write_line(f.get_result());
00217         }
00218 
00219         template <class Arg1, class Arg2>
00220 
00226         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2)
00227         {
00228                 CL_StringFormat f(format);
00229                 f.set_arg(1, arg1);
00230                 f.set_arg(2, arg2);
00231                 write_line(f.get_result());
00232         }
00233 
00234         template <class Arg1, class Arg2, class Arg3>
00235 
00242         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3)
00243         {
00244                 CL_StringFormat f(format);
00245                 f.set_arg(1, arg1);
00246                 f.set_arg(2, arg2);
00247                 f.set_arg(3, arg3);
00248                 write_line(f.get_result());
00249         }
00250 
00251         template <class Arg1, class Arg2, class Arg3, class Arg4>
00252 
00260         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
00261         {
00262                 CL_StringFormat f(format);
00263                 f.set_arg(1, arg1);
00264                 f.set_arg(2, arg2);
00265                 f.set_arg(3, arg3);
00266                 f.set_arg(4, arg4);
00267                 write_line(f.get_result());
00268         }
00269 
00270         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00271 
00280         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
00281         {
00282                 CL_StringFormat f(format);
00283                 f.set_arg(1, arg1);
00284                 f.set_arg(2, arg2);
00285                 f.set_arg(3, arg3);
00286                 f.set_arg(4, arg4);
00287                 f.set_arg(5, arg5);
00288                 write_line(f.get_result());
00289         }
00290 
00291         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
00292 
00302         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
00303         {
00304                 CL_StringFormat f(format);
00305                 f.set_arg(1, arg1);
00306                 f.set_arg(2, arg2);
00307                 f.set_arg(3, arg3);
00308                 f.set_arg(4, arg4);
00309                 f.set_arg(5, arg5);
00310                 f.set_arg(6, arg6);
00311                 write_line(f.get_result());
00312         }
00313 
00314         template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
00315 
00326         static void write_line(const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7)
00327         {
00328                 CL_StringFormat f(format);
00329                 f.set_arg(1, arg1);
00330                 f.set_arg(2, arg2);
00331                 f.set_arg(3, arg3);
00332                 f.set_arg(4, arg4);
00333                 f.set_arg(5, arg5);
00334                 f.set_arg(6, arg6);
00335                 f.set_arg(7, arg7);
00336                 write_line(f.get_result());
00337         }
00338 
00342         static void wait_for_key();
00343 
00345 };
00346