GlfStatus Class Reference

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. More...
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. More...
void | addError (GlfStatus newStatus)
| Adds the specified status to the status message, setting the status to newStatus if the current status is SUCCESS. More...
Status | getStatus () const
| Return the enum for this status. More...
const char * | getStatusMessage () const
| Return the status message. More...
GlfStatus & | operator= (Status newStatus)
| Overload operator = to set the glf status type to the passed in status and to clear the message string. More...
bool | operator!= (const GlfStatus::Status &compStatus) const
| Overload operator != to determine if the passed in type is not equal to this status's type. More...
bool | operator== (const GlfStatus::Status &compStatus) const
| Overload operator != to determine if the passed in type is equal to this status's type. More...

## Static Public Member Functions

static const char * | getStatusString (GlfStatus::Status statusEnum)
| Returns the string representation of the specified enum. More...
static bool | isContinuableStatus (GlfStatus::Status status)
| Returns whether or not it is "safe" to keep processing the file after the specified status return. More...

## Detailed Description

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.

## Member Enumeration Documentation

## Status

enum GlfStatus::Status

Return value enum for the GlfFile class methods.

Enumerator
SUCCESS | 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.

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.
};
GlfStatus::FAIL_MEM
@ FAIL_MEM
fail a memory allocation.
Definition: GlfStatus.h:40
GlfStatus::FAIL_ORDER
@ FAIL_ORDER
method failed because it was called out of order, like trying to read a file without opening it for r...
Definition: GlfStatus.h:35
GlfStatus::UNKNOWN
@ UNKNOWN
unknown result (default value should never be used)
Definition: GlfStatus.h:33
GlfStatus::SUCCESS
@ SUCCESS
method completed successfully.
Definition: GlfStatus.h:32
GlfStatus::INVALID
@ INVALID
invalid.
Definition: GlfStatus.h:39
GlfStatus::FAIL_PARSE
@ FAIL_PARSE
failed to parse a record/header - invalid format.
Definition: GlfStatus.h:38
GlfStatus::FAIL_IO
@ FAIL_IO
method failed due to an I/O issue.
Definition: GlfStatus.h:34

## Member Function Documentation

## addError() [1/2]

void GlfStatus::addError | ( | GlfStatus | newStatus | ) |

Adds the specified status to the status message, setting the status to newStatus if the current status is SUCCESS.

Parameters

  newStatus | status to add to this object.

Definition at line 103 of file GlfStatus.cpp.

{
if(myType == GlfStatus::SUCCESS)
{
myType = newStatus.myType;
}
else
{
myMessage += "\n";
}
myMessage += newStatus.myMessage;
}

References SUCCESS.

## addError() [2/2]

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.

Parameters

  newStatus | status to add to this object.
  newMessage | message to add to this object

Definition at line 85 of file GlfStatus.cpp.

{
if(myType == GlfStatus::SUCCESS)
{
myType = newStatus;
}
else
{
myMessage += "\n";
}
myMessage += getStatusString(newStatus);
myMessage += ": ";
myMessage += newMessage;
}
GlfStatus::getStatusString
static const char * getStatusString(GlfStatus::Status statusEnum)
Returns the string representation of the specified enum.
Definition: GlfStatus.cpp:31

References getStatusString(), and SUCCESS.

Referenced by GlfException::GlfException().

## getStatus()

GlfStatus::Status GlfStatus::getStatus | ( |  | ) | const

Return the enum for this status.

Returns
  enum for this status object.

Definition at line 118 of file GlfStatus.cpp.

{
return(myType);
}

Referenced by GlfFile::getStatus().

## getStatusMessage()

const char * GlfStatus::getStatusMessage | ( |  | ) | const

Return the status message.

Returns
  status message associate with this status object.

Definition at line 125 of file GlfStatus.cpp.

{
return(myMessage.c_str());
}

Referenced by GlfFile::getStatusMessage(), and GlfException::what().

## getStatusString()

const char * GlfStatus::getStatusString | ( | GlfStatus::Status | statusEnum | ) |

static

Returns the string representation of the specified enum.

Parameters

  statusEnum | enum to convert to a string

Returns
  string representation of the enum

Definition at line 31 of file GlfStatus.cpp.

{
return(enumStatusString[statusEnum]);
}

Referenced by addError(), and setStatus().

## isContinuableStatus()

bool GlfStatus::isContinuableStatus | ( | GlfStatus::Status | status | ) |

static

Returns whether or not it is "safe" to keep processing the file after the specified status return.

Parameters

  status | enum to check if it is "safe" to continue processing.

Returns
  whether or not it is "safe" to keep processing the file after receiving the specified enum.

Definition at line 39 of file GlfStatus.cpp.

{
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);
}

References FAIL_PARSE, INVALID, and SUCCESS.

## operator!=()

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.

Parameters

  compStatus | status enum to compare this status object to.

Returns
  true if they are not equal, false if they are.

Definition at line 142 of file GlfStatus.cpp.

{
return(compStatus != myType);
}

## operator=()

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.

Parameters

  newStatus | new status to set this object to.

Returns
  this object.

Definition at line 133 of file GlfStatus.cpp.

{
reset();
myType = newStatus;
return(*this);
}
GlfStatus::reset
void reset()
Resets this status.
Definition: GlfStatus.cpp:66

References reset().

## operator==()

bool GlfStatus::operator== | ( | const GlfStatus::Status & | compStatus | ) | const

Overload operator != to determine if the passed in type is equal to this status's type.

Parameters

  compStatus | status enum to compare this status object to.

Returns
  true if they are equal, false if they are not.

Definition at line 148 of file GlfStatus.cpp.

{
return(compStatus == myType);
}

## setStatus()

void GlfStatus::setStatus | ( | Status | newStatus,
|  | const char * | newMessage
| ) |  |

Set the status with the specified values.

Parameters

  newStatus | new status to set this object to.
  newMessage | message associated with the new status

Definition at line 74 of file GlfStatus.cpp.

{
myType = newStatus;
myMessage = getStatusString(newStatus);
myMessage += ": ";
myMessage += newMessage;
}

References getStatusString().

Referenced by GlfException::GlfException(), GlfFile::getNextRecord(), GlfFile::getNextRefSection(), GlfFile::openForRead(), GlfFile::openForWrite(), GlfFile::readHeader(), GlfFile::writeHeader(), GlfFile::writeRecord(), and GlfFile::writeRefSection().

The documentation for this class was generated from the following files:

- glf/GlfStatus.h
- glf/GlfStatus.cpp