olp-cpp-sdk  1.22.0
Public Member Functions | Friends | List of all members
olp::logging::FormatBuffer Class Reference

Attempts to format a string to a buffer before falling back to a dynamically allocated string. More...

#include <Format.h>

Public Member Functions

const char * format (const char *formatStr,...) CHECK_PRINTF_FORMAT_STRING(2
 Formats a string using a printf-style format string. More...
 
const char const char * formatv (const char *formatStr, va_list args)
 Formats a string using a printf-style format string with an already created va_list. More...
 
const char * formatLocalTime (const TimePoint &timestamp)
 Creates a string for a timestamp using local time with the default format string. More...
 
const char * formatLocalTime (const TimePoint &timestamp, const char *formatStr)
 Creates a string for a timestamp using local time. More...
 
const char * formatUtcTime (const TimePoint &timestamp)
 Creates a string for a timestamp using the UTC time standard with the default format string. More...
 
const char * formatUtcTime (const TimePoint &timestamp, const char *formatStr)
 Creates a string for a timestamp using the UTC time standard. More...
 

Friends

std::string logging::formatv (const char *formatStr, va_list args)
 

Detailed Description

Attempts to format a string to a buffer before falling back to a dynamically allocated string.

This can be used to avoid allocating std::string for smaller strings.

Member Function Documentation

◆ format()

const char* olp::logging::FormatBuffer::format ( const char *  formatStr,
  ... 
)

Formats a string using a printf-style format string.

Parameters
formatStrThe format string.
Returns
The formatted string.

◆ formatLocalTime() [1/2]

const char* olp::logging::FormatBuffer::formatLocalTime ( const TimePoint &  timestamp)

Creates a string for a timestamp using local time with the default format string.

The default format string is Y-m-d H:M:S.

Parameters
timestampThe timestamp to format as seconds from epoch.
Returns
The formatted string.

◆ formatLocalTime() [2/2]

const char* olp::logging::FormatBuffer::formatLocalTime ( const TimePoint &  timestamp,
const char *  formatStr 
)

Creates a string for a timestamp using local time.

Parameters
timestampThe timestamp to format as seconds from epoch.
formatStrThe format string to use, conforming to strftime.
Returns
The formatted string.

◆ formatUtcTime() [1/2]

const char* olp::logging::FormatBuffer::formatUtcTime ( const TimePoint &  timestamp)

Creates a string for a timestamp using the UTC time standard with the default format string.

The default format string is Y-m-d H:M:S.

Parameters
timestampThe timestamp to format as seconds from epoch.
Returns
The formatted string.

◆ formatUtcTime() [2/2]

const char* olp::logging::FormatBuffer::formatUtcTime ( const TimePoint &  timestamp,
const char *  formatStr 
)

Creates a string for a timestamp using the UTC time standard.

Parameters
timestampThe timestamp to format as seconds from epoch.
formatStrThe format string to use, conforming to strftime.
Returns
The formatted string.

◆ formatv()

const char const char* olp::logging::FormatBuffer::formatv ( const char *  formatStr,
va_list  args 
)

Formats a string using a printf-style format string with an already created va_list.

Parameters
formatStrThe format string.
argsThe va_list that contains the arguments.
Returns
The formatted string.

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