libStatGen Software
1
|
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.
{ SUCCESS = 0, ///< method completed successfully. UNKNOWN, ///< unknown result (default value should never be used) FAIL_IO, ///< method failed due to an I/O issue. FAIL_ORDER, ///< method failed because it was called out of order, ///< like trying to read a file without opening it for ///< read or trying to read a record before the header. FAIL_PARSE, ///< failed to parse a record/header - invalid format. INVALID, ///< invalid. FAIL_MEM ///< fail a memory allocation. };
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().
{ if(myType == GlfStatus::SUCCESS) { myType = newStatus; } else { myMessage += "\n"; } myMessage += getStatusString(newStatus); myMessage += ": "; myMessage += newMessage; }
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.
{ if(myType == GlfStatus::SUCCESS) { myType = newStatus.myType; } else { myMessage += "\n"; } myMessage += newStatus.myMessage; }
GlfStatus::Status GlfStatus::getStatus | ( | ) | const |
Return the enum for this status.
Definition at line 118 of file GlfStatus.cpp.
Referenced by GlfFile::getStatus().
{
return(myType);
}
const char * GlfStatus::getStatusMessage | ( | ) | const |
Return the status message.
Definition at line 125 of file GlfStatus.cpp.
Referenced by GlfFile::getStatusMessage(), and GlfException::what().
{
return(myMessage.c_str());
}
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().
{
return(enumStatusString[statusEnum]);
}
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.
{ if(status == GlfStatus::SUCCESS || status == GlfStatus::FAIL_PARSE || status == GlfStatus::INVALID) { // The status is such that file processing can continue. return(true); } // UNKNOWN, FAIL_IO, FAIL_ORDER, FAIL_MEM return(false); }
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.
{
return(compStatus != myType);
}
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().
{ reset(); myType = newStatus; return(*this); }
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.
{
return(compStatus == myType);
}
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().
{ myType = newStatus; myMessage = getStatusString(newStatus); myMessage += ": "; myMessage += newMessage; }