userver: Universal
Loading...
Searching...
No Matches
Universal

Detailed Description

Functions and classes that could be used with or without coroutine environment.

Those classes and functions reside in CMake target userver-universal, that is a base target for all the userver-* targets, so all these the classes and functions are available while using any of the userver parts.

See also
Non-Coroutine Console Tool for a usage example.

Files

file  using_namespace_userver.hpp
 For samples and snippets only! Has a using namespace / USERVER_NAMESPACE; if the USERVER_NAMESPACE is not empty.
 
file  json.hpp
 Include-all header for JSON support.
 
file  fwd.hpp
 Forward declarations of YamlConfig type and formats::parse::To.
 
file  exception.hpp
 Exception classes for JSON module.
 
file  inline.hpp
 Inline value builders.
 
file  str_icase.hpp
 Case insensitive ASCII comparators and hashers.
 
file  to.hpp
 Helper for parsers.
 
file  assert.hpp
 Assertion macros UASSERT, UASSERT_MSG, UINVARIANT and AbortWithStacktrace() function.
 
file  items.hpp
 Wrapper for handy python-like iteration over a map.
 
file  meta.hpp
 Metaprogramming helpers for converters detection.
 
file  common.hpp
 Parsers and converters for std::chrono::seconds, std::chrono::system_clock::time_point and integral types.
 
file  string_literal.hpp
 Non-empty string view to a compile time known null terminated char array that lives for the lifetime of program, as per [lex.string]; a drop-in replacement for static const std::string kVar = "value" and constexpr std::string_view kVar = "value".
 
file  to.hpp
 Helper for serializers.
 
file  select.hpp
 Utilities for selection of platform specific values.
 
file  atomic.hpp
 Helper algorithms to work with atomics.
 
file  meta_light.hpp
 Lightweight concepts.
 
file  from_string_saturating.hpp
 Saturating converters from strings to time points.
 
file  datetime_light.hpp
 Date and Time related converters.
 
file  meta.hpp
 Metaprogramming, template variables and concepts.
 
file  string_to_duration.hpp
 Converts strings like "10s", "5d", "1h" to durations.
 
file  zstring_view.hpp
 Non-empty string view type that guarantees null-termination and has a c_str() member function.
 
file  demangle.hpp
 Returns a human-readable representation of provided type name.
 
file  datetime.hpp
 Date, Time, and Timezone related converters.
 
file  merge_schemas.hpp
 Merge parent and child components schemas of static configs.
 
file  cpp_20_calendar.hpp
 This file brings date.h into utils::datetime::date namespace, which is std::chrono::operator/ (calendar) in c++20.
 
file  common_containers.hpp
 Parsers and converters for Standard Library containers and std::optional.
 
file  underlying_value.hpp
 Function that extracts integral value from enum or StrongTypedef.
 
file  exception.hpp
 Exception classes for YAML module.
 
file  decimal64.hpp
 Decimal data type for fixed-point arithmetic.
 
file  trivial_map_fwd.hpp
 Forward declarations of utils::TrivialBiMap and utils::TrivialSet types.
 
file  type.hpp
 Common enum of types.
 
file  format_options.hpp
 Structure storing format options for decimal.
 
file  assert_macros.hpp
 Extensions to the gtest macros for printing and testing exceptions that could work even without coroutine environment.
 
file  death_tests.hpp
 Contains facilities for testing service crashes.
 
file  hash.hpp
 Cryptographic hashing.
 
file  mock_now.hpp
 Mocking and getting mocked time values.
 
file  common_headers.hpp
 Common HTTP header names.
 
file  url.hpp
 URL manipulation functions.
 
file  algo.hpp
 Small useful algorithms.
 
file  from_string.hpp
 Extract the number contained in the string. No space characters or other extra characters allowed. Supported types:
 
file  algorithm.hpp
 Miscellaneous cryptographic routines.
 
file  base64.hpp
 Cryptographic hashing.
 
file  signers.hpp
 Digital signature generators.
 
file  verifiers.hpp
 Digital signature verifiers.
 
