libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibSgfcPlusPlus::ISgfcMessage Class Referenceabstract

The ISgfcMessage interface represents a message that is generated when SGF data is loaded and parsed, or when SGF data is saved. Most messages are generated by SGFC, but there are a few error cases where libsgfc++ also generates messages. ISgfcMessage objects are immutable. More...

#include <ISgfcMessage.h>

Inheritance diagram for LibSgfcPlusPlus::ISgfcMessage:
LibSgfcPlusPlus::SgfcMessage

Public Member Functions

 ISgfcMessage ()
 Initializes a newly constructed ISgfcMessage object.
 
virtual ~ISgfcMessage ()
 Destroys and cleans up the ISgfcMessage object.
 
virtual SgfcMessageID GetMessageID () const =0
 Returns the message's unique identification number.
 
virtual SgfcMessageType GetMessageType () const =0
 Returns the type of message.
 
virtual unsigned long GetLineNumber () const =0
 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 =0
 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 =0
 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 =0
 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 =0
 Returns the message text.
 
virtual std::string GetFormattedMessageText () const =0
 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().
 

Detailed Description

The ISgfcMessage interface represents a message that is generated when SGF data is loaded and parsed, or when SGF data is saved. Most messages are generated by SGFC, but there are a few error cases where libsgfc++ also generates messages. ISgfcMessage objects are immutable.

Member Function Documentation

◆ GetColumnNumber()

virtual unsigned long LibSgfcPlusPlus::ISgfcMessage::GetColumnNumber ( ) const
pure virtual

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).

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetFormattedMessageText()

virtual std::string LibSgfcPlusPlus::ISgfcMessage::GetFormattedMessageText ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetLibraryErrorNumber()

virtual int LibSgfcPlusPlus::ISgfcMessage::GetLibraryErrorNumber ( ) const
pure virtual

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.

Note
Messages for which this method returns a non-zero value are usually fatal error messages related to file I/O. There is no guarantee that this will always be the case, though.
This method always returns 0 (zero) for messages generated by libsgfc++.

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetLineNumber()

virtual unsigned long LibSgfcPlusPlus::ISgfcMessage::GetLineNumber ( ) const
pure virtual

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).

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetMessageID()

virtual SgfcMessageID LibSgfcPlusPlus::ISgfcMessage::GetMessageID ( ) const
pure virtual

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.

See also
SgfcMessageID

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetMessageText()

virtual std::string LibSgfcPlusPlus::ISgfcMessage::GetMessageText ( ) const
pure virtual

Returns the message text.

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ GetMessageType()

virtual SgfcMessageType LibSgfcPlusPlus::ISgfcMessage::GetMessageType ( ) const
pure virtual

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).

Attention
For SGFC-generated messages one and the same message ID can have different message types, depending on the context in which the message is generated. Examples: SgfcMessageID::EmptyValueDeleted, SgfcMessageID::IllegalSingleValueCorrected, etc.. Refer to the SGFC documentation for details.

Implemented in LibSgfcPlusPlus::SgfcMessage.

◆ IsCriticalMessage()

virtual bool LibSgfcPlusPlus::ISgfcMessage::IsCriticalMessage ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcMessage.


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