Utilities. More...
Namespaces | |
namespace | datetime |
Date and time utilities. | |
namespace | generators |
Generators. | |
namespace | log |
Algorithms to aid logging. | |
namespace | text |
Text utilities. | |
Classes | |
class | AnyMovable |
Replacement for std::any that is not copyable. It allows to store non-copyable and even non-movable types. More... | |
class | AtomicFlags |
Wrapper to extend enum with atomic flags interface. More... | |
class | BadAnyMovableCast |
The exception that is thrown when AnyCast fails. More... | |
struct | CachedHash |
Holds the key and its hash for faster comparisons and hashing. More... | |
class | CachedHashKeyEqual |
Compares utils::CachedHash only by keys. More... | |
class | CachedHashKeyEqual< Equal, std::false_type > |
class | CheckedPtr |
Utility template for returning a pointer to an object that is owned by someone else; throws std::runtime_error if nullptr is stored. More... | |
class | CheckedPtr< T & > |
class | CpuRelax |
class | CurrentThreadNameGuard |
RAII helper to run some code with a temporary current thread name. More... | |
class | FastPimpl |
Implements pimpl idiom without dynamic memory allocation. More... | |
class | FastScopeGuard |
a helper class to perform actions on scope exit More... | |
class | FixedArray |
A fixed-size array with the size determined at runtime. More... | |
class | Flags |
Wrapper to extend enum with flags interface. More... | |
class | InvariantError |
Exception that is thrown on UINVARIANT violation. More... | |
class | LazyPrvalue |
Can be used with various emplace functions to allow in-place constructing a non-movable value using a callable. More... | |
class | LazySharedPtr |
A lazy wrapper around utils::SharedReadablePtr that fetches the data on first access. More... | |
class | NotNull |
Restricts a pointer or smart pointer to only hold non-null values. More... | |
class | OptionalRef |
Class that behaves as a nullable reference. Main difference from the pointer - value comparison of pointed values. More... | |
struct | Overloaded |
Utility to define std::variant visitors in a simple way. More... | |
class | PeriodicTask |
Task that periodically runs a user callback. More... | |
class | RandomBase |
Virtualized standard UniformRandomBitGenerator concept, for use with random number distributions. More... | |
class | regex |
Small alias for boost::regex / std::regex without huge includes. More... | |
class | ResultStore |
Simple value/exception store. More... | |
class | ResultStore< void > |
Simple void value/exception store. More... | |
class | ScopeGuard |
a helper class to perform actions on scope exit More... | |
class | ScopeTimePause |
Utility to easily pause ScopeTime, e.g. when yielding. More... | |
class | SharedReadablePtr |
std::shared_ptr<const T> wrapper that makes sure that the pointer is stored before dereferencing. Protects from dangling references: More... | |
class | StrCaseHash |
Case sensitive ASCII hashing functor. More... | |
class | StreamingCpuRelax |
class | StrIcaseCompareThreeWay |
Case insensitive ASCII 3-way comparison functor. More... | |
class | StrIcaseEqual |
Case insensitive ASCII equality comparison functor. More... | |
class | StrIcaseHash |
Case insensitive ASCII hashing functor. More... | |
class | StrIcaseLess |
Case insensitive ASCII less comparison functor. More... | |
class | StrongTypedef |
Strong typedef for a type T. More... | |
class | SwappingSmart |
class | TokenBucket |
class | TracefulException |
Exception that remembers the backtrace at the point of its construction. More... | |
class | TracefulExceptionBase |
Base class implementing backtrace storage and message builder, published only for documentation purposes, please inherit from utils::TracefulException instead. More... | |
class | TrivialBiMap |
Bidirectional unordered map for trivial types, including string literals; could be efficiently used as a unordered non-bidirectional map. More... | |
class | TrivialSet |
Unordered set for trivial types, including string literals. More... | |
Typedefs | |
template<typename U > | |
using | SharedRef = NotNull< std::shared_ptr< U > > |
A std::shared_ptr that is guaranteed to be not-null. More... | |
template<typename U > | |
using | UniqueRef = NotNull< std::unique_ptr< U > > |
A std::unique_ptr that is guaranteed to be not-null. More... | |
template<typename Value , auto Projection, typename Hash = void, typename Equal = std::equal_to<>, typename Allocator = std::allocator<Value>> | |
using | ProjectedUnorderedSet = std::unordered_set< Value, impl::projected_set::Hash< Value, Projection, Hash >, impl::projected_set::Compare< Value, Projection, Equal >, Allocator > |
A std::unordered_set that compares its elements (of type Value) based on their Projection. It allows to create, essentially, an equivalent of std::unordered_map where keys are stored inside values. More... | |
template<typename Value , auto Projection, typename Compare = std::less<>, typename Allocator = std::allocator<Value>> | |
using | ProjectedSet = std::set< Value, impl::projected_set::Compare< Value, Projection, Compare >, Allocator > |
Same as ProjectedUnorderedSet, but for std::set . More... | |
template<class Tag , class T > | |
using | NonLoggable = StrongTypedef< Tag, T, StrongTypedefOps::kCompareStrong|StrongTypedefOps::kNonLoggable > |
template<typename... T> | |
using | void_t = std::void_t< T... > |
std::void_t implementation with workarounds for compiler bugs More... | |
Enumerations | |
enum class | BytesPerSecond : long long |
Data type that represents bytes per second unit. More... | |
enum class | StrongTypedefOps { kNoCompare = 0 , kCompareStrong = 1 , kCompareTransparentOnly = 2 , kCompareTransparent = 3 , kNonLoggable = 4 } |
Functions | |
template<typename... Strings> | |
std::string | StrCat (const Strings &... strings) |
Concatenates multiple std::string_view -convertible items. More... | |
template<class Map , class Key > | |
auto * | FindOrNullptr (Map &map, const Key &key) |
Returns nullptr if no key in associative container, otherwise returns pointer to value. More... | |
template<class Map , class Key , class Default > | |
Map::mapped_type | FindOrDefault (Map &map, const Key &key, Default &&def) |
Returns default value if no key in associative container, otherwise returns a copy of the stored value. More... | |
template<class Map , class Key > | |
Map::mapped_type | FindOrDefault (Map &map, const Key &key) |
Returns default value if no key in associative container, otherwise returns a copy of the stored value. More... | |
template<class Map , class Key > | |
std::optional< typename Map::mapped_type > | FindOptional (Map &map, const Key &key) |
Returns std::nullopt if no key in associative container, otherwise returns std::optional with a copy of value. More... | |
template<typename Map , typename Key > | |
auto | CheckedFind (Map &map, const Key &key) -> decltype(utils::MakeCheckedPtr(&map.find(key) ->second)) |
Searches a map for an element and return a checked pointer to the found element. More... | |
template<class ToContainer , class FromContainer > | |
ToContainer | AsContainer (FromContainer &&container) |
Converts one container type to another. More... | |
template<class Container , class Pred > | |
auto | EraseIf (Container &container, Pred pred) |
Erased elements and returns number of deleted elements. More... | |
template<class Container , class T > | |
size_t | Erase (Container &container, const T &elem) |
Erased elements and returns number of deleted elements. More... | |
template<typename Container , typename Pred > | |
bool | ContainsIf (const Container &container, Pred pred) |
returns true if there is an element in container which satisfies the predicate More... | |
template<typename ValueType > | |
ValueType * | AnyCast (AnyMovable *operand) noexcept |
template<typename ValueType > | |
const ValueType * | AnyCast (const AnyMovable *operand) noexcept |
template<typename ValueType > | |
ValueType | AnyCast (AnyMovable &operand) |
template<typename ValueType > | |
ValueType | AnyCast (const AnyMovable &operand) |
template<typename ValueType > | |
ValueType | AnyCast (AnyMovable &&operand) |
template<typename T , typename Func > | |
T | AtomicUpdate (std::atomic< T > &atomic, Func updater) |
Atomically performs the operation of updater on atomic More... | |
template<typename T > | |
T | AtomicMin (std::atomic< T > &atomic, T value) |
Concurrently safe sets atomic to a value if value is less. More... | |
template<typename T > | |
T | AtomicMax (std::atomic< T > &atomic, T value) |
Concurrently safe sets atomic to a value if value is greater. More... | |
boost::uuids::uuid | BoostUuidFromString (std::string const &str) |
Parse string into boost::uuids::uuid. | |
std::string | ToString (const boost::uuids::uuid &) |
Serialize boost::uuids::uuid to string. | |
constexpr long long | ToLongLong (BytesPerSecond x) |
constexpr bool | operator== (BytesPerSecond lhs, BytesPerSecond rhs) |
constexpr bool | operator!= (BytesPerSecond lhs, BytesPerSecond rhs) |
BytesPerSecond | StringToBytesPerSecond (const std::string &data) |
template<class Value > | |
BytesPerSecond | Parse (const Value &v, formats::parse::To< BytesPerSecond >) |
template<class T > | |
constexpr bool | operator== (const CachedHash< T > &x, const CachedHash< T > &y) |
Compares utils::CachedHash by hash first and then by keys. More... | |
template<class T > | |
constexpr bool | operator!= (const CachedHash< T > &x, const CachedHash< T > &y) |
Compares utils::CachedHash by hash first and then by keys. More... | |
template<typename T > | |
constexpr CheckedPtr< T > | MakeCheckedPtr (T *ptr) noexcept |
template<typename Container > | |
constexpr auto | enumerate (Container &&iterable) |
Implementation of python-style enumerate function for range-for loops. More... | |
template<typename T = std::runtime_error> | |
void | LogErrorAndThrow (const std::string &error_message) |
Logs error_message and throws an exception ith that message. More... | |
template<class GeneratorFunc > | |
auto | GenerateFixedArray (std::size_t size, GeneratorFunc &&generator) |
Applies generator to indices in the range [0, size) , storing the results in a new utils::FixedArray. The generator is guaranteed to be invoked in the first-to-last order. More... | |
template<typename Enum > | |
constexpr Flags< Enum > | operator| (Enum, Flags< Enum >) |
template<typename Enum > | |
constexpr Flags< Enum > | operator& (Enum, Flags< Enum >) |
template<typename Enum > | |
constexpr bool | operator== (Enum, Flags< Enum >) |
template<typename Enum > | |
constexpr bool | operator!= (Enum, Flags< Enum >) |
template<typename Enum > | |
Flags< Enum > | operator| (Enum, const AtomicFlags< Enum > &) |
template<typename Enum > | |
Flags< Enum > | operator& (Enum, const AtomicFlags< Enum > &) |
template<typename Enum > | |
bool | operator== (Enum, const AtomicFlags< Enum > &) |
template<typename Enum > | |
bool | operator!= (Enum, const AtomicFlags< Enum > &) |
template<typename T > | |
T | FromString (const std::string &str) |
Extract the number contained in the string. No space characters or other extra characters allowed. Supported types: More... | |
template<typename Leaf > | |
constexpr auto * | GetIf (Leaf &&leaf) |
template<typename Root , typename Head , typename... Tail> | |
constexpr auto * | GetIf (Root &&root, Head &&head, Tail &&... tail) |
Dereferences a chain of indirections and compositions, returns nullptr if one of the chain elements is not set. More... | |
template<class Target , class... Args> | |
boost::intrusive_ptr< Target > | make_intrusive_ptr (Args &&... args) |
Factory function for boost::intrusive_ptr, like std::make_unique. More... | |
template<typename U , typename... Args> | |
SharedRef< U > | MakeSharedRef (Args &&... args) |
An equivalent of std::make_shared for SharedRef. More... | |
template<typename U , typename... Args> | |
UniqueRef< U > | MakeUniqueRef (Args &&... args) |
An equivalent of std::make_unique for UniqueRef. More... | |
template<class T , class U > | |
constexpr bool | operator== (OptionalRef< T > lhs, OptionalRef< U > rhs) noexcept |
template<class T , class U > | |
constexpr bool | operator!= (OptionalRef< T > lhs, OptionalRef< U > rhs) noexcept |
template<class T > | |
std::string | ToString (const std::optional< T > &from) |
Converts std::optional to a string, empty value represented as "--". More... | |
template<class... Ts> | |
Overloaded (Ts...) -> Overloaded< Ts... > | |
template<typename Container , typename Value > | |
void | ProjectedInsertOrAssign (Container &set, Value &&value) |
An equivalent of std::unordered_map::insert_or_assign for utils::ProjectedUnorderedSet and utils::ProjectedSet. More... | |
RandomBase & | DefaultRandom () |
Returns a thread-local UniformRandomBitGenerator. More... | |
template<typename T > | |
T | RandRange (T from_inclusive, T to_exclusive) |
Generates a random number in range [from, to) More... | |
template<typename T > | |
T | RandRange (T to_exclusive) |
Generates a random number in range [0, to) More... | |
uint32_t | Rand () |
Generate a random number in the whole uint32_t range. More... | |
bool | regex_match (std::string_view str, const regex &pattern) |
Determines whether the regular expression matches the entire target character sequence. | |
bool | regex_search (std::string_view str, const regex &pattern) |
Determines whether the regular expression matches anywhere in the target character sequence. | |
template<typename T > | |
bool | operator== (const SharedReadablePtr< T > &ptr, std::nullptr_t) |
template<typename T > | |
bool | operator== (std::nullptr_t, const SharedReadablePtr< T > &ptr) |
template<typename T > | |
bool | operator!= (const SharedReadablePtr< T > &ptr, std::nullptr_t) |
template<typename T > | |
bool | operator!= (std::nullptr_t, const SharedReadablePtr< T > &ptr) |
template<typename T , typename... Args> | |
SharedReadablePtr< T > | MakeSharedReadable (Args &&... args) |
std::chrono::milliseconds | StringToDuration (const std::string &data) |
Converts strings like "10s", "5d", "1h" to durations. More... | |
constexpr bool | operator& (StrongTypedefOps op, StrongTypedefOps mask) noexcept |
constexpr auto | operator| (StrongTypedefOps op1, StrongTypedefOps op2) noexcept |
template<class Tag , class T , StrongTypedefOps Ops> | |
std::ostream & | operator<< (std::ostream &os, const StrongTypedef< Tag, T, Ops > &v) |
Ostreams and Logging. More... | |
template<class Tag , class T , StrongTypedefOps Ops> | |
logging::LogHelper & | operator<< (logging::LogHelper &os, const StrongTypedef< Tag, T, Ops > &v) |
template<class Tag , class T , StrongTypedefOps Ops> | |
constexpr decltype(auto) | UnderlyingValue (const StrongTypedef< Tag, T, Ops > &v) noexcept |
template<class Tag , class T , StrongTypedefOps Ops> | |
constexpr T | UnderlyingValue (StrongTypedef< Tag, T, Ops > &&v) noexcept |
constexpr bool | IsStrongTypedefLoggable (StrongTypedefOps Ops) |
template<typename Tag , typename T , StrongTypedefOps Ops, typename Enable , typename ValueType > | |
std::enable_if_t< formats::common::kIsFormatValue< ValueType >, StrongTypedef< Tag, T, Ops, Enable > > | Parse (const ValueType &source, formats::parse::To< StrongTypedef< Tag, T, Ops, Enable > >) |
template<typename Tag , typename T , StrongTypedefOps Ops, typename Enable , typename TargetType > | |
TargetType | Serialize (const StrongTypedef< Tag, T, Ops, Enable > &object, formats::serialize::To< TargetType >) |
template<typename Tag , typename T , StrongTypedefOps Ops, typename Enable , typename StringBuilder > | |
void | WriteToStream (const StrongTypedef< Tag, T, Ops, Enable > &object, StringBuilder &sw) |
template<typename Tag , StrongTypedefOps Ops> | |
std::string | ToString (const StrongTypedef< Tag, std::string, Ops > &object) |
template<typename Tag , typename T , StrongTypedefOps Ops, typename = std::enable_if_t<meta::kIsInteger<T>>> | |
std::string | ToString (const StrongTypedef< Tag, T, Ops > &object) |
template<typename Target , typename Tag , typename T , StrongTypedefOps Ops, typename Enable > | |
constexpr Target | StrongCast (const StrongTypedef< Tag, T, Ops, Enable > &src) |
template<typename Target , typename Tag , typename T , StrongTypedefOps Ops, typename Enable > | |
constexpr Target | StrongCast (StrongTypedef< Tag, T, Ops, Enable > &&src) |
template<class Tag , class T , StrongTypedefOps Ops> | |
std::size_t | hash_value (const StrongTypedef< Tag, T, Ops > &v) |
std::string | GetCurrentThreadName () |
Get the name of the current thread. More... | |
void | SetCurrentThreadName (std::string_view name) |
Set the name of the current thread. More... | |
template<class T > | |
constexpr auto | UnderlyingValue (T v) noexcept |
Function that extracts integral value from enum or StrongTypedef. More... | |
template<typename Function , typename... Args> | |
auto | CriticalAsync (engine::TaskProcessor &task_processor, std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedCriticalAsync (engine::TaskProcessor &task_processor, std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | Async (engine::TaskProcessor &task_processor, std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedAsync (engine::TaskProcessor &task_processor, std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | Async (engine::TaskProcessor &task_processor, std::string name, engine::Deadline deadline, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedAsync (engine::TaskProcessor &task_processor, std::string name, engine::Deadline deadline, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | CriticalAsync (std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedCriticalAsync (std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | Async (std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedAsync (std::string name, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | Async (std::string name, engine::Deadline deadline, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | SharedAsync (std::string name, engine::Deadline deadline, Function &&f, Args &&... args) |
template<typename Function , typename... Args> | |
auto | AsyncBackground (std::string name, engine::TaskProcessor &task_processor, Function &&f, Args &&... args) |
int | DaemonMain (int argc, const char *const argv[], const components::ComponentList &components_list) |
template<typename Cache > | |
LazySharedPtr< typename Cache::DataType > | MakeLazyCachePtr (Cache &cache) |
Make a lazy pointer to the data of a cache. More... | |
const char * | GetUserverVersion () noexcept |
const char * | GetUserverVcsRevision () noexcept |
const char * | GetUserverIdentifier () noexcept |
template<class Tag , class T , StrongTypedefOps Ops> | |
void | PrintTo (const StrongTypedef< Tag, T, Ops > &v, std::ostream *os) |
Variables | |
constexpr bool | kStrictMatch = true |
Helper constant to use with FastPimpl. More... | |
Utilities.
using utils::NonLoggable = typedef StrongTypedef< Tag, T, StrongTypedefOps::kCompareStrong | StrongTypedefOps::kNonLoggable> |
A StrongTypedef for data that MUST NOT be logged or outputted in some other way. Also prevents the data from appearing in backtrace prints of debugger.
Definition at line 413 of file strong_typedef.hpp.
using utils::void_t = typedef std::void_t<T...> |
std::void_t implementation with workarounds for compiler bugs
Definition at line 15 of file void_t.hpp.
|
strong |
Enumerator | |
---|---|
kCompareStrong | Forbid all comparisons for StrongTypedef. |
kCompareTransparentOnly | Allow comparing two StrongTypedef<Tag, T> |
kCompareTransparent | Allow comparing StrongTypedef<Tag, T> and T. |
kNonLoggable | Allow both of the above. |
Definition at line 29 of file strong_typedef.hpp.
ValueType utils::AnyCast | ( | AnyMovable && | operand | ) |
BadAnyMovableCast | if type of the data stored in operand does not match ValueType |
Definition at line 219 of file any_movable.hpp.
ValueType utils::AnyCast | ( | AnyMovable & | operand | ) |
BadAnyMovableCast | if type of the data stored in operand does not match ValueType |
Definition at line 201 of file any_movable.hpp.
|
noexcept |
Definition at line 189 of file any_movable.hpp.
ValueType utils::AnyCast | ( | const AnyMovable & | operand | ) |
BadAnyMovableCast | if type of the data stored in operand does not match ValueType |
Definition at line 211 of file any_movable.hpp.
|
noexcept |
Definition at line 194 of file any_movable.hpp.
ToContainer utils::AsContainer | ( | FromContainer && | container | ) |
auto utils::CheckedFind | ( | Map & | map, |
const Key & | key | ||
) | -> decltype(utils::MakeCheckedPtr(&map.find(key)->second)) |
bool utils::ContainsIf | ( | const Container & | container, |
Pred | pred | ||
) |
int utils::DaemonMain | ( | int | argc, |
const char *const | argv[], | ||
const components::ComponentList & | components_list | ||
) |
Parses command line arguments and calls components::Run with config file from –config parameter.
Other command line argumants:
RandomBase & utils::DefaultRandom | ( | ) |
Returns a thread-local UniformRandomBitGenerator.
Random
instance is not cryptographically secure Random
across thread boundaries
|
constexpr |
Implementation of python-style enumerate function for range-for loops.
iterable | Container to iterate |
Definition at line 64 of file enumerate.hpp.
size_t utils::Erase | ( | Container & | container, |
const T & | elem | ||
) |
auto utils::EraseIf | ( | Container & | container, |
Pred | pred | ||
) |
std::optional< typename Map::mapped_type > utils::FindOptional | ( | Map & | map, |
const Key & | key | ||
) |
Map::mapped_type utils::FindOrDefault | ( | Map & | map, |
const Key & | key | ||
) |
Map::mapped_type utils::FindOrDefault | ( | Map & | map, |
const Key & | key, | ||
Default && | def | ||
) |
auto * utils::FindOrNullptr | ( | Map & | map, |
const Key & | key | ||
) |
T utils::FromString | ( | const std::string & | str | ) |
Extract the number contained in the string. No space characters or other extra characters allowed. Supported types:
Parse YAML from string.
std::strtod
.T | The type of the number to be parsed |
str | The string that contains the number |
std::runtime_error | if the string does not contain an integer or floating-point number in the specified format, or the string contains extra junk, or the number does not fit into the provided type |
Definition at line 45 of file from_string.hpp.
auto utils::GenerateFixedArray | ( | std::size_t | size, |
GeneratorFunc && | generator | ||
) |
Applies generator
to indices in the range [0, size)
, storing the results in a new utils::FixedArray. The generator is guaranteed to be invoked in the first-to-last order.
size | How many objects to generate |
generator | A functor that takes an index and returns an object for the FixedArray |
FixedArray
with the return objects of generator
Definition at line 175 of file fixed_array.hpp.
std::string utils::GetCurrentThreadName | ( | ) |
Get the name of the current thread.
Thread names should only be used for debugging purposes. Thread names aren't required to be preserved exactly due to the system limit on thread name length.
std::system_error | on error |
|
constexpr |
Definition at line 29 of file get_if.hpp.
|
constexpr |
Dereferences a chain of indirections and compositions, returns nullptr if one of the chain elements is not set.
Definition at line 42 of file get_if.hpp.
|
noexcept |
|
noexcept |
|
noexcept |
std::size_t utils::hash_value | ( | const StrongTypedef< Tag, T, Ops > & | v | ) |
Definition at line 404 of file strong_typedef.hpp.
|
constexpr |
Definition at line 329 of file strong_typedef.hpp.
void utils::LogErrorAndThrow | ( | const std::string & | error_message | ) |
Logs error_message and throws an exception ith that message.
Definition at line 17 of file exception.hpp.
boost::intrusive_ptr< Target > utils::make_intrusive_ptr | ( | Args &&... | args | ) |
Factory function for boost::intrusive_ptr, like std::make_unique.
Definition at line 16 of file make_intrusive_ptr.hpp.
|
constexprnoexcept |
Definition at line 73 of file checked_pointer.hpp.
LazySharedPtr< typename Cache::DataType > utils::MakeLazyCachePtr | ( | Cache & | cache | ) |
Make a lazy pointer to the data of a cache.
The cache type must have:
DataType
member type;Get() -> utils::SharedReadablePtr<DataType>
method.For example, components::CachingComponentBase satisfies these requirements.
Definition at line 152 of file lazy_shared_ptr.hpp.
SharedReadablePtr< T > utils::MakeSharedReadable | ( | Args &&... | args | ) |
Definition at line 137 of file shared_readable_ptr.hpp.
SharedRef< U > utils::MakeSharedRef | ( | Args &&... | args | ) |
An equivalent of std::make_shared
for SharedRef.
Definition at line 115 of file not_null.hpp.
UniqueRef< U > utils::MakeUniqueRef | ( | Args &&... | args | ) |
An equivalent of std::make_unique
for UniqueRef.
Definition at line 121 of file not_null.hpp.
|
constexpr |
Definition at line 27 of file bytes_per_second.hpp.
|
constexpr |
Compares utils::CachedHash by hash first and then by keys.
Definition at line 28 of file cached_hash.hpp.
bool utils::operator!= | ( | const SharedReadablePtr< T > & | ptr, |
std::nullptr_t | |||
) |
Definition at line 127 of file shared_readable_ptr.hpp.
bool utils::operator!= | ( | Enum | lhs, |
const AtomicFlags< Enum > & | rhs | ||
) |
|
constexpr |
|
constexprnoexcept |
Definition at line 106 of file optional_ref.hpp.
bool utils::operator!= | ( | std::nullptr_t | , |
const SharedReadablePtr< T > & | ptr | ||
) |
Definition at line 132 of file shared_readable_ptr.hpp.
Flags< Enum > utils::operator& | ( | Enum | lhs, |
const AtomicFlags< Enum > & | rhs | ||
) |
|
constexprnoexcept |
Definition at line 39 of file strong_typedef.hpp.
logging::LogHelper & utils::operator<< | ( | logging::LogHelper & | os, |
const StrongTypedef< Tag, T, Ops > & | v | ||
) |
Definition at line 311 of file strong_typedef.hpp.
std::ostream & utils::operator<< | ( | std::ostream & | os, |
const StrongTypedef< Tag, T, Ops > & | v | ||
) |
Ostreams and Logging.
Definition at line 304 of file strong_typedef.hpp.
|
constexpr |
Definition at line 23 of file bytes_per_second.hpp.
|
constexpr |
Compares utils::CachedHash by hash first and then by keys.
Definition at line 22 of file cached_hash.hpp.
bool utils::operator== | ( | const SharedReadablePtr< T > & | ptr, |
std::nullptr_t | |||
) |
Definition at line 117 of file shared_readable_ptr.hpp.
bool utils::operator== | ( | Enum | lhs, |
const AtomicFlags< Enum > & | rhs | ||
) |
|
constexpr |
|
constexprnoexcept |
Definition at line 100 of file optional_ref.hpp.
bool utils::operator== | ( | std::nullptr_t | , |
const SharedReadablePtr< T > & | ptr | ||
) |
Definition at line 122 of file shared_readable_ptr.hpp.
Flags< Enum > utils::operator| | ( | Enum | lhs, |
const AtomicFlags< Enum > & | rhs | ||
) |
|
constexprnoexcept |
Definition at line 43 of file strong_typedef.hpp.
BytesPerSecond utils::Parse | ( | const Value & | v, |
formats::parse::To< BytesPerSecond > | |||
) |
Definition at line 36 of file bytes_per_second.hpp.
std::enable_if_t< formats::common::kIsFormatValue< ValueType >, StrongTypedef< Tag, T, Ops, Enable > > utils::Parse | ( | const ValueType & | source, |
formats::parse::To< StrongTypedef< Tag, T, Ops, Enable > > | |||
) |
Definition at line 339 of file strong_typedef.hpp.
void utils::PrintTo | ( | const StrongTypedef< Tag, T, Ops > & | v, |
std::ostream * | os | ||
) |
void utils::ProjectedInsertOrAssign | ( | Container & | set, |
Value && | value | ||
) |
An equivalent of std::unordered_map::insert_or_assign
for utils::ProjectedUnorderedSet and utils::ProjectedSet.
Definition at line 104 of file projected_set.hpp.
uint32_t utils::Rand | ( | ) |
Generate a random number in the whole uint32_t
range.
Rand() % N
, use RandRange
instead T utils::RandRange | ( | T | from_inclusive, |
T | to_exclusive | ||
) |
T utils::RandRange | ( | T | to_exclusive | ) |
TargetType utils::Serialize | ( | const StrongTypedef< Tag, T, Ops, Enable > & | object, |
formats::serialize::To< TargetType > | |||
) |
Definition at line 347 of file strong_typedef.hpp.
void utils::SetCurrentThreadName | ( | std::string_view | name | ) |
Set the name of the current thread.
This function should only be used from drivers that create their own threads! Users should normally rely on the coroutine engine instead of creating additional threads.
There is a system limit on thread name length, e.g. 15 chars on Linux. The name is automatically cut to fit the limit.
name | the new thread name |
std::system_error | on error |
std::string utils::StrCat | ( | const Strings &... | strings | ) |
BytesPerSecond utils::StringToBytesPerSecond | ( | const std::string & | data | ) |
Understands all the date-rate unit suffixes from https://en.wikipedia.org/wiki/Data-rate_units#Conversion_table
std::chrono::milliseconds utils::StringToDuration | ( | const std::string & | data | ) |
Converts strings like "10s", "5d", "1h" to durations.
Understands the following suffixes: s - seconds ms - milliseconds m - minutes h - hours d - days
|
constexpr |
Explicitly cast from one strong typedef to another, to replace constructions SomeStrongTydef{utils::UnderlyingValue(another_strong_val)}
with utils::StrongCast<SomeStrongTydef>(another_strong_val)
Definition at line 383 of file strong_typedef.hpp.
|
constexpr |
Definition at line 394 of file strong_typedef.hpp.
|
constexpr |
Definition at line 19 of file bytes_per_second.hpp.
std::string utils::ToString | ( | const std::optional< T > & | from | ) |
Converts std::optional to a string, empty value represented as "--".
Definition at line 18 of file optionals.hpp.
std::string utils::ToString | ( | const StrongTypedef< Tag, std::string, Ops > & | object | ) |
Definition at line 362 of file strong_typedef.hpp.
std::string utils::ToString | ( | const StrongTypedef< Tag, T, Ops > & | object | ) |
Definition at line 370 of file strong_typedef.hpp.
|
constexprnoexcept |
Definition at line 319 of file strong_typedef.hpp.
|
constexprnoexcept |
Definition at line 325 of file strong_typedef.hpp.
|
constexprnoexcept |
Function that extracts integral value from enum or StrongTypedef.
Definition at line 14 of file underlying_value.hpp.
void utils::WriteToStream | ( | const StrongTypedef< Tag, T, Ops, Enable > & | object, |
StringBuilder & | sw | ||
) |
Definition at line 355 of file strong_typedef.hpp.
|
inlineconstexpr |
Helper constant to use with FastPimpl.
Definition at line 16 of file fast_pimpl.hpp.