00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef SH_MSG_H
00022
#define SH_MSG_H
00023
00024
#include <cstdarg>
00025
#include <string>
00026
00027 class MessageBase {
00028
public:
00029
MessageBase (
void) ;
00030
MessageBase (std::string msg) ;
00031
MessageBase (
const char* msgfmt, ...) ;
00032 virtual ~MessageBase() {} ;
00033
00034 const std::string&
getMessage (
void)
const
00035
{
return Message ; } ;
00036
00037 void setMessage (std::string msg)
00038 {
Message = msg ; } ;
00039
00044 void setNewline (
bool prnl)
00045 {
Newline = prnl ; } ;
00046
00050 const std::string
getNewline (
void)
const
00051
{
return (
Newline ?
"\n" :
"") ; } ;
00052
00053
void setMessage (
const char *msgfmt, ...) ;
00054
virtual void printMessage (
void) const = 0 ;
00055
00056 protected:
00057 static const
unsigned int MsgMaxSize = 512 ;
00058
00059 std::string compose (const
char *msgfmt, ...) const ;
00060 std::string vcompose (const
char *msgfmt, va_list ap) const ;
00061
00062 private:
00063 std::string
Message ;
00064 bool Newline ;
00065 } ;
00066
00067 class Message : public
MessageBase {
00068
public:
00069 Message (
void) : MessageBase() {} ;
00070 Message (std::string msg) : MessageBase (msg) {} ;
00071 Message (
const char *msgfmt, ...) ;
00072
00073
void printMessage (
void) const ;
00074 } ;
00075
00076 class
VerboseMessage : public MessageBase {
00077
public:
00078 VerboseMessage (
void) : MessageBase() {} ;
00079 VerboseMessage (std::string msg) : MessageBase (msg) {} ;
00080
VerboseMessage (
const char *msgfmt, ...) ;
00081
00082
void printMessage (
void) const ;
00083 } ;
00084
00085 class
Warning : public MessageBase {
00086
public:
00087 Warning (
void) : MessageBase() {} ;
00088 Warning (std::string msg) : MessageBase (msg) {} ;
00089
Warning (
const char *msgfmt, ...) ;
00090
00091
void printMessage (
void) const ;
00092 } ;
00093
00094 class
CriticalWarning : public MessageBase {
00095
public:
00096 CriticalWarning (
void) : MessageBase() {} ;
00097 CriticalWarning (std::string msg) : MessageBase (msg) {} ;
00098
CriticalWarning (
const char *msgfmt, ...) ;
00099
00100
void printMessage (
void) const ;
00101 } ;
00102
00103 class
Question : public MessageBase {
00104
public:
00105
Question (
void) ;
00106
Question (std::string msg) ;
00107
Question (
const char *msgfmt, ...) ;
00108
00109
void printMessage (
void)
const ;
00110
00115
bool getAnswer (
void) ;
00116
00117
private:
00118 std::string yeschar ;
00119 std::string nochar ;
00120 } ;
00121
00122
#endif