[#util]
= util
:mrdocs:

Bitcoin Core utility helpers shared across the codebase&period;

== Namespaces

[cols="1,4"]
|===
| Name| Description
| xref:util/log.adoc[`log`] 
| Application&hyphen;agnostic logging interface shared across Bitcoin Core&period;
|===


== Types

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


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:util/LockResult.adoc[`LockResult`] 
| Outcome of trying to acquire a directory lock&period;
|===


== Functions

[cols="1,4"]
|===
| Name| Description
| xref:util/AnyPtr.adoc[`AnyPtr`] 
| Helper function to access the contained object of a std&colon;&colon;any instance&period; Returns a pointer to the object if passed instance has a value and the type matches, nullptr otherwise&period;
| xref:util/ConstevalHexDigit.adoc[`ConstevalHexDigit`] 
| consteval version of HexDigit() without the lookup table&period;
| xref:util/ContainsNoNUL.adoc[`ContainsNoNUL`] 
| Check if a string does not contain any embedded NUL (0) characters
| xref:util/ErrorString-0d.adoc[`ErrorString`] 
| Extracts the error message from a result&period;
| xref:util/ExecVp.adoc[`ExecVp`] 
| Cross&hyphen;platform wrapper for POSIX execvp function&period; 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&period;
| xref:util/GetExePath.adoc[`GetExePath`] 
| Return path to current executable assuming it was invoked with argv0&period; If path could not be determined, returns an empty path&period;
| xref:util/HasPrefix.adoc[`HasPrefix`] 
| Check whether a container begins with the given prefix&period;
| xref:util/Join-07.adoc[`Join`] 
| `Join` overloads
| xref:util/LockDirectory.adoc[`LockDirectory`] 
| Acquire an exclusive lock on a directory via a lock file&period;
| xref:util/MakeUnorderedList.adoc[`MakeUnorderedList`] 
| Create an unordered multi&hyphen;line list of items&period;
| xref:util/RemovePrefix.adoc[`RemovePrefix`] 
| Return a copy of str with the given prefix removed, if present&period;
| xref:util/RemovePrefixView.adoc[`RemovePrefixView`] 
| Return a view of str with the given prefix removed, if present&period;
| xref:util/RemoveSuffixView.adoc[`RemoveSuffixView`] 
| Return a view of str with the given suffix removed, if present&period;
| xref:util/ReplaceAll.adoc[`ReplaceAll`] 
| Replace every occurrence of a substring in place&period;
| xref:util/Split-0b.adoc[`Split`] 
| `Split` overloads
| xref:util/SplitString-0e.adoc[`SplitString`] 
| `SplitString` overloads
| xref:util/ThreadGetInternalName.adoc[`ThreadGetInternalName`] 
| Get the thread&apos;s internal (in&hyphen;memory) name&semi; used e&period;g&period; for identification in logging&period;
| xref:util/ThreadRename.adoc[`ThreadRename`] 
| Rename a thread both in terms of an internal (in&hyphen;memory) name as well as its system thread name&period;
| xref:util/ThreadSetInternalName.adoc[`ThreadSetInternalName`] 
| Set the internal (in&hyphen;memory) name of the current thread only&period;
| xref:util/ToString.adoc[`ToString`] 
| Locale&hyphen;independent version of std&colon;&colon;to&lowbar;string
| xref:util/TraceThread.adoc[`TraceThread`] 
| A wrapper for do&hyphen;something&hyphen;once thread functions&period;
| xref:util/TrimString.adoc[`TrimString`] 
| Return a copy of str with leading and trailing pattern characters removed&period;
| xref:util/TrimStringView.adoc[`TrimStringView`] 
| Return a view of str with leading and trailing pattern characters removed&period;
| xref:util/insert-0b.adoc[`insert`] 
| `insert` overloads
| xref:util/operator_hex.adoc[`operator&quot;&quot;&lowbar;hex`] 
| Compile&hyphen;time hex literal returning a `std&colon;&colon;array&lt;std&colon;&colon;byte, N&sol;2&gt;`&period;
| xref:util/operator_hex_u8.adoc[`operator&quot;&quot;&lowbar;hex&lowbar;u8`] 
| Compile&hyphen;time hex literal returning a `std&colon;&colon;array&lt;uint8&lowbar;t, N&sol;2&gt;`&period;
| xref:util/operator_hex_v.adoc[`operator&quot;&quot;&lowbar;hex&lowbar;v`] 
| Compile&hyphen;time hex literal returning a `std&colon;&colon;vector&lt;std&colon;&colon;byte&gt;`&period;
| xref:util/operator_hex_v_u8.adoc[`operator&quot;&quot;&lowbar;hex&lowbar;v&lowbar;u8`] 
| Compile&hyphen;time hex literal returning a `std&colon;&colon;vector&lt;uint8&lowbar;t&gt;`&period;
| xref:util/operator_plus-01.adoc[`operator&plus;`] 
| Addition operators
| xref:util/operator_lshift.adoc[`operator&lt;&lt;`] 
| Write the translated form of a literal to an output stream&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
