Fawkes API  Fawkes Development Version
fawkes::StringContent Class Reference

Content for a variable length string. More...

#include <>>

Inheritance diagram for fawkes::StringContent:

List of all members.

Public Member Functions

 StringContent (const char *initial_string)
 Primary constructor.
 StringContent (unsigned int cid, unsigned int msgid, void *payload, size_t payload_size)
 Constructor.
virtual ~StringContent ()
 Destructor.
void set_string (const char *s)
 Set the string.
const char * get_string () const
 Get string.
size_t get_string_length ()
 Get length of string.
virtual void serialize ()
 Serialize message content.

Detailed Description

Content for a variable length string.

This content class can be used with a FawkesNetworkMessage. It takes a single string of variable size and stuffs it into a message.

Author:
Tim Niemueller

Constructor & Destructor Documentation

fawkes::StringContent::StringContent ( const char *  initial_string)

Primary constructor.

Parameters:
initial_stringinitial string

Definition at line 44 of file string_content.cpp.

References set_string().

fawkes::StringContent::StringContent ( unsigned int  cid,
unsigned int  msgid,
void *  payload,
size_t  payload_size 
)

Constructor.

This ctor can be used with FawkesNetworkMessage::msgc().

Parameters:
cidcomponent ID, ignored
msgidmessage ID, ignored
payloadPayload, checked if it can be a valid string.
payload_sizesize in bytes of payload

Definition at line 58 of file string_content.cpp.

References fawkes::FawkesNetworkMessageContent::_payload, fawkes::FawkesNetworkMessageContent::payload(), fawkes::FawkesNetworkMessageContent::_payload_size, and fawkes::FawkesNetworkMessageContent::payload_size().

fawkes::StringContent::~StringContent ( ) [virtual]

Destructor.

Definition at line 73 of file string_content.cpp.


Member Function Documentation

const char * fawkes::StringContent::get_string ( ) const

Get string.

Returns:
null-terminated string

Definition at line 103 of file string_content.cpp.

size_t fawkes::StringContent::get_string_length ( )

Get length of string.

Returns:
string length

Definition at line 113 of file string_content.cpp.

References fawkes::FawkesNetworkMessageContent::_payload_size.

void fawkes::StringContent::serialize ( ) [virtual]

Serialize message content.

Generate a single contiguous buffer. Make _payload point to this buffer and _payload_size contain the size of the buffer.

Implements fawkes::FawkesNetworkMessageContent.

Definition at line 120 of file string_content.cpp.

void fawkes::StringContent::set_string ( const char *  s)

Set the string.

Can only be called if the instance has been created with the primary constructor.

Parameters:
sthe new string, must be null-terminated.

Definition at line 86 of file string_content.cpp.

References fawkes::FawkesNetworkMessageContent::_payload, and fawkes::FawkesNetworkMessageContent::_payload_size.

Referenced by StringContent().


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