util

Application-agnostic logging interface shared across Bitcoin Core.

Namespaces

NameDescription
log Application-agnostic logging interface shared across Bitcoin Core.

Types

NameDescription
BadExpectedAccess Exception thrown when the value of an errored util::Expected is accessed.
BilingualFmt Compile-time bilingual format string carrying a checked format and its translatable literal.
ConstevalFormatString A wrapper for a compile-time partially validated format string
Error Wraps a failure message used to construct a util::Result in the error state.
Expected The util::Expected class provides a standard way for low-level functions to return either error values or result values.
ImmediateTaskRunner Task runner that processes each callback synchronously on insertion.
LineReader Reads a character buffer line by line or in fixed-length chunks.
Overloaded Overloaded helper for std::visit. This helper and std::visit in general are useful to write code that switches on a variant type. Unlike if/else-if and switch/case statements, std::visit will trigger compile errors if there are unhandled cases.
Result The util::Result class provides a standard way for functions to return either error messages or result values.
SignalInterrupt Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another thread.
TaskRunnerInterface This header provides an interface and simple implementation for a task runner. Another threaded, serial implementation using a queue is available in the scheduler module's SerialTaskRunner.
TokenBucket A token bucket rate limiter.
TranslatedLiteral Compile-time literal string that can be translated with an optional translation function.
Unexpected The util::Unexpected class represents an unexpected value stored in util::Expected.

Enums

NameDescription
LockResult Outcome of trying to acquire a directory lock.

Functions

NameDescription
AnyPtr Helper function to access the contained object of a std::any instance. Returns a pointer to the object if passed instance has a value and the type matches, nullptr otherwise.
ConstevalHexDigit consteval version of HexDigit() without the lookup table.
ContainsNoNUL Check if a string does not contain any embedded NUL (0) characters
ErrorString Extracts the error message from a result.
ExecVp Cross-platform wrapper for POSIX execvp function. Arguments and return value are the same as for POSIX execvp, and the argv array should consist of null terminated strings and be null terminated itself, like the POSIX function.
GetExePath Return path to current executable assuming it was invoked with argv0. If path could not be determined, returns an empty path.
HasPrefix Check whether a container begins with the given prefix.
Join Join overloads
LockDirectory Acquire an exclusive lock on a directory via a lock file.
MakeUnorderedList Create an unordered multi-line list of items.
RemovePrefix Return a copy of str with the given prefix removed, if present.
RemovePrefixView Return a view of str with the given prefix removed, if present.
RemoveSuffixView Return a view of str with the given suffix removed, if present.
ReplaceAll Replace every occurrence of a substring in place.
Split Split overloads
SplitString SplitString overloads
ThreadGetInternalName Get the thread's internal (in-memory) name; used e.g. for identification in logging.
ThreadRename Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
ThreadSetInternalName Set the internal (in-memory) name of the current thread only.
ToString Locale-independent version of std::to_string
TraceThread A wrapper for do-something-once thread functions.
TrimString Return a copy of str with leading and trailing pattern characters removed.
TrimStringView Return a view of str with leading and trailing pattern characters removed.
insert insert overloads
operator""_hex Compile-time hex literal returning a std::array<std::byte, N/2>.
operator""_hex_u8 Compile-time hex literal returning a std::array<uint8_t, N/2>.
operator""_hex_v Compile-time hex literal returning a std::vector<std::byte>.
operator""_hex_v_u8 Compile-time hex literal returning a std::vector<uint8_t>.
operator+ Addition operators
operator<< Write the translated form of a literal to an output stream.