Yate: Base64 Class Reference

Yate

Public Member Functions | List of all members
Base64 Class Reference

Base64 encoder/decoder class. More...

`#include <yateclass.h>`

Inheritance diagram for Base64:

## Public Member Functions
| Base64 ()
| Base64 (void *src, unsigned int len, bool copyData=true)
void | encode (String &dest, unsigned int lineLen=0, bool lineAtEnd=false)
bool | decode (DataBlock &dest, bool liberal=true)
Base64 & | operator<< (const String &value)
Base64 & | operator<< (const DataBlock &data)
Base64 & | operator<< (const char *value)
Public Member Functions inherited from DataBlock
| DataBlock (unsigned int overAlloc=0)
| DataBlock (const DataBlock &value)
| DataBlock (const DataBlock &value, unsigned int overAlloc)
| DataBlock (void *value, unsigned int len, bool copyData=true, unsigned int overAlloc=0)
virtual | ~DataBlock ()
void * | data () const
unsigned char * | data (unsigned int offs, unsigned int len=1) const
int | at (unsigned int offs, int defvalue=-1) const
bool | null () const
unsigned int | length () const
unsigned int | size () const
unsigned int | overAlloc () const
void | overAlloc (unsigned int bytes)
void | clear (bool deleteData=true)
DataBlock & | assign (void *value, unsigned int len, bool copyData=true, unsigned int allocated=0)
bool | change (unsigned int pos, const void *buf, unsigned int bufLen, unsigned int extra=0, int extraVal=0, bool mayOverlap=true)
bool | change8hton (unsigned int pos, uint64_t value)
bool | change4hton (unsigned int pos, uint32_t value)
bool | change3hton (unsigned int pos, uint32_t value)
bool | change2hton (unsigned int pos, uint16_t value)
bool | changeHton (unsigned int pos, uint64_t value, uint8_t bytes)
bool | changeLsb (unsigned int pos, uint64_t value, uint8_t bytes=8)
void | append (const void *value, unsigned int len, bool mayOverlap=true)
void | append (const DataBlock &value, bool mayOverlap=true)
void | append (const String &value)
void | appendBytes (unsigned int count, uint8_t val=0)
void | append8hton (uint64_t value)
void | append4hton (uint32_t value)
void | append3hton (uint32_t value)
void | append2hton (uint16_t value)
void | appendHton (uint64_t value, uint8_t bytes)
void | append8lsb (uint64_t value, uint8_t bytes=8)
void | append1 (uint8_t value)
void | insert (const void *buf, unsigned int bufLen, unsigned int pos=0, bool mayOverlap=true)
void | insert (const DataBlock &value, unsigned int pos=0, bool mayOverlap=true)
void | insertBytes (unsigned int count, unsigned int pos=0, uint8_t val=0)
void | insert8hton (uint64_t value, unsigned int pos=0)
void | insert4hton (uint32_t value, unsigned int pos=0)
void | insert3hton (uint32_t value, unsigned int pos=0)
void | insert2hton (uint16_t value, unsigned int pos=0)
void | insertHton (uint64_t value, uint8_t bytes=8, unsigned int pos=0)
void | insertLsb (uint64_t value, uint8_t bytes=8, unsigned int pos=0)
void | insert1 (uint8_t value, unsigned int pos=0)
void | resize (unsigned int len, bool keepData=false, bool reAlloc=true)
void | truncate (unsigned int len, bool reAlloc=true)
void | cut (unsigned int pos, unsigned int len, bool reAlloc=true)
void | cut (int len)
int | operator[] (signed int index) const
int | operator[] (unsigned int index) const
DataBlock & | operator= (const DataBlock &value)
DataBlock & | operator+= (const DataBlock &value)
DataBlock & | operator+= (const String &value)
bool | convert (const DataBlock &src, const String &sFormat, const String &dFormat, unsigned maxlen=0)
bool | changeHex (unsigned int pos, const char *data, unsigned int len, char sep=0, bool guessSep=true, bool emptyOk=true, int *res=0)
bool | changeHex (unsigned int pos, const String &data, char sep=0, bool guessSep=true, bool emptyOk=true, int *res=0)
bool | appendHex (const String &data, char sep=0, bool guessSep=true, bool emptyOk=true, int *res=0)
bool | unHexify (const char *data, unsigned int len, char sep)
bool | unHexify (const char *data, unsigned int len)
bool | unHexify (const String &data)
String & | sqlEscape (String &str, char extraEsc=0) const
String | sqlEscape (char extraEsc) const
Public Member Functions inherited from GenObject
| GenObject ()
virtual | ~GenObject ()
virtual bool | alive () const
virtual void | destruct ()
virtual const String & | toString () const
virtual const String & | traceId () const
virtual void * | getObject (const String &name) const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (NamedCounter *counter)

