FUtils/FUStatus.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00017 #ifndef _FU_STATUS_H_
00018 #define _FU_STATUS_H_
00019 
00029 class FCOLLADA_EXPORT FUStatus
00030 {
00031 private:
00032     fstring errorString;
00033     bool callSuccessful;
00034 
00035 public:
00039     FUStatus(bool _callSuccessful=true) { callSuccessful = _callSuccessful; }
00040 
00044     FUStatus& Fail() { callSuccessful = false; return *this; }
00045 
00051     FUStatus& Fail(const fstring& str, size_t line=0) { callSuccessful = false; AppendString(FS("ERROR[") + TO_FSTRING(line) + FS("]: ") + str); return *this; }
00052     FUStatus& Fail(const fchar* str, size_t line=0) { callSuccessful = false; AppendString(FS("ERROR[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } 
00059     FUStatus& Warning(const fstring& str, size_t line=0) { AppendString(FS("WARNING[") + TO_FSTRING(line) + FS("]: ") + str); return *this; }
00060     FUStatus& Warning(const fchar* str, size_t line=0) { AppendString(FS("WARNING[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } 
00066     void AppendStatus(const FUStatus& a) { AppendString(a.errorString); callSuccessful &= a.callSuccessful; }
00067 
00071     void AppendString(const fstring& str) { AppendString(str.c_str()); }
00072     void AppendString(const fchar* str) { if (*str != 0) { if (!errorString.empty()) errorString += FC("\r\n"); errorString += str; } } 
00076     const fchar* GetErrorString() const { return errorString.empty() ? (callSuccessful ? FC("Success") : FC("Failure")) : errorString.c_str(); }
00077 
00080     bool IsSuccessful() const { return callSuccessful; }
00081 
00084     bool IsFailure() const { return !callSuccessful; }
00085 
00088     operator bool() const { return callSuccessful; }
00089 };
00090 
00091 #endif // _FU_STATUS_H_

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO