AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch Namespace Reference

AnCH framework base namespace. More...

Namespaces

namespace  cli
 AnCH command line interface library namespace.
namespace  codec
 AnCH codec library namespace.
namespace  conf
 AnCH configuration library namespace.
namespace  crypto
 Cryptography namespace.
namespace  csv
 AnCH CSV library namespace.
namespace  cutils
 AnCH C utilities library namespace.
namespace  date
 Dates namespace.
namespace  device
 Device management namespace.
namespace  events
 Events management namespace.
namespace  ini
 AnCH INI library namespace.
namespace  json
 JSON namespace.
namespace  log
 AnCH logging library namespace.
namespace  network
 Network namespace.
namespace  oas
 OpenAPI namespace.
namespace  rest
 AnCH REST library namespace.
namespace  sql
 SQL namespace.
namespace  ut
 AnCH unit tests library namespace.
namespace  val
 AnCH validation library namespace.

Classes

class  Collectors
 Stream collector functions. More...
class  Fluent
 Java style fuent class. More...
class  Flux
 Manage collection as stream. More...
struct  LessPtrCompare
 Less comparator based on object address. More...
struct  Mapping
 Description of an object for every format (anch-json, ...). More...
class  Optional
 std::optional usefull methods. More...
class  PoolableResource
 Generic poolable resource. More...
class  ResourcePool
 Generic resource pool utility class. More...
struct  ResourcePoolState
 Resource pool shared state (internal usage). More...
class  Singleton
 Meyers' singleton implementation. More...
class  ThreadPool
 Thread pool utility class. More...
class  TimeoutException
 Timeout exception. More...
class  UUID
 UUID generator and parser. More...

Concepts

concept  Convertible
concept  Described
 Type described by an anch::Mapping specialization.
concept  ObjectMapper
 Mapper of a format on which anch::Mapping registers the fields of T.
concept  Releasable
concept  Validable

Functions

template<anch::Convertible N>
N convert (std::string_view str)
template<anch::Convertible N>
std::expected< N, std::errc > tryConvert (std::string_view str) noexcept
template<std::integral T>
void byteSwap (T src, uint8_t *dest) noexcept
constexpr bool isBigEndian () noexcept
constexpr bool isLittleEndian () noexcept
template<anch::Described T, anch::ObjectMapper< T > M>
void describe (M &mapper)
template<typename T>
void applyIfValue (const std::optional< T > &value, std::function< void(const T &)> func)
template<typename T>
void applyIfValueOrElse (const std::optional< T > &value, std::function< void(const T &)> func, std::function< void()> fallback)
void toLower (std::string &value)
void toUpper (std::string &value)

Detailed Description

AnCH framework base namespace.

Contains utility classes from AnCH utils and UUID libraries.

Function Documentation

◆ applyIfValue()

template<typename T>
void anch::applyIfValue ( const std::optional< T > & value,
std::function< void(const T &)> func )

Apply treatment if optional has value

Parameters
valuethe optional value
functhe treatment to apply when optional has value
Here is the call graph for this function:

◆ applyIfValueOrElse()

template<typename T>
void anch::applyIfValueOrElse ( const std::optional< T > & value,
std::function< void(const T &)> func,
std::function< void()> fallback )

Apply treatment if optional has value or apply fallback treatment

Parameters
valuethe optional value
functhe treatment to apply when optional has value
fallbackthe treatment to apply when optional has no value
Here is the call graph for this function:

◆ byteSwap()

template<std::integral T>
void anch::byteSwap ( T src,
uint8_t * dest )
noexcept

Switch data endianness.
Write the sizeof(T) bytes of src in reverse order into dest (dest can overlap src storage).

Parameters
srcthe integer to convert
destthe converted bytes (at least sizeof(T) bytes)
Since
0.1
Author
Vincent Lachenal
Here is the call graph for this function:

◆ convert()

template<anch::Convertible N>
N anch::convert ( std::string_view str)

Performs strict conversion from string to number.

The whole string has to be a number: leading or trailing characters (including spaces and '+' sign) are rejected.
The conversion does not depend on locale. Negative values are rejected for unsigned types and out of range values are rejected. int8_t and uint8_t are converted as numbers (not as characters).
Floating point values can be written in fixed or scientific notation, and can be inf or nan.

Parameters
strthe string to convert
Returns
the number
Exceptions
std::bad_castconversion error
Here is the call graph for this function:

◆ describe()

template<anch::Described T, anch::ObjectMapper< T > M>
void anch::describe ( M & mapper)

Register the fields of a described type on a mapper (used by formats)

Template Parameters
Tthe described type
Mthe mapper type
Parameters
mapperthe mapper
Since
0.3
Here is the call graph for this function:

◆ isBigEndian()

bool anch::isBigEndian ( )
constexprnoexcept

Check if system is in big endian bytes order.

Returns
true if system is big endian, false otherwise
Since
0.1
Author
Vincent Lachenal
Here is the call graph for this function:

◆ isLittleEndian()

bool anch::isLittleEndian ( )
constexprnoexcept

Check if system is in little endian bytes order.

Returns
true if system is little endian, false otherwise
Since
0.1
Author
Vincent Lachenal
Here is the call graph for this function:

◆ toLower()

void anch::toLower ( std::string & value)

Transform input string to lower case, byte per byte with std::tolower .
The conversion depends on the global C locale (std::setlocale ): only ASCII letters are converted with the default "C" locale ; multibyte characters (UTF-8) are not converted.

Parameters
valuethe string to transform
Here is the call graph for this function:

◆ toUpper()

void anch::toUpper ( std::string & value)

Transform input string to upper case, byte per byte with std::toupper .
The conversion depends on the global C locale (std::setlocale ): only ASCII letters are converted with the default "C" locale ; multibyte characters (UTF-8) are not converted.

Parameters
valuethe string to transform
Here is the call graph for this function:

◆ tryConvert()

template<anch::Convertible N>
std::expected< N, std::errc > anch::tryConvert ( std::string_view str)
noexcept

Performs strict conversion from string to number without exception.

Same rules as convert: the whole string has to be a number (no leading or trailing characters, no space, no '+' sign), conversion does not depend on locale, negative values are rejected for unsigned types.

Parameters
strthe string to convert
Returns
the number, or std::errc::invalid_argument (empty string, not a number, leading or trailing characters) or std::errc::result_out_of_range (value out of type range)
Since
0.3
Here is the call graph for this function: