Prusa MINI Firmware overview
NumberHeader Class Reference

NumberHeader is for number headers like Content-Length. More...

#include <lwsapi_app.hpp>

Inheritance diagram for NumberHeader:
Collaboration diagram for NumberHeader:

Public Member Functions

 NumberHeader (const char *const key, size_t value, IHeader *next=nullptr)
 
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

size_t 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

NumberHeader is for number headers like Content-Length.

Constructor & Destructor Documentation

◆ NumberHeader()

NumberHeader::NumberHeader ( const char *const  key,
size_t  value,
IHeader next = nullptr 
)
93  : IHeader(key, next)
94  , value(value) {}

Member Function Documentation

◆ length()

virtual size_t NumberHeader::length ( ) const
overridevirtual

Implements IHeader.

96  {
97  size_t count = 1;
98  size_t tmp = value;
99  while (tmp > 9) {
100  count++;
101  tmp = tmp / 10;
102  }
103 
104  return count + strlen(key) + format_chars;
105  }
Here is the caller graph for this function:

◆ snprintf()

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

Implements IHeader.

106  {
107  ::snprintf(buff, length(), "%s: %zu\r\n", key, value);
108  }
Here is the call graph for this function:

◆ dbg()

virtual void NumberHeader::dbg ( ) const
overridevirtual

Implements IHeader.

110  {
111  lwsapi_dbg("Header: [%s]:'%zu'", key, value);
112  }

Member Data Documentation

◆ value

size_t NumberHeader::value
NumberHeader::snprintf
virtual void snprintf(char *buff) const override
Definition: lwsapi_app.hpp:106
IHeader::key
const char * key
Definition: lwsapi_app.hpp:72
NumberHeader::value
size_t value
Definition: lwsapi_app.hpp:90
lwsapi_dbg
#define lwsapi_dbg
Definition: lwsapi_app.hpp:41
NumberHeader::length
virtual size_t length() const override
Definition: lwsapi_app.hpp:96
IHeader::next
IHeader * next
Definition: lwsapi_app.hpp:73
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