]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/qstd.h
Require Qt version 4.8.4
[bacula/bacula] / bacula / src / qt-console / qstd.h
1 #ifndef QSTD_H
2 #define QSTD_H
3
4 #include <QTextStream>
5 #include <QFile>
6 #include <QString>
7
8 /** @short helper objects and functions which help reduce the
9        need for char[] and the standard library.  
10
11     defines three @ref QTextStream instances
12     which behave like the c++ standard iostreams, bound to the
13     standard in/out/error. 
14     
15     Also provided, some helper functions for writing
16     interactive stdin/stdout applications.
17 */
18 //start
19 namespace qstd {
20
21     /** @short  An alias for standard input
22      */
23     extern QTextStream cin;  /* declared only, defined in the .cpp file */
24     /** @short  An alias for standard output
25      */
26     extern QTextStream cout;
27     /** @short  An alias for standard error
28      */
29     extern QTextStream cerr;
30     /** yes/no prompt
31         interactive stdin UI - prompts user with
32         a yes/no question. Repeatedly-asks
33         until user supplies a valid answer.
34  
35         @param yesNoQuestion the yes/no question
36         @return true/false depending on what the
37         user responded.
38     */
39     bool yes(QString yesNoQuestion);
40     /** Convenience function that feeds a  specific question
41         to the yes() function.
42         @usage do {.....} while(more ("foobar"));
43         so that user sees the question: "Another foobar (y/n)? "
44         @param name of the item being handled by the loop.
45     */
46     bool more(QString prompt);
47     /** A function for safely taking an int from the keyboard.
48         Takes data into a  QString and tests to make sure it
49         can be converted to int before returning.
50         @param base allows choice of number base.
51         @return returns validated int.
52     */
53     int promptInt(int base = 10);
54     /** A function for safely taking a double from the keyboard.
55         Takes data into a  QString and tests to make sure it
56         can be converted to double before returning.
57         @return returns validated int.
58     */
59     double promptDouble();
60     /** Complete dialog for opening a file for output.
61         Asks user for file name, checks to see if
62         file already exists and, if so, asks the user if
63         it is ok to overwrite.
64         @param Reference QFile parameter is set to point
65         to the (eventually) opened file.
66     */
67     /** @short Dialog for a output file prompt
68      */
69     void promptOutputFile(QFile& outfile);
70
71     /** @short Dialog for input file prompt */
72     void promptInputFile(QFile& infile);
73     
74     
75 //end
76 }
77
78 #endif
79