## Additional Inherited Members
Static Public Member Functions inherited from DataBlock
static const DataBlock & | empty ()
static String & | sqlEscape (String &str, const void *data, unsigned int len, char extraEsc=0)
static void | moveData (void *buf, unsigned int bufLen, unsigned int len, unsigned int dPos, unsigned int sPos, int fill=-1)
static void | rebuildDataInsert (void *dest, unsigned int dLen, const void *src, unsigned int sLen, unsigned int pos, unsigned int space, int fill=-1)
static void | rebuildDataRemove (void *dest, unsigned int dLen, const void *src, unsigned int sLen, unsigned int pos, unsigned int space, int fillAfter=-1)
static uint64_t | ntoh8advance (const uint8_t *&buf)
static uint64_t | ntoh8advance (const uint8_t *&buf, unsigned int &len)
static uint64_t | ntoh8 (const uint8_t *buf)
static void | hton8advance (uint8_t *&buf, uint64_t val)
static void | hton8advance (uint8_t *&buf, uint64_t val, unsigned int &len)
static void | hton8 (uint8_t *buf, uint64_t val)
static uint32_t | ntoh4advance (const uint8_t *&buf)
static uint32_t | ntoh4advance (const uint8_t *&buf, unsigned int &len)
static uint32_t | ntoh4 (const uint8_t *buf)
static void | hton4advance (uint8_t *&buf, uint32_t val)
static void | hton4advance (uint8_t *&buf, uint32_t val, unsigned int &len)
static void | hton4 (uint8_t *buf, uint32_t val)
static uint32_t | ntoh3advance (const uint8_t *&buf)
static uint32_t | ntoh3advance (const uint8_t *&buf, unsigned int &len)
static uint32_t | ntoh3 (const uint8_t *buf)
static void | hton3advance (uint8_t *&buf, uint32_t val)
static void | hton3advance (uint8_t *&buf, uint32_t val, unsigned int &len)
static void | hton3 (uint8_t *buf, uint32_t val)
static uint16_t | ntoh2advance (const uint8_t *&buf)
static uint16_t | ntoh2advance (const uint8_t *&buf, unsigned int &len)
static uint16_t | ntoh2 (const uint8_t *buf)
static void | hton2advance (uint8_t *&buf, uint16_t val)
static void | hton2advance (uint8_t *&buf, uint16_t val, unsigned int &len)
static void | hton2 (uint8_t *buf, uint16_t val)
static uint64_t | ntohAdvance (const uint8_t *&buf, uint8_t bytes)
static uint64_t | ntohAdvance (const uint8_t *&buf, unsigned int &len, uint8_t bytes)
static uint64_t | ntoh (const uint8_t *buf, uint8_t bytes)
static void | htonAdvance (uint8_t *&buf, uint64_t val, uint8_t bytes)
static void | htonAdvance (uint8_t *&buf, uint64_t val, unsigned int &len, uint8_t bytes)
static void | hton (uint8_t *buf, uint64_t val, uint8_t bytes)
static uint64_t | lsbAdvance (const uint8_t *&buf, uint8_t bytes)
static uint64_t | lsbAdvance (const uint8_t *&buf, unsigned int &len, uint8_t bytes)
static uint64_t | lsb (const uint8_t *buf, uint8_t bytes)
static void | lsbSetAdvance (uint8_t *&buf, uint64_t val, uint8_t bytes)
static void | lsbSetAdvance (uint8_t *&buf, uint64_t val, unsigned int &len, uint8_t bytes)
static void | lsbSet (uint8_t *buf, uint64_t val, uint8_t bytes)
Static Public Member Functions inherited from GenObject
static void * | getObject (const String &name, const GenObject *obj)
static bool | getObjCounting ()
static void | setObjCounting (bool enable)
static NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()

## Detailed Description

Base64 encoder/decoder class.

Base64 encoder/decoder class

## Constructor & Destructor Documentation

## ◆ Base64() [1/2]

Base64 | ( |  | ) |
| inline

Constructor

Referenced by operator<<(), operator<<(), and operator<<().

## ◆ Base64() [2/2]

Base64 | ( | void * | src,
|  | unsigned int | len,
|  | bool | copyData = true )
| inline

Constructor. Set the buffer

Parameters

  src | Initial data buffer
  len | Initial data buffer length
  copyData | True to make a copy of the received data

References DataBlock::DataBlock().

## Member Function Documentation

## ◆ decode()

bool decode | ( | DataBlock & | dest,
|  | bool | liberal = true )

Decode this buffer to a destination one

Parameters

  dest | Destination data buffer
  liberal | True to use 'liberal' rules when decoding. Some non alphabet characters (such as CR, LF, TAB, SPACE or the Base64 padding char '=') will be accepted and ignored. The resulting number of Base64 chars to decode must be a valid one

Returns
  True on succes, false if an invalid (non Base64) character was found or the number of Base64 characters is invalid (must be a multiple of 4 plus 0, 2 or 3 characters) or the padding is incorrect

References DataBlock::DataBlock().

## ◆ encode()

void encode | ( | String & | dest,
|  | unsigned int | lineLen = 0,
|  | bool | lineAtEnd = false )

Encode this buffer to a destination string

Parameters

  dest | Destination string
  lineLen | The length of a line. If non 0, a line break (CR/LF) will be inserted in the encoded data after each lineLine characters. No line break will be added after the last line. Use the lineAtEnd parameter to do that
  lineAtEnd | True to add a line break at the end of encoded data

## ◆ operator<<() [1/3]

Base64 & operator<< | ( | const char * | value | ) |
| inline

Base64 append operator for C strings

References Base64(), and operator<<().

## ◆ operator<<() [2/3]

Base64 & operator<< | ( | const DataBlock & | data | ) |
| inline

Base64 append operator for DataBlocks

References DataBlock::append(), Base64(), DataBlock::data(), and DataBlock::DataBlock().

## ◆ operator<<() [3/3]

Base64 & operator<< | ( | const String & | value | ) |
| inline

Base64 append operator for Strings

References DataBlock::append(), and Base64().

Referenced by operator<<().

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

- yateclass.h