file  merge.hpp
 Add to original new non-object elements from patch (overwriting the old ones, if any) and merge object elements recursively.
 
file  utils.hpp
 formats::common::GetAtPath and formats::common::RemoveAtPath utils for Value and ValueBuilder
 
file  serialize_boost_variant.hpp
 Serializers for boost::variant types.
 
file  serialize_duration.hpp
 Serializers for std::chrono::duration types.
 
file  serialize_variant.hpp
 Serializers for std::variant. Deprecated include, use userver/formats/serialize/variant.hpp instead of.
 
file  boost_optional.hpp
 Parsers and converters for boost::optional.
 
file  boost_uuid.hpp
 boost::uuids::uuid parser for any format
 
file  boost_variant.hpp
 Ineffective but generic parser for boost::variant type.
 
file  time_of_day.hpp
 utils::datetime::TimeOfDay parser for any format
 
file  variant.hpp
 Ineffective but generic parser for std::variant type.
 
file  boost_optional.hpp
 Serializers for boost::optional.
 
file  boost_uuid.hpp
 boost::uuids::uuid serializer to any format
 
file  common_containers.hpp
 Serializers for standard containers and optional.
 
file  time_of_day.hpp
 utils::datetime::TimeOfDay to any format
 
file  variant.hpp
 Serializers for std::variant.
 
file  write_to_stream.hpp
 Common WriteToStream functions for SAX serializers.
 
file  yaml.hpp
 Include-all header for YAML support.
 
file  open_mode.hpp
 A set of OpenFlags.
 
file  read.hpp
 functions for synchronous (blocking) file read operations
 
file  write.hpp
 Functions for synchronous (blocking) file write operations.
 
file  get_hostname.hpp
 Returns host name.
 
file  read_groups.hpp
 Reads Conductor groups from conductor-hostinfo file.
 
file  cpu_limit.hpp
 Information about CPU limits in container.
 
file  http_request_parse_args.hpp
 Strict URL arguments parsing.
 
file  bytes_per_second.hpp
 Data type that represents bytes per second unit.
 
file  timepoint_tz.hpp
 Timepoint with timezone.
 
file  hex.hpp
 Encoders, decoders and helpers for hexadecimal representations.
 
file  tskv.hpp
 Encoders, decoders and helpers for TSKV representations.
 
file  enumerate.hpp
 Implementation of python-style enumerate function for range-for loops.
 
file  get_if.hpp
 
 
file  make_intrusive_ptr.hpp
 Factory function for boost::intrusive_ptr, like std::make_unique.
 
file  optionals.hpp
 Helper functions for std optionals.
 
file  rand.hpp
 Random number generators.
 
file  str_icase_containers.hpp
 Contains utilities for working with containers with utils::StrCaseHash and utils::StrIcaseHash.
 
file  text_light.hpp
 Text utilities that do not use locales.
 
file  thread_name.hpp
 Functions for thread name manipulation.
 
file  threads.hpp
 Functions to work with OS threads.
 
file  uuid4.hpp
 Generate a UUIDv4 string.
 
file  uuid7.hpp
 Generate a UUIDv7 string.
 
file  serialize_duration.hpp
 Serializers for std::chrono::duration types.
 

Classes

class  http::ContentType
 Content-Type representation. More...
 
class  utils::FastPimpl< T, Size, Alignment, Strict >
 Implements pimpl idiom without dynamic memory allocation. More...
 
class  utils::NotNull< T >
 Restricts a pointer or smart pointer to only hold non-null values. More...
 
class  formats::json::Value
 Non-mutable JSON value representation. More...
 
class  formats::json::ValueBuilder
 Builder for JSON. More...
 
struct  utils::datetime::WallCoarseClock
 System clock with up to a few millisecond resolution that is slightly faster than the std::chrono::system_clock. More...
 
class  utils::AnyMovable
 Replacement for std::any that is not copyable. It allows to store non-copyable and even non-movable types. More...
 
struct  formats::parse::To< T >
 
class  crypto::Certificate
 
class  crypto::PrivateKey
 
