00001
00002 #ifndef GAUDIKERNEL_MESSAGE_H
00003 #define GAUDIKERNEL_MESSAGE_H
00004
00005 #include <string>
00006 #include <iostream>
00007
00015 class Message {
00016 public:
00018 Message();
00019
00021 Message ( const char* src, int type, const char* msg );
00022
00024 Message ( const std::string& src, int type, const std::string& msg );
00025
00027 ~Message() {}
00028
00030 const std::string& getMessage() const;
00031
00033 void setMessage( const std::string& msg );
00034
00036 int getType() const;
00037
00039 void setType( int msg_type );
00040
00042 const std::string& getSource() const;
00043
00045 void setSource( const std::string& src );
00046
00048 const std::string& getFormat() const;
00049
00051 void setFormat( const std::string& msg ) const;
00052
00054 bool operator < ( const Message& test );
00055
00057 friend std::ostream& operator << ( std::ostream& stream, const Message& msg );
00058
00060 friend bool operator == ( const Message& a, const Message& b );
00061
00062 protected:
00064 void invalidFormat() const;
00065
00067 void makeFormattedMsg( const std::string& format ) const;
00068
00070 void decodeFormat( const std::string& format ) const;
00071
00073 void sizeField( const std::string& text ) const;
00074
00076 void setWidth( const std::string& formatArg ) const;
00077
00079 std::string m_message;
00080
00082 std::string m_source;
00083
00085 mutable std::string m_format;
00086
00088 int m_type;
00089
00091 mutable std::string m_formatted_msg;
00092
00094 mutable char m_fill;
00095
00097 mutable int m_width;
00098
00100 mutable bool m_left;
00101
00103 static const char FORMAT_PREFIX;
00104
00106 static const char JUSTIFY_LEFT;
00107
00109 static const char JUSTIFY_RIGHT;
00110
00112 static const char MESSAGE;
00113
00115 static const char TYPE;
00116
00118 static const char SOURCE;
00119
00123 static const char FILL;
00124
00128 static const char WIDTH;
00129
00131 static const char* DEFAULT_FORMAT;
00132 };
00133
00134 #endif