ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
active::utility::DataFormat Struct Reference

#include <DataFormat.h>

Collaboration diagram for active::utility::DataFormat:
Collaboration graph
[legend]

Public Types

using Option = std::optional<DataFormat>
 

Public Member Functions

 DataFormat ()
 
 DataFormat (bool withBOM, bool asBigEndian=defaultEndian)
 
 DataFormat (TextEncoding encode, bool withBOM=false, bool asBigEndian=defaultEndian)
 
Memory::Option toBOM () const
 

Static Public Member Functions

static std::optional< std::pair< DataFormat, Memory::size_type > > fromBOM (const char *bom, Memory::size_type len)
 

Public Attributes

TextEncoding encoding = TextEncoding::UTF8
 The text encoding.
 
bool isBigEndian = defaultEndian
 True if byte ordering is big-endian.
 
bool isBOM = false
 True if the text is preceded by a BOM.
 

Static Public Attributes

static constexpr bool defaultEndian {std::endian::native == std::endian::big}
 

Detailed Description

A structure specifying i/o data formatting

Constructor & Destructor Documentation

◆ DataFormat() [1/3]

active::utility::DataFormat::DataFormat ( )
inline

Default constructor

◆ DataFormat() [2/3]

active::utility::DataFormat::DataFormat ( bool withBOM,
bool asBigEndian = defaultEndian )
inline

Constructor

Parameters
withBOMTrue if the text is preceded by a BOM
asBigEndianTrue if byte ordering is big-endian

◆ DataFormat() [3/3]

active::utility::DataFormat::DataFormat ( TextEncoding encode,
bool withBOM = false,
bool asBigEndian = defaultEndian )
inline

Constructor

Parameters
encodeThe text encoding
withBOMTrue if the text is preceded by a BOM
asBigEndianTrue if byte ordering is big-endian

Member Function Documentation

◆ fromBOM()

std::optional< std::pair< DataFormat, Memory::size_type > > DataFormat::fromBOM ( const char * bom,
Memory::size_type len )
static

Create a data format from a BOM signature

Parameters
bomA series of bytes to test for a BOM signature
lenThe number of available bytes
Returns
The data format paired with the number of bytes in the BOM (nullopt on failure)

◆ toBOM()

Memory::Option DataFormat::toBOM ( ) const

Get a BOM signature for the format

Returns
The BOM signature (nullopt if none defined, e.g. for ascii)
Here is the call graph for this function:
Here is the caller graph for this function:

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