Ookii.CommandLine for C++  2.0.0
Namespaces | Macros | Functions
format_helper.h File Reference

Allows selection between the C++20 <format> library and libfmt. More...

#include "string_helper.h"
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <fmt/xchar.h>
Include dependency graph for format_helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ookii
 Namespace containing the core Ookii.CommandLine.Cpp types.
 
 ookii::format
 Namespace containing helper functions for formatting.
 

Macros

#define OOKII_FMT_NS   fmt::
 The namespace which contains the formatting library. More...
 
#define OOKII_USING_LIBFMT
 Indicates libfmt is in use. More...
 

Functions

template<typename... Args>
std::string ookii::format::ncformat (const std::locale &loc, std::string_view format, Args &&... args)
 Helper to format using a non-const format string without needing to explicitly construct a format_args. More...
 
template<typename... Args>
std::wstring ookii::format::ncformat (const std::locale &loc, std::wstring_view format, Args &&... args)
 Helper to format using a non-const format wide string without needing to explicitly construct a wformat_args. More...
 

Detailed Description

Allows selection between the C++20 <format> library and libfmt.

This file makes it possible for Ookii.CommandLine.Cpp to work with either the standard <format> header provided in C++20, or with libfmt on compilers that don't provide <format>.

To force the use of libfmt even if <format> is available, you can define OOKII_FORCE_LIBFMT.

In addition, this header provides several helper types and functions used for formatting strings.

Macro Definition Documentation

◆ OOKII_FMT_NS

#define OOKII_FMT_NS   fmt::

The namespace which contains the formatting library.

This evaluates to std:: if <format> is available, otherwise to fmt::.

◆ OOKII_USING_LIBFMT

#define OOKII_USING_LIBFMT

Indicates libfmt is in use.

This is only defined if <format> is not available or OOKII_FORCE_LIBFMT is used.