ML Reference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00004 00028 //------------------------------------------------------------------------- 00029 #ifndef __mlErrorOutputInfos_H 00030 #define __mlErrorOutputInfos_H 00031 00032 #ifndef __mlUtilsSystem_H 00033 #include "mlUtilsSystem.h" 00034 #endif 00035 #ifndef __mlErrorOutput_H 00036 #include "mlErrorOutput.h" 00037 #endif 00038 #ifndef __mlDateTime_H 00039 #include "mlDateTime.h" 00040 #endif 00041 00042 ML_UTILS_START_NAMESPACE 00043 00044 //--------------------------------------------------------------------------------------------- 00050 //--------------------------------------------------------------------------------------------- 00051 class ErrorOutputInfos { 00052 public: 00053 00055 inline ErrorOutputInfos() 00056 { 00057 ML_INTERNAL_ERROR_TRACE_IN( "ErrorOutputInfos( )" ); 00058 00059 messageType = ML_WARNING; 00060 errorCode = ML_RESULT_OK; 00061 libraryPrefix = ML_PREFIX; 00062 fPrefix = ""; 00063 functionName = ""; 00064 reason = ""; 00065 handling = ""; 00066 file = ""; 00067 time = DateTime().now(); 00068 line = 0; 00069 } 00070 00072 inline ErrorOutputInfos(const ErrorOutputInfos &ei) { *this = ei; } 00073 00075 inline ErrorOutputInfos &operator=(const ErrorOutputInfos &ei) 00076 { 00077 ML_INTERNAL_ERROR_TRACE_IN( "ErrorOutputInfos ( )" ); 00078 00079 messageType = ei.messageType; 00080 errorCode = ei.errorCode; 00081 libraryPrefix = ei.libraryPrefix; 00082 fPrefix = ei.fPrefix; 00083 functionName = ei.functionName; 00084 reason = ei.reason; 00085 handling = ei.handling; 00086 file = ei.file; 00087 time = ei.time; 00088 line = ei.line; 00089 return *this; 00090 } 00091 00093 inline MLMessageType getMessageType() const { return messageType; } 00094 00096 inline MLErrorCode getErrorCode() const { return errorCode; } 00097 00099 inline const char* getLibraryPrefix() const { return libraryPrefix.c_str(); } 00100 00102 inline const char* getFunctionPrefix() const { return fPrefix.c_str(); } 00103 00105 inline const char* getFunctionName() const { return functionName.c_str(); } 00106 00108 inline const char* getReason() const { return reason.c_str(); } 00109 00111 inline const char* getHandling() const { return handling.c_str(); } 00112 00114 inline const char* getFile() const { return file.c_str(); } 00115 00117 inline const DateTime& getTime() const { return time; } 00118 00120 inline int getLine() const { return line; } 00121 00122 protected: 00123 // The following members are only set by the friend class \c ErrorOutput 00124 // to avoid undesired modifications from outside. 00125 00127 ML_UTILS_EXPORT friend class ErrorOutput; 00128 00130 MLMessageType messageType; 00131 00133 MLErrorCode errorCode; 00134 00137 std::string libraryPrefix; 00138 00140 std::string fPrefix; 00141 00143 std::string functionName; 00144 00146 std::string reason; 00147 00149 std::string handling; 00150 00152 std::string file; 00153 00155 DateTime time; 00156 00158 int line; 00159 00160 00161 #ifdef ML_DEPRECATED 00162 00164 00165 00166 public: 00167 00170 inline ML_DEPRECATED const char* getFPrefix() const { return getFunctionPrefix(); } 00171 00173 00174 #endif // ML_DEPRECATED 00175 00176 }; 00177 00178 ML_UTILS_END_NAMESPACE 00179 00180 //----------------------------------------------------------------------------------- 00181 // Stream output for std::ostream 00182 //----------------------------------------------------------------------------------- 00183 namespace std 00184 { 00185 00187 inline ostream& operator<<(ostream& s, const ML_UTILS_NAMESPACE::ErrorOutputInfos &eoi) 00188 { 00189 ML_INTERNAL_ERROR_TRACE_IN( "operator<< on ErrorOutputInfos()" ); 00190 return s << "Message type :" << eoi.getMessageType() << endl << 00191 "Error Code :" << eoi.getErrorCode() << endl << 00192 "Library Prefix :" << eoi.getLibraryPrefix() << endl << 00193 "Function Prefix:" << eoi.getFunctionPrefix() << endl << 00194 "Function Name :" << eoi.getFunctionName() << endl << 00195 "Reason :" << eoi.getReason() << endl << 00196 "Handling :" << eoi.getHandling() << endl << 00197 "File Name :" << eoi.getFile() << endl << 00198 "Time Stamp :" << eoi.getTime() << endl << 00199 // Cast to MLint32 to avoid non unique << operators on 64 bit compilation. 00200 "Line Number :" << static_cast<MLint32>(eoi.getLine()) << endl; 00201 } 00202 00203 } 00204 00205 #endif // End of __mlErrorOutputInfos_H 00206 00207 00208 00209