Fawkes API  Fawkes Development Version
fawkes::StringContent Class Reference

#include <>>

Inheritance diagram for fawkes::StringContent:

Public Member Functions

 StringContent (const char *initial_string)
 Primary constructor. More...
 
 StringContent (unsigned int cid, unsigned int msgid, void *payload, size_t payload_size)
 Constructor. More...
 
virtual ~StringContent ()
 Destructor. More...
 
void set_string (const char *s)
 Set the string. More...
 
const char * get_string () const
 Get string. More...
 
size_t get_string_length ()
 Get length of string. More...
 
virtual void serialize ()
 
- Public Member Functions inherited from fawkes::FawkesNetworkMessageContent
 FawkesNetworkMessageContent ()
 Constructor. More...
 
virtual ~FawkesNetworkMessageContent ()
 Virtual empty destructor. More...
 
virtual void * payload ()
 Return pointer to payload. More...
 
virtual size_t payload_size ()
 Return payload size. More...
 

Additional Inherited Members

- Protected Member Functions inherited from fawkes::FawkesNetworkMessageContent
void copy_payload (size_t offset, const void *buf, size_t len)
 Copy payload into payload buffer to a specified offset. More...
 
- Protected Attributes inherited from fawkes::FawkesNetworkMessageContent
void * _payload
 Pointer to payload. More...
 
size_t _payload_size
 Payloda size. More...
 

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

Definition at line 38 of file string_content.h.

Constructor & Destructor Documentation

◆ StringContent() [1/2]

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

Primary constructor.

Parameters
initial_stringinitial string

Definition at line 49 of file string_content.cpp.

◆ StringContent() [2/2]

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 62 of file string_content.cpp.

◆ ~StringContent()

fawkes::StringContent::~StringContent ( )
virtual

Destructor.

Definition at line 78 of file string_content.cpp.

References fawkes::FawkesNetworkMessageContent::_payload.

Member Function Documentation

◆ get_string()

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

Get string.

Returns
null-terminated string

Definition at line 106 of file string_content.cpp.

References fawkes::FawkesNetworkMessageContent::_payload_size.

◆ get_string_length()

size_t fawkes::StringContent::get_string_length ( )

Get length of string.

Returns
string length

Definition at line 115 of file string_content.cpp.

◆ serialize()

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 121 of file string_content.cpp.

◆ set_string()

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 90 of file string_content.cpp.


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