This class is used to track the status results of some methods in the GLF classes using the status enum that is defined in this class to describe the return value of a method. More...
#include <GlfStatus.h>
Public Types | |
enum | Status { SUCCESS = 0, UNKNOWN, FAIL_IO, FAIL_ORDER, FAIL_PARSE, INVALID, FAIL_MEM } |
Return value enum for the GlfFile class methods. More... | |
Public Member Functions | |
GlfStatus () | |
Constructor. | |
~GlfStatus () | |
Destructor. | |
void | reset () |
Resets this status. | |
void | setStatus (Status newStatus, const char *newMessage) |
Set the status with the specified values. | |
void | addError (Status newStatus, const char *newMessage) |
Adds the specified error message to the status message, setting the status to newStatus if the current status is SUCCESS. | |
void | addError (GlfStatus newStatus) |
Adds the specified status to the status message, setting the status to newStatus if the current status is SUCCESS. | |
Status | getStatus () const |
Return the enum for this status. | |
const char * | getStatusMessage () const |
Return the status message. | |
GlfStatus & | operator= (Status newStatus) |
Overload operator = to set the glf status type to the passed in status and to clear the message string. | |
bool | operator!= (const GlfStatus::Status &compStatus) const |
Overload operator != to determine if the passed in type is not equal to this status's type. | |
bool | operator== (const GlfStatus::Status &compStatus) const |
Overload operator != to determine if the passed in type is equal to this status's type. | |
Static Public Member Functions | |
static const char * | getStatusString (GlfStatus::Status statusEnum) |
Returns the string representation of the specified enum. | |
static bool | isContinuableStatus (GlfStatus::Status status) |
Returns whether or not it is "safe" to keep processing the file after the specified status return. |
This class is used to track the status results of some methods in the GLF classes using the status enum that is defined in this class to describe the return value of a method.
Definition at line 26 of file GlfStatus.h.
enum GlfStatus::Status |
Return value enum for the GlfFile class methods.
Definition at line 31 of file GlfStatus.h.
00031 { 00032 SUCCESS = 0, ///< method completed successfully. 00033 UNKNOWN, ///< unknown result (default value should never be used) 00034 FAIL_IO, ///< method failed due to an I/O issue. 00035 FAIL_ORDER, ///< method failed because it was called out of order, 00036 ///< like trying to read a file without opening it for 00037 ///< read or trying to read a record before the header. 00038 FAIL_PARSE, ///< failed to parse a record/header - invalid format. 00039 INVALID, ///< invalid. 00040 FAIL_MEM ///< fail a memory allocation. 00041 };
void GlfStatus::addError | ( | GlfStatus | newStatus | ) |
Adds the specified status to the status message, setting the status to newStatus if the current status is SUCCESS.
newStatus | status to add to this object. |
Definition at line 103 of file GlfStatus.cpp.
References SUCCESS.
00104 { 00105 if(myType == GlfStatus::SUCCESS) 00106 { 00107 myType = newStatus.myType; 00108 } 00109 else 00110 { 00111 myMessage += "\n"; 00112 } 00113 myMessage += newStatus.myMessage; 00114 }
void GlfStatus::addError | ( | Status | newStatus, | |
const char * | newMessage | |||
) |
Adds the specified error message to the status message, setting the status to newStatus if the current status is SUCCESS.
newStatus | status to add to this object. | |
newMessage | message to add to this object |
Definition at line 85 of file GlfStatus.cpp.
References getStatusString(), and SUCCESS.
Referenced by GlfException::GlfException().
00086 { 00087 if(myType == GlfStatus::SUCCESS) 00088 { 00089 myType = newStatus; 00090 } 00091 else 00092 { 00093 myMessage += "\n"; 00094 } 00095 myMessage += getStatusString(newStatus); 00096 myMessage += ": "; 00097 myMessage += newMessage; 00098 }
GlfStatus::Status GlfStatus::getStatus | ( | ) | const |
Return the enum for this status.
Definition at line 118 of file GlfStatus.cpp.
Referenced by GlfFile::getStatus().
const char * GlfStatus::getStatusMessage | ( | ) | const |
Return the status message.
Definition at line 125 of file GlfStatus.cpp.
Referenced by GlfFile::getStatusMessage(), and GlfException::what().
const char * GlfStatus::getStatusString | ( | GlfStatus::Status | statusEnum | ) | [static] |
Returns the string representation of the specified enum.
statusEnum | enum to convert to a string |
Definition at line 31 of file GlfStatus.cpp.
Referenced by addError(), and setStatus().
bool GlfStatus::isContinuableStatus | ( | GlfStatus::Status | status | ) | [static] |
Returns whether or not it is "safe" to keep processing the file after the specified status return.
status | enum to check if it is "safe" to continue processing. |
Definition at line 39 of file GlfStatus.cpp.
References FAIL_PARSE, INVALID, and SUCCESS.
00040 { 00041 if(status == GlfStatus::SUCCESS || status == GlfStatus::FAIL_PARSE || 00042 status == GlfStatus::INVALID) 00043 { 00044 // The status is such that file processing can continue. 00045 return(true); 00046 } 00047 // UNKNOWN, FAIL_IO, FAIL_ORDER, FAIL_MEM 00048 return(false); 00049 }
bool GlfStatus::operator!= | ( | const GlfStatus::Status & | compStatus | ) | const |
Overload operator != to determine if the passed in type is not equal to this status's type.
compStatus | status enum to compare this status object to. |
Definition at line 142 of file GlfStatus.cpp.
GlfStatus & GlfStatus::operator= | ( | GlfStatus::Status | newStatus | ) |
Overload operator = to set the glf status type to the passed in status and to clear the message string.
newStatus | new status to set this object to. |
Definition at line 133 of file GlfStatus.cpp.
References reset().
00134 { 00135 reset(); 00136 myType = newStatus; 00137 return(*this); 00138 }
bool GlfStatus::operator== | ( | const GlfStatus::Status & | compStatus | ) | const |
Overload operator != to determine if the passed in type is equal to this status's type.
compStatus | status enum to compare this status object to. |
Definition at line 148 of file GlfStatus.cpp.
void GlfStatus::setStatus | ( | Status | newStatus, | |
const char * | newMessage | |||
) |
Set the status with the specified values.
newStatus | new status to set this object to. | |
newMessage | message associated with the new status |
Definition at line 74 of file GlfStatus.cpp.
References getStatusString().
Referenced by GlfFile::getNextRecord(), GlfFile::getNextRefSection(), GlfException::GlfException(), GlfFile::openForRead(), GlfFile::openForWrite(), GlfFile::readHeader(), GlfFile::writeHeader(), GlfFile::writeRecord(), and GlfFile::writeRefSection().
00075 { 00076 myType = newStatus; 00077 myMessage = getStatusString(newStatus); 00078 myMessage += ": "; 00079 myMessage += newMessage; 00080 }