//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ using System; using System.Collections; using System.IO; namespace Ilog.Language.Tools { /** * A (very) primitive debugging class. * * @version Last modified on Mon May 23 11:25:20 2005 by hak * @author Hassan Aït-Kaci * @copyright © 2000 ILOG, S.A. */ public class Debug { public Debug () { Step(); } public Debug (object o) { Step(o); } private static bool debugFlag; public static bool DebugFlag { get { return debugFlag; } set { debugFlag = value; } } private static int step = 0; private static string quitString = "quit"; public static string QuitString { get { return quitString; } set { quitString = value; } } /** * Returns true iff the specified string is a non-empty * prefix of the quit string. */ public static bool MatchesQuitString (string s) { return s.Length > 0 && quitString.StartsWith(s); } /** * Returns true iff the specified string is the quit string. */ public static bool IsQuitString (string s) { return s.Equals(quitString); } public static void StepIfFlag (object info) { if (debugFlag) Step(info); } /** * Prompts the user using the specified info and returns * the string entered by the user. */ public static string Step (object info) { Console.Error.WriteLine ("\n-------------------------------------------------------------------"); string msg = info is IList ? Misc.ListToString((IList)info) : info.ToString(); return Misc.Prompt(msg+"\nSTEP ["+(++step)+"] >",Console.Error); } public static string Step () { return Step(""); } } }