class  utils::Flags< Enum >
 Wrapper to extend enum with flags interface. More...
 
class  utils::AtomicFlags< Enum >
 Wrapper to extend enum with atomic flags interface. More...
 
struct  yaml_config::Schema
 JSON Schema-like type definition. More...
 
class  http::headers::HeaderMap
 Container that maps case-insensitive header name into header value. More...
 
class  utils::FastScopeGuard< Callback >
 a helper class to perform actions on scope exit More...
 
struct  formats::serialize::To< T >
 
class  http::headers::PredefinedHeader
 A struct to represent compile-time known header name. More...
 
class  yaml_config::YamlConfig
 Datatype that represents YAML with substituted variables. More...
 
class  utils::SlidingInterval< T >
 Sliding interval of values that provides functions to compute average, min and max values from the last window_size values of interval. More...
 
class  utils::FixedArray< T >
 A fixed-size array with the size determined at runtime. More...
 
class  utils::TrivialBiMap< BuilderFunc >
 Bidirectional unordered map for trivial types, including string literals; could be efficiently used as a unordered non-bidirectional map. More...
 
class  utils::TrivialSet< BuilderFunc >
 Unordered set for trivial types, including string literals. More...
 
class  formats::yaml::Value
 Non-mutable YAML value representation. More...
 
class  utils::TracefulException
 Exception that remembers the backtrace at the point of its construction. More...
 
class  decimal64::Decimal< Prec, TRoundPolicy >
 Fixed-point decimal data type for use in deterministic calculations, oftentimes involving money. More...
 
class  utils::datetime::TimeOfDay< Duration >
 A simple implementation of a "time since midnight" datatype. More...
 
class  utils::OptionalRef< T >
 Class that behaves as a nullable reference. Main difference from the pointer - value comparison of pointed values. More...
 
class  formats::common::Path
 
class  utils::TokenBucket
 
class  utils::InvariantError
 Exception that is thrown on UINVARIANT violation. More...
 
class  utils::datetime::Date
 Date in format YYYY-MM-DD, std::chrono::year_month_day like type. More...
 
class  utils::CheckedPtr< T >
 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  cache::LruMap< T, U, Hash, Equal >
 
class  cache::LruSet< T, Hash, Equal >
 
class  crypto::PublicKey
 
class  crypto::SslCtx
 
class  formats::json::StringBuilder
 SAX like builder of JSON string. Use with extreme caution and only in performance critical part of your code. More...
 
class  formats::yaml::ValueBuilder
 Builder for YAML. More...
 
class  fs::blocking::CFile
 A std::FILE* wrapper. More...
 
class  fs::blocking::FileDescriptor
 A file descriptor wrapper. More...
 
class  fs::blocking::TempDirectory
 A unique directory for temporary files. The directory is deleted when the TempDirectory is destroyed. More...
 
class  fs::blocking::TempFile
 A unique temporary file. The file is deleted when the TempFile object is destroyed. More...
 
class  utils::AnyStorage< StorageTag >
 map-like heterogeneous data storage More...
 
struct  utils::CachedHash< Key >
 Holds the key and its hash for faster comparisons and hashing. More...
 
struct  utils::datetime::SteadyCoarseClock
 Steady clock with up to a few millisecond resolution that is slightly faster than the std::chrono::steady_clock. More...
 
class  utils::DefaultDict< ValueType >
 Dictionary that for missing keys falls back to a default value stored by key utils::kDefaultDictDefaultName. More...
 
class  utils::expected< S, E >
 For holding a value or an error. More...
 
class  utils::FilterBloom< T, Counter, Hash1, Hash2 >
 Space-efficient probabilistic data structure. More...
 
class  utils::LazyPrvalue< Func >
 Can be used with various emplace functions to allow in-place constructing a non-movable value using a callable. More...
 
struct  utils::Overloaded< Ts >
 Utility to define std::variant visitors in a simple way. More...
 
class  utils::regex
 A drop-in replacement for std::regex without huge includes and with better performance characteristics. More...
 
class  utils::match_results
 A drop-in replacement for std::match_results without huge includes and with better performance characteristics. Represents capturing groups of a single match result. More...
 
class  utils::ResultStore< T >
 
class  utils::ResultStore< void >
 
class  utils::ScopeGuard
 a helper class to perform actions on scope exit More...
 
class  utils::SharedReadablePtr< T >
 std::shared_ptr<const T> wrapper that makes sure that the pointer is stored before dereferencing. Protects from dangling references. More...
 
class  utils::SmallString< N >
 An alternative to std::string with a custom SSO (small string optimization) container size. Unlike std::string, SmallString is not null-terminated thus it has no c_str(), data() returns a not null-terminated buffer. More...
 
class  utils::StrongTypedef< Tag, T, Ops, class >
 Strong typedef for a type T. More...
 

Macros

#define USERVER_FILEPATH
 Short std::string_view with source path for logging.
 

Typedefs

template<typename U>
using utils::SharedRef = NotNull<std::shared_ptr<U>>
 A std::shared_ptr that is guaranteed to be not-null.
 
template<typename U>
using utils::UniqueRef = NotNull<std::unique_ptr<U>>
 A std::unique_ptr that is guaranteed to be not-null.
 
template<typename... T>
using utils::void_t = std::void_t<T...>
 std::void_t implementation with workarounds for compiler bugs
 
template<typename Value, auto Projection, typename Hash = void, typename Equal = std::equal_to<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedUnorderedSet
 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.
 
template<typename Value, auto Projection, typename Compare = std::less<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedSet = std::set<Value, impl::projected_set::Compare<Value, Projection, Compare>, Allocator>
 Same as utils::ProjectedUnorderedSet, but for std::set.
 

Enumerations

enum class  utils::BytesPerSecond : long long
 Data type that represents bytes per second unit. More...
 

Macro Definition Documentation

◆ USERVER_FILEPATH

#define USERVER_FILEPATH

Short std::string_view with source path for logging.

Definition at line 19 of file log_filepath.hpp.

Typedef Documentation

◆ ProjectedSet

template<typename Value, auto Projection, typename Compare = std::less<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedSet = std::set<Value, impl::projected_set::Compare<Value, Projection, Compare>, Allocator>

Same as utils::ProjectedUnorderedSet, but for std::set.

Definition at line 106 of file projected_set.hpp.

◆ ProjectedUnorderedSet

template<typename Value, auto Projection, typename Hash = void, typename Equal = std::equal_to<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedUnorderedSet
Initial value:
utils::impl::TransparentSet<
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.

Usage example:

struct User {
std::string username;
std::string first_name;
int age{};
};
inline constexpr auto kUserKey = &User::username;
UserProjectedSet set;
set.insert({"fabulous_tony", "Anthony", 17});
set.insert({"sassy_nancy", "Anne", 71});
EXPECT_EQ(utils::ProjectedFind(set, "sassy_nancy")->first_name, "Anne");
EXPECT_EQ(utils::ProjectedFind(set, "meaning_of_life"), set.end());
See also
utils::ProjectedInsertOrAssign
utils::ProjectedFind

Definition at line 97 of file projected_set.hpp.

◆ SharedRef

template<typename U>
using utils::SharedRef = NotNull<std::shared_ptr<U>>

A std::shared_ptr that is guaranteed to be not-null.

See also
MakeSharedRef

Definition at line 99 of file not_null.hpp.

◆ UniqueRef

template<typename U>
using utils::UniqueRef = NotNull<std::unique_ptr<U>>

A std::unique_ptr that is guaranteed to be not-null.

See also
MakeUniqueRef

Definition at line 106 of file not_null.hpp.

◆ void_t

template<typename... T>
using utils::void_t = std::void_t<T...>

std::void_t implementation with workarounds for compiler bugs

Definition at line 17 of file void_t.hpp.

Enumeration Type Documentation

◆ BytesPerSecond

enum class utils::BytesPerSecond : long long
strong

Data type that represents bytes per second unit.

Definition at line 18 of file bytes_per_second.hpp.