libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The SgfcMessage class provides an implementation of the ISgfcMessage interface. See the interface header file for documentation. More...
#include <SgfcMessage.h>
Public Member Functions | |
SgfcMessage (SgfcMessageID messageID, SgfcMessageType messageType, unsigned long lineNumber, unsigned long columnNumber, bool isCriticalMessage, int libraryErrorNumber, const std::string &messageText, const std::string &formattedMessageText) | |
Initializes a newly constructed SgfcMessage object with the supplied parameter values. | |
SgfcMessage (SgfcMessageID messageID, const std::string &messageText) | |
Initializes a newly constructed SgfcMessage object with the supplied parameter values. The SgfcMessage has message type SgfcMessageType::FatalError. | |
virtual | ~SgfcMessage () |
Destroys and cleans up the ISgfcMessage object. | |
virtual SgfcMessageID | GetMessageID () const override |
Returns the message's unique identification number. | |
virtual SgfcMessageType | GetMessageType () const override |
Returns the type of message. | |
virtual unsigned long | GetLineNumber () const override |
Returns the number of the line (1-based) in the parsed SGF data that caused the message. Returns SgfcConstants::InvalidLineNumber if the message does not refer to a specific line in the SGF data (most fatal errors, but also some errors and warnings). | |
virtual unsigned long | GetColumnNumber () const override |
Returns the number of the column (1-based) in the parsed SGF data that caused the message. Returns SgfcConstants::InvalidColumnNumber if the message does not refer to a specific column in the SGF data (most fatal errors, but also some errors and warnings). | |
virtual bool | IsCriticalMessage () const override |
Returns true if the message describes a critical problem. Only warning and error messages can be critical. Always returns false for fatal errors. | |
virtual int | GetLibraryErrorNumber () const override |
Returns an error number that indicates what went wrong when a standard C library function was invoked by SGFC. The value 0 (zero) indicates "no error", a non-zero value indicates an error. | |
virtual std::string | GetMessageText () const override |
Returns the message text. | |
virtual std::string | GetFormattedMessageText () const override |
Returns the formatted message text as if it had been printed by SGFC on the command-line. If the message was generated by libsgfc++ this returns the same value as GetMessageText(). | |
The SgfcMessage class provides an implementation of the ISgfcMessage interface. See the interface header file for documentation.
LibSgfcPlusPlus::SgfcMessage::SgfcMessage | ( | SgfcMessageID | messageID, |
SgfcMessageType | messageType, | ||
unsigned long | lineNumber, | ||
unsigned long | columnNumber, | ||
bool | isCriticalMessage, | ||
int | libraryErrorNumber, | ||
const std::string & | messageText, | ||
const std::string & | formattedMessageText ) |
Initializes a newly constructed SgfcMessage object with the supplied parameter values.
This constructor is intended to be used for messages that are generated by SGFC.
std::invalid_argument | Is thrown if the numeric value underlying messageID is not zero or a positive number. Is thrown if the message type is SgfcMessageType::FatalError and isCriticalMessage is true. |
LibSgfcPlusPlus::SgfcMessage::SgfcMessage | ( | SgfcMessageID | messageID, |
const std::string & | messageText ) |
Initializes a newly constructed SgfcMessage object with the supplied parameter values. The SgfcMessage has message type SgfcMessageType::FatalError.
This constructor is intended to be used for messages that are generated by libsgfc++.
std::invalid_argument | Is thrown if the numeric value underlying messageID is not a negative number |
|
overridevirtual |
Returns the number of the column (1-based) in the parsed SGF data that caused the message. Returns SgfcConstants::InvalidColumnNumber if the message does not refer to a specific column in the SGF data (most fatal errors, but also some errors and warnings).
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns the formatted message text as if it had been printed by SGFC on the command-line. If the message was generated by libsgfc++ this returns the same value as GetMessageText().
When the command-line version of SGFC prints messages it assembles the individual message parts into a formatted text. libsgfc++ emulates this formatting as closely as possible to generate the value returned by this method. There is no guarantee for an exact match, though.
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns an error number that indicates what went wrong when a standard C library function was invoked by SGFC. The value 0 (zero) indicates "no error", a non-zero value indicates an error.
As a convenience the library provides the constant SgfcConstants::LibraryErrorNumberNoError in case you prefer to use a constant to implement your program logic.
A non-zero value is a copy of the global errno value, made shortly after the failing function call. In the unlikely case that you need to evaluate this, consult the standard C library documentation of errno.
In case this method returns a non-zero error number, the text returned by GetFormattedMessageText() already includes an error message that results from invoking strerror() with the error number.
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns the number of the line (1-based) in the parsed SGF data that caused the message. Returns SgfcConstants::InvalidLineNumber if the message does not refer to a specific line in the SGF data (most fatal errors, but also some errors and warnings).
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns the message's unique identification number.
Every message generated by SGFC has its own unique message ID. Consult the SGFC documentation for a list of message IDs. SGFC calls them "error codes". The exception is when libsgfc++ is unable to determine the message ID when it receives the message data from SGFC - in the very unlikely case that this happens libsgfc++ sets the message ID to SgfcMessageID::UnknownSgfcMessageID.
Every message generated by libsgfc++ also has its own unique message ID that is distinct from all SGFC-generated message IDs.
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns the message text.
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns the type of message.
Messages generated by SGFC can be of all types. Messages generated by libsgfc++ are always fatal errors (although this may change in the future).
Implements LibSgfcPlusPlus::ISgfcMessage.
|
overridevirtual |
Returns true if the message describes a critical problem. Only warning and error messages can be critical. Always returns false for fatal errors.
A critical problem indicates that the SGF content parsed by SGFC may be severely damaged and that information may be lost if the parsed SGF data is written.
Implements LibSgfcPlusPlus::ISgfcMessage.