UMPS
The University of Utah Seismograph Stations Message Passing System.
UMPS::MessageFormats::Text Class Reference

Defines a text-based message. For example, this class would allow you to send the contents of a text file. More...

#include "umps/messageFormats/text.hpp"

Inheritance diagram for UMPS::MessageFormats::Text:
Collaboration diagram for UMPS::MessageFormats::Text:

Public Member Functions

void setContents (const std::string &contents) noexcept
 Sets the contents of a text message. More...
 
std::string getContents () const noexcept
 
Constructors
 Text ()
 Constructor.
 
 Text (const Text &message)
 Copy constructor. More...
 
 Text (Text &&message) noexcept
 Move constructor. More...
 
Operators
Textoperator= (const Text &message)
 Copy assignment. More...
 
Textoperator= (Text &&message) noexcept
 Move assignment. More...
 
Message Abstract Base Class Properties
std::string toMessage () const final
 Converts the text class to a string message. More...
 
void fromMessage (const std::string &message) final
 Creates the class from a message. More...
 
void fromMessage (const char *data, size_t length) final
 Creates the class from a message. More...
 
std::string getMessageType () const noexcept final
 
std::string getMessageVersion () const noexcept final
 
std::unique_ptr< UMPS::MessageFormats::IMessageclone () const final
 
std::unique_ptr< UMPS::MessageFormats::IMessagecreateInstance () const noexcept final
 
Destructors
void clear () noexcept
 Resets the class and releases all memory.
 
 ~Text () override
 Destructor.
 
- Public Member Functions inherited from UMPS::MessageFormats::IMessage
virtual ~IMessage ()
 Destructor.
 

Detailed Description

Defines a text-based message. For example, this class would allow you to send the contents of a text file.

Constructor & Destructor Documentation

◆ Text() [1/2]

UMPS::MessageFormats::Text::Text ( const Text message)

Copy constructor.

Parameters
[in]messageThe text message class from which to initialize this class.

◆ Text() [2/2]

UMPS::MessageFormats::Text::Text ( Text &&  message)
noexcept

Move constructor.

Parameters
[in,out]messageThe text message class from which to initialize this class. On exit, message's behavior is undefined.

Member Function Documentation

◆ clone()

std::unique_ptr<UMPS::MessageFormats::IMessage> UMPS::MessageFormats::Text::clone ( ) const
finalvirtual
Returns
A copy of this class.

Implements UMPS::MessageFormats::IMessage.

◆ createInstance()

std::unique_ptr<UMPS::MessageFormats::IMessage> UMPS::MessageFormats::Text::createInstance ( ) const
finalvirtualnoexcept
Returns
An uninitialized instance of this class.

Implements UMPS::MessageFormats::IMessage.

◆ fromMessage() [1/2]

void UMPS::MessageFormats::Text::fromMessage ( const char *  data,
size_t  length 
)
finalvirtual

Creates the class from a message.

Parameters
[in]dataThe contents of the message. This is an array whose dimension is [length]
[in]lengthThe length of data.
Exceptions
std::runtime_errorif the message is invalid.
std::invalid_argumentif data is NULL or length is 0.

Implements UMPS::MessageFormats::IMessage.

◆ fromMessage() [2/2]

void UMPS::MessageFormats::Text::fromMessage ( const std::string &  message)
finalvirtual

Creates the class from a message.

Parameters
[in]messageThe contents of the message.
Exceptions
std::runtime_errorif the message is invalid.
std::invalid_argumentif data.empty() is true.

Implements UMPS::MessageFormats::IMessage.

◆ getContents()

std::string UMPS::MessageFormats::Text::getContents ( ) const
noexcept
Returns
The contents of the text message.

◆ getMessageType()

std::string UMPS::MessageFormats::Text::getMessageType ( ) const
finalvirtualnoexcept
Returns
A message type indicating this is a text message.

Implements UMPS::MessageFormats::IMessage.

◆ getMessageVersion()

std::string UMPS::MessageFormats::Text::getMessageVersion ( ) const
finalvirtualnoexcept
Returns
The message version.

Implements UMPS::MessageFormats::IMessage.

◆ operator=() [1/2]

Text& UMPS::MessageFormats::Text::operator= ( const Text message)

Copy assignment.

Parameters
[in]messageThe text message class to copy to this.
Returns
A deep copy of the text message.

◆ operator=() [2/2]

Text& UMPS::MessageFormats::Text::operator= ( Text &&  message)
noexcept

Move assignment.

Parameters
[in,out]messageThe text message class whose memory will be moved to this. On exit, messages's behavior is undefined.
Returns
The memory from message moved to this.

◆ setContents()

void UMPS::MessageFormats::Text::setContents ( const std::string &  contents)
noexcept

Sets the contents of a text message.

Parameters
[in]contentsThe text-based contents of the message to set.

◆ toMessage()

std::string UMPS::MessageFormats::Text::toMessage ( ) const
finalvirtual

Converts the text class to a string message.

Returns
The class expressed as a string message.
Exceptions
std::runtime_errorif the required information is not set.
Note
Though the container is a string the message need not be human readable.

Implements UMPS::MessageFormats::IMessage.


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