#include <Message_AMOS.hh>
Public Types | |
typedef HASHMAP::hash_map< NCode_t, std::string >::const_iterator | const_iterator |
Public Member Functions | |
Message_t () | |
Constructs an empty Message_t. | |
~Message_t () | |
Destroys a Message_t object. | |
const_iterator | begin () const |
Returns a const_iterator to the beginning of the field map. | |
const_iterator | end () const |
Returns a const_iterator to the end of the field map. | |
void | clear () |
Clears the message. | |
Size_t | countFields () const |
Returns the number of top-level fields in the message. | |
Size_t | countSubMessages () const |
Returns the number of top-level sub-messages in the message. | |
bool | empty () const |
Returns true if the message has no fields or sub messages. | |
bool | exists (NCode_t fcode) const |
Checks for the existence of a field by NCode. | |
bool | exists (const std::string &fname) const |
Checks for the existence of a field by name. | |
const std::string & | getField (NCode_t fcode) const |
Gets field data by field NCode. | |
const std::string & | getField (const std::string &fname) const |
Gets field data by field name. | |
const std::vector< Message_t > & | getSubMessages () const |
Get the vector of submessages for this message. | |
std::vector< Message_t > & | getSubMessages () |
Get the vector of submessages for this message. | |
NCode_t | getMessageCode () const |
Get the NCode type of this message. | |
const std::string & | operator[] (NCode_t fcode) const |
operator for getField method | |
const std::string & | operator[] (const std::string &fname) const |
bool | read (std::istream &in) |
Read a message from an input stream. | |
void | removeField (NCode_t fcode) |
Removes a field from the message object by NCode. | |
void | removeField (const std::string &fname) |
Removes a field from the message object. | |
void | setSubMessages (const std::vector< Message_t > &subs) |
Set the vector of submessages for this message. | |
void | setField (NCode_t fcode, const std::string &data) |
Set field data by field NCode. | |
void | setField (const std::string &fname, const std::string &data) |
Set field data by field name. | |
void | setMessageCode (NCode_t mcode) |
Set the NCode type code of this message. | |
void | setMessageCode (const std::string &mname) |
Set the NCode type name of this message. | |
void | write (std::ostream &out) const |
Write the message object to an output stream. | |
Static Public Member Functions | |
NCode_t | skip (std::istream &in) |
Skips a message in an input stream, returning its NCode. |
Based on the Celera 3-code format, the AMOS 'NCode' messages are designed for easy parsing and compatibility with the other AMOS modules. This generic message class makes no assumptions about the type of data to be stored within, so it can be used for reading and writing ANY type of ASCII record in NCode format. The main duty of this class is to understand and validate incoming or outgoing NCode format.
Definition at line 98 of file Message_AMOS.hh.
|
Definition at line 110 of file Message_AMOS.hh. Referenced by begin(), end(), getField(), main(), and write(). |
|
Constructs an empty Message_t. Definition at line 116 of file Message_AMOS.hh. References AMOS::M_NULL. |
|
Destroys a Message_t object. Definition at line 125 of file Message_AMOS.hh. |
|
Returns a const_iterator to the beginning of the field map. Iterator is of the type hash_map<NCode_t,std::string>::const_iterator. Access NCode with `itr -> first` and data with `itr -> second`.
References const_iterator. Referenced by write(). |
|
Clears the message.
References AMOS::M_NULL. Referenced by read(). |
|
Returns the number of top-level fields in the message.
References AMOS::Size_t. |
|
Returns the number of top-level sub-messages in the message.
References AMOS::Size_t. |
|
Returns true if the message has no fields or sub messages.
Referenced by read(), and setField(). |
|
Returns a const_iterator to the end of the field map. Iterator is of the type hash_map<NCode_t,std::string>::const_iterator. Access NCode with `itr -> first` and data with `itr -> second`.
References const_iterator. Referenced by exists(), getField(), and write(). |
|
Checks for the existence of a field by name.
References AMOS::Encode(), and exists(). |
|
Checks for the existence of a field by NCode.
References end(), and AMOS::NCode_t. Referenced by exists(). |
|
Gets field data by field name. Will return the field data, or throws an exception if the field does not exist. You can check if the field exists first with the exists method.
References AMOS::Encode(), and getField(). |
|
Gets field data by field NCode. Will return the field data, or throws an exception if the field does not exist. You can check if the field exists first with the exists method.
References AMOS_THROW_ARGUMENT, const_iterator, AMOS::Decode(), end(), and AMOS::NCode_t. Referenced by getField(), and operator[](). |
|
Get the NCode type of this message. Will return M_NULL if the message has not been assigned a type name yet. NCode can be decoded to a string with the 'AMOSDecode' function.
References AMOS::NCode_t. |
|
Get the vector of submessages for this message.
|
|
Get the vector of submessages for this message.
|
|
Definition at line 312 of file Message_AMOS.hh. References getField(). |
|
operator for getField method Definition at line 307 of file Message_AMOS.hh. References getField(), and AMOS::NCode_t. |
|
Read a message from an input stream. Reads a message from an input stream and populates the message fields with the values read from the stream. Will throw an exception if a message is found, but is not properly formatted.
References AMOS_THROW_IO, clear(), AMOS::Decode(), empty(), FIELD_SEPARATOR, FIELD_TERMINATOR, AMOS::NCODE_SIZE, AMOS::NL_CHAR, AMOS::NULL_CHAR, AMOS::NULL_NCODE, setField(), setMessageCode(), and skipto(). |
|
Removes a field from the message object. Removes a field from the message. Has no effect if the field name does not exist or is improperly formatted.
References AMOS::Encode(), and removeField(). |
|
Removes a field from the message object by NCode. Removes a field from the message by its NCode. Has no effect if the field code does not exist.
References AMOS::NCode_t. Referenced by removeField(). |
|
Set field data by field name. Will set a new, or overwrite and existing field with the supplied data. Throws an exception for an improperly formatted 3-code field name or an improperly formated data record (i.e. a multi-line record that does not end in a newline).
References AMOS::Encode(), and setField(). |
|
Set field data by field NCode. Will set a new, or overwrite and existing field with the supplied data. Throws an exception for an improperly formatted data record (i.e. a multi-line record that does not end in a newline). If the data string is empty, the field will be ignored and will remain uninitialized.
References AMOS_THROW_ARGUMENT, empty(), AMOS::NCode_t, and AMOS::NL_CHAR. Referenced by read(), and setField(). |
|
Set the NCode type name of this message. Will throw an exception if the name is improperly formatted.
References AMOS::Encode(), and setMessageCode(). |
|
Set the NCode type code of this message.
References AMOS::NCode_t. Referenced by read(), and setMessageCode(). |
|
Set the vector of submessages for this message.
|
|
Skips a message in an input stream, returning its NCode. Skips a message in an input stream, returning its NCode. Will throw an exception if a message is found, but its nesting is not properly formatted. However, complete validation is not performed. Use read method to assure proper formatting.
References AMOS_THROW_IO, AMOS::Encode(), AMOS::NCODE_SIZE, AMOS::NCode_t, AMOS::NL_CHAR, AMOS::NULL_CHAR, AMOS::NULL_NCODE, and skipto(). |
|
Write the message object to an output stream. Writes the NCode ASCII representation of this object to the supplied output stream. Will throw an exception if there was an error trying to write to the stream.
References AMOS_THROW_IO, begin(), const_iterator, AMOS::Decode(), end(), FIELD_SEPARATOR, FIELD_TERMINATOR, and AMOS::NL_CHAR. |