Prusa MINI Firmware overview
DynamicsHeader Class Reference

DynamicsHeader store it's value to LwIP memory pool. More...

#include <lwsapi_app.hpp>

Inheritance diagram for DynamicsHeader:
Collaboration diagram for DynamicsHeader:

Public Member Functions

 DynamicsHeader (const char *const key, const char *value, IHeader *next=nullptr)
 
 DynamicsHeader (const char *const key, const char *value, size_t length, IHeader *next=nullptr)
 
 ~DynamicsHeader ()
 
virtual size_t length () const override
 
virtual void snprintf (char *buff) const override
 
virtual void dbg () const override
 
- Public Member Functions inherited from IHeader
 IHeader (const char *const key, IHeader *next=nullptr)
 
- Public Member Functions inherited from LwIPClass
virtual ~LwIPClass ()
 

Public Attributes

char * value
 
- Public Attributes inherited from IHeader
const char * key
 
IHeadernext
 

Additional Inherited Members

- Static Public Member Functions inherited from LwIPClass
static voidoperator new (size_t size)
 
static void operator delete (void *ptr)
 
- Static Protected Attributes inherited from IHeader
static const size_t format_chars = 5
 

Detailed Description

DynamicsHeader store it's value to LwIP memory pool.

Constructor & Destructor Documentation

◆ DynamicsHeader() [1/2]

DynamicsHeader::DynamicsHeader ( const char *const  key,
const char *  value,
IHeader next = nullptr 
)
145  : IHeader(key, next) {
146  this->value = reinterpret_cast<char *>(
147  mem_calloc(sizeof(char), strlen(value) + 1));
148  if (this->value != nullptr) {
149  memcpy(this->value, value, strlen(value));
150  }
151  }
Here is the call graph for this function:

◆ DynamicsHeader() [2/2]

DynamicsHeader::DynamicsHeader ( const char *const  key,
const char *  value,
size_t  length,
IHeader next = nullptr 
)
155  : IHeader(key, next) {
156  this->value = reinterpret_cast<char *>(
157  mem_calloc(sizeof(char), length + 1));
158  if (this->value != nullptr) {
159  memcpy(this->value, value, length);
160  }
161  }
Here is the call graph for this function:

◆ ~DynamicsHeader()

DynamicsHeader::~DynamicsHeader ( )
163  {
165  }

Member Function Documentation

◆ length()

virtual size_t DynamicsHeader::length ( ) const
overridevirtual

Implements IHeader.

167  {
168  return strlen(key) + strlen(value) + format_chars;
169  }
Here is the caller graph for this function:

◆ snprintf()

virtual void DynamicsHeader::snprintf ( char *  buff) const
overridevirtual

Implements IHeader.

171  {
172  ::snprintf(buff, length(), "%s: %s\r\n", key, value);
173  }
Here is the call graph for this function:

◆ dbg()

virtual void DynamicsHeader::dbg ( ) const
overridevirtual

Implements IHeader.

175  {
176  lwsapi_dbg("Header: [%s]:'%s'", key, value);
177  }

Member Data Documentation

◆ value

char* DynamicsHeader::value
DynamicsHeader::value
char * value
Definition: lwsapi_app.hpp:141
DynamicsHeader::length
virtual size_t length() const override
Definition: lwsapi_app.hpp:167
IHeader::key
const char * key
Definition: lwsapi_app.hpp:72
mem_calloc
void * mem_calloc(mem_size_t count, mem_size_t size)
Definition: mem.c:765
DynamicsHeader::snprintf
virtual void snprintf(char *buff) const override
Definition: lwsapi_app.hpp:171
lwsapi_dbg
#define lwsapi_dbg
Definition: lwsapi_app.hpp:41
IHeader::next
IHeader * next
Definition: lwsapi_app.hpp:73
lwsapi_free
#define lwsapi_free(arg)
Definition: lwsapi_app.hpp:44
IHeader::IHeader
IHeader(const char *const key, IHeader *next=nullptr)
Definition: lwsapi_app.hpp:75
IHeader::format_chars
static const size_t format_chars
Definition: lwsapi_app.hpp:84