CatapultServer  v0.5.0.1 (Elephant)
catapult::utils Namespace Reference

Namespaces

 detail
 
 log
 
 traits
 

Classes

struct  ArrayHasher
 
struct  ArrayPointerEquality
 Functor for comparing two array pointers. More...
 
struct  ArrayPointerHasher
 Functor for hashing an array pointer. More...
 
class  AtomicIncrementDecrementGuard
 RAII class that increments an atomic on construction and decrements it on destruction. More...
 
class  BaseValue
 Immutable wrapper for basic types, to provide some type-safety. More...
 
struct  BaseValueHasher
 Hasher object for a base value. More...
 
class  BasicBaseValue
 Base class for immutable wrappers of basic types, to provide some type-safety. More...
 
struct  BasicLoggerOptions
 Basic logger options. More...
 
class  BasicRawBuffer
 Basic raw buffer that is composed of a pointer and a size. More...
 
class  BasicSpinReaderWriterLock
 
class  BlockSpan
 Represents a block duration. More...
 
class  ByteArray
 Base class for wrappers of byte array types, to provide some type-safety. More...
 
class  CheckedArray
 An array that checks for overflow. More...
 
class  CircularBuffer
 A fixed size circular buffer. More...
 
struct  ClampedBaseValue
 Base values that are constrained to a range of values. More...
 
class  ConfigurationBag
 A simple bag of properties. More...
 
struct  ConfigurationKey
 A configuration key. More...
 
class  ContainerHexFormatter
 Formatter for printing a container of integral hex numbers to a stream. More...
 
class  DiagnosticCounter
 A diagnostic counter. More...
 
class  DiagnosticCounterId
 A diagnostic counter id. More...
 
struct  FileLoggerOptions
 File logger options. More...
 
class  FileSize
 Represents a file size. More...
 
class  IdentifierGroup
 A group of identifiers that share a common (external) attribute. More...
 
class  ImmutableValue
 A move-only value wrapper. More...
 
class  IntegralHexFormatter
 Formatter for printing an integral hex number to a stream. More...
 
class  IntegralHexFormatterGuard
 
struct  LogFilter
 Filter used for filtering logs by level and/or component. More...
 
class  LoggingBootstrapper
 Bootstraps boost logging. More...
 
class  ModificationSafeIterableContainer
 Wraps a container type and provides modification-safe iteration support. More...
 
class  MoveOnly
 A class that can be moved but not copied. More...
 
class  MutableRawString
 A mutable string buffer. More...
 
class  NamedObjectMixin
 Mixin to have named objects. More...
 
class  NonCopyable
 A class that can neither be copied nor moved. More...
 
struct  NoOpReaderNotificationPolicy
 A no-op reader notification policy. More...
 
class  property_malformed_error
 Exception class that is thrown when a configuration property is malformed. More...
 
class  property_not_found_error
 Exception class that is thrown when a required configuration property is missing. More...
 
class  RawString
 A const string buffer. More...
 
class  reader_reentrancy_error
 Exception class that is thrown when reader reentrancy is detected. More...
 
class  ReentrancyCheckReaderNotificationPolicy
 A reentrancy check reader notification policy. More...
 
class  ResettableWrappedWithOwnerDecorator
 
struct  ShortHash_tag
 
struct  ShortHashHasher
 
class  SlowOperationLogger
 Simple RAII class that logs slow operation messages. More...
 
class  SpinLock
 
class  StackLogger
 Simple RAII class that logs scope messages. More...
 
class  StackTimer
 Stack based timer. More...
 
class  StreamFormatGuard
 
class  ThrottleLogger
 
class  TimeSpan
 Represents a time duration. More...
 
class  WeakContainer
 A container of weak_ptr<T> pointing to closable items. More...
 
class  WrappedWithOwnerDecorator
 

Typedefs

template<typename TArray >
using ArraySet = std::unordered_set< TArray, ArrayHasher< TArray > >
 A set of arrays. More...
 
template<typename TArray >
using ArrayPointerSet = std::unordered_set< const TArray *, ArrayPointerHasher< TArray >, ArrayPointerEquality< TArray > >
 A set of array pointers. More...
 
template<typename TArray >
using ArrayPointerFlagMap = std::unordered_map< const TArray *, bool, ArrayPointerHasher< TArray >, ArrayPointerEquality< TArray > >
 A map of array pointers to flags. More...
 
using HashSet = ArraySet< Hash256 >
 A hash set. More...
 
using KeySet = ArraySet< Key >
 A key set. More...
 
using SortedKeySet = std::set< Key >
 A sorted key set. More...
 
using HashPointerSet = ArrayPointerSet< Hash256 >
 A hash pointer set. More...
 
using KeyPointerSet = ArrayPointerSet< Key >
 A key pointer set. More...
 
using RawBuffer = BasicRawBuffer< const uint8_t >
 A const binary buffer. More...
 
using MutableRawBuffer = BasicRawBuffer< uint8_t >
 A mutable binary buffer. More...
 
using ShortHash = BaseValue< uint32_t, ShortHash_tag >
 
using ShortHashesSet = std::unordered_set< ShortHash, ShortHashHasher >
 
using SpinLockGuard = std::lock_guard< SpinLock >
 A spin lock guard. More...
 
using DefaultReaderNotificationPolicy = NoOpReaderNotificationPolicy
 
using SpinReaderWriterLock = BasicSpinReaderWriterLock< DefaultReaderNotificationPolicy >
 A default reader writer lock. More...
 

Enumerations

enum  LogLevel {
  LogLevel::Trace = boost::log::trivial::trace, LogLevel::Debug = boost::log::trivial::debug, LogLevel::Info = boost::log::trivial::info, LogLevel::Warning = boost::log::trivial::warning,
  LogLevel::Error = boost::log::trivial::error, LogLevel::Fatal = boost::log::trivial::fatal, LogLevel::Min = Trace, LogLevel::Max = Fatal
}
 Catapult log levels. More...
 
enum  LogSinkType { LogSinkType::Sync, LogSinkType::Async }
 Catapult log sink types. More...
 
enum  LogColorMode { LogColorMode::Ansi, LogColorMode::AnsiBold, LogColorMode::None }
 Catapult (console) log color modes. More...
 

Functions

template<typename T >
AtomicIncrementDecrementGuard< T > MakeIncrementDecrementGuard (std::atomic< T > &value)
 Factory function for creating AtomicIncrementDecrementGuard<T>. More...
 
bool TryBase32Encode (const RawBuffer &data, const MutableRawString &encodedData)
 
void Base32Encode (const RawBuffer &data, const MutableRawString &encodedData)
 
std::string Base32Encode (const RawBuffer &data)
 Encodes an array of bytes pointed to by data. The size must be a multiple of 5. More...
 
bool TryBase32Decode (const RawString &encodedData, const MutableRawBuffer &data)
 
void Base32Decode (const RawString &encodedData, const MutableRawBuffer &data)
 
constexpr size_t GetEncodedDataSize (size_t decodedSize)
 Gets the encoded size of decoded data with size decodedSize. More...
 
constexpr size_t GetDecodedDataSize (size_t encodedSize)
 Gets the decoded size of encoded data with size encodedSize. More...
 
template<size_t N>
std::array< uint8_t, N > Base32Decode (const RawString &encodedData)
 Decodes a base32 encoded string pointed to by encodedData. The string length must be a multiple of 8. More...
 
std::ostream & operator<< (std::ostream &out, const BlockSpan &blockSpan)
 Insertion operator for outputting blockSpan to out. More...
 
template<size_t N, typename TTag >
constexpr void HexFormat (const ByteArray< N, TTag > &)
 
template<typename T >
constexpr const T & as_const (T &ref)
 Coerces a reference (ref) to a const reference. More...
 
template<typename TEnum >
constexpr std::underlying_type_t< TEnum > to_underlying_type (TEnum value)
 Converts a strongly typed enumeration value to its underlying integral value. More...
 
template<typename TSource , typename TDest >
TDest checked_cast (TSource value)
 
std::string GetIniPropertyName (const char *cppVariableName)
 Gets the ini property name corresponding to the cpp variable name (cppVariableName). More...
 
void VerifyBagSizeLte (const ConfigurationBag &bag, size_t expectedSize)
 Verifies that the number of properties in bag is no greater than expectedSize. More...
 
ConfigurationBag ExtractSectionAsBag (const ConfigurationBag &bag, const char *section)
 Extracts all section properties from bag into a new bag with a single section with a default (empty string) name. More...
 
std::pair< std::unordered_set< std::string >, size_t > ExtractSectionAsUnorderedSet (const ConfigurationBag &bag, const char *section)
 
std::pair< std::vector< std::string >, size_t > ExtractSectionAsOrderedVector (const ConfigurationBag &bag, const char *section)
 
template<typename T >
void LoadIniProperty (const ConfigurationBag &bag, const char *section, const char *cppVariableName, T &value)
 
bool TryParseValue (const std::string &str, LogLevel &parsedValue)
 Tries to parse str into a log level (parsedValue). More...
 
bool TryParseValue (const std::string &str, LogSinkType &parsedValue)
 Tries to parse str into a log sink type (parsedValue). More...
 
bool TryParseValue (const std::string &str, LogColorMode &parsedValue)
 Tries to parse str into a log color mode (parsedValue). More...
 
bool TryParseValue (const std::string &str, bool &parsedValue)
 Tries to parse str into a boolean (parsedValue). More...
 
bool TryParseValue (const std::string &str, uint8_t &parsedValue)
 Tries to parse str into a uint8_t (parsedValue). More...
 
bool TryParseValue (const std::string &str, uint16_t &parsedValue)
 Tries to parse str into a uint16_t (parsedValue). More...
 
bool TryParseValue (const std::string &str, uint32_t &parsedValue)
 Tries to parse str into a uint32_t (parsedValue). More...
 
bool TryParseValue (const std::string &str, uint64_t &parsedValue)
 Tries to parse str into a uint64_t (parsedValue). More...
 
bool TryParseValue (const std::string &str, Amount &parsedValue)
 Tries to parse str into an Amount (parsedValue). More...
 
bool TryParseValue (const std::string &str, BlockFeeMultiplier &parsedValue)
 Tries to parse str into a BlockFeeMultiplier (parsedValue). More...
 
bool TryParseValue (const std::string &str, Height &parsedValue)
 Tries to parse str into a Height (parsedValue). More...
 
bool TryParseValue (const std::string &str, Importance &parsedValue)
 Tries to parse str into an Importance (parsedValue). More...
 
bool TryParseValue (const std::string &str, MosaicId &parsedValue)
 Tries to parse str into a MosaicId (parsedValue). More...
 
bool TryParseValue (const std::string &str, TimeSpan &parsedValue)
 Tries to parse str into a TimeSpan (parsedValue). More...
 
bool TryParseValue (const std::string &str, BlockSpan &parsedValue)
 Tries to parse str into a BlockSpan (parsedValue). More...
 
bool TryParseValue (const std::string &str, FileSize &parsedValue)
 Tries to parse str into a FileSize (parsedValue). More...
 
bool TryParseValue (const std::string &str, Key &parsedValue)
 Tries to parse str into a Key (parsedValue). More...
 
bool TryParseValue (const std::string &str, Hash256 &parsedValue)
 Tries to parse str into a Hash256 (parsedValue). More...
 
bool TryParseValue (const std::string &str, GenerationHash &parsedValue)
 Tries to parse str into a GenerationHash (parsedValue). More...
 
bool TryParseValue (const std::string &str, std::string &parsedValue)
 
bool TryParseValue (const std::string &str, std::unordered_set< std::string > &parsedValue)
 
template<typename T , size_t N>
bool TryParseEnumValue (const std::array< std::pair< const char *, T >, N > &stringToValueMapping, const std::string &str, T &parsedValue)
 Tries to parse str into an enum value (parsedValue) given a mapping of strings to values (stringToValueMapping). More...
 
template<typename T , size_t N>
bool TryParseBitwiseEnumValue (const std::array< std::pair< const char *, T >, N > &stringToValueMapping, const std::string &str, T &parsedValues)
 Tries to parse str into a bitwise enum value (parsedValue) given a mapping of strings to values (stringToValueMapping). More...
 
template<typename TMap , typename TPredicate >
void map_erase_if (TMap &map, TPredicate predicate)
 Removes all entries from map that fulfill the given predicate. More...
 
std::ostream & operator<< (std::ostream &out, const FileSize &fileSize)
 Insertion operator for outputting fileSize to out. More...
 
template<typename TContainer , typename TInitial , typename TFunction >
auto Reduce (const TContainer &container, TInitial initialValue, TFunction fun)
 
template<typename TContainer , typename TFunction >
auto Sum (const TContainer &container, TFunction accessor)
 
template<typename TInputIterator >
auto HexFormat (TInputIterator begin, TInputIterator end, char separator=0)
 Factory function for creating a hex formatter around iterators begin and end with separator. More...
 
template<typename TContainer >
auto HexFormat (const TContainer &container, char separator)
 Factory function for creating a hex formatter around container with separator. More...
 
template<typename T >
auto HexFormat (const T &data)
 Factory function for creating a hex formatter around data. More...
 
template<typename T >
auto HexFormat (const std::vector< T > &container)
 Factory function for creating a hex formatter around container. More...
 
template<typename T , size_t N>
auto HexFormat (const std::array< T, N > &container)
 Factory function for creating a hex formatter around container. More...
 
uint8_t ParseByte (char ch1, char ch2)
 Parses two characters (ch1 and ch2) into a byte. More...
 
bool TryParseByte (char ch1, char ch2, uint8_t &by)
 Tries to parse two characters (ch1 and ch2) into a byte (by). More...
 
template<typename TContainer >
bool TryParseHexStringIntoContainer (const char *const pHexData, size_t dataSize, TContainer &outputContainer)
 Tries to parse a hex string (pHexData with size dataSize) into outputContainer. More...
 
template<typename TContainer >
void ParseHexStringIntoContainer (const char *const pHexData, size_t dataSize, TContainer &outputContainer)
 Parses a hex string (pHexData with size dataSize) into outputContainer. More...
 
template<typename TByteArray >
TByteArray ParseByteArray (const std::string &hexString)
 Parses a hex string (hexString) into a byte array. More...
 
uint64_t Log2TimesPowerOfTwo (uint64_t value, uint64_t n)
 Calculates log2(value^(2^n)). More...
 
template<typename T >
bool CheckedAdd (T &value, T delta)
 Adds delta to value if and only if there is no overflow. More...
 
template<typename T , typename X = std::enable_if_t<std::is_integral_v<T>>>
constexpr T GetNumBits ()
 Gets the number of bits in the specified type. More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T Log2 (T value)
 Calculates log2(value). More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T Pow2 (T value)
 Calculates 2^(value). More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T DivideAndGetRemainder (T &value, T divisor)
 Divides value by divisor and returns the remainder. More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr bool IsPowerMultiple (T lhs, T rhs, T base)
 Returns true if rhs is equal to lhs multipled by a power of base. More...
 
void CatapultLogFlush ()
 
template<typename T >
std::unique_ptr< T > MakeUniqueWithSize (size_t size)
 Creates a unique pointer of the specified type with custom size. More...
 
template<typename T >
std::shared_ptr< T > MakeSharedWithSize (size_t size)
 Creates a shared pointer of the specified type with custom size. More...
 
template<typename T >
std::shared_ptr< T > UniqueToShared (std::unique_ptr< T > &&pointer)
 Converts a unique pointer to a shared pointer of the same type. More...
 
template<typename TNamedObjects >
std::vector< std::string > ExtractNames (const TNamedObjects &namedObjects)
 Extracts all names from namedObjects. More...
 
std::string ReduceNames (const std::vector< std::string > &names)
 Reduces names into a single string. More...
 
Timestamp NetworkTime ()
 Returns the network time, i.e. the number of milliseconds since Epoch_Time. More...
 
Timestamp ToNetworkTime (const Timestamp &timestamp)
 
Timestamp ToUnixTime (const Timestamp &timestamp)
 
constexpr bool IsDirectorySeparator (char ch)
 Gets a value indicating whether or not ch is a directory separator. More...
 
constexpr const char * AdvanceToEnd (const char *str)
 Advances str to its end (the NUL terminator). More...
 
constexpr const char * ExtractFilename (const char *fullPath)
 
constexpr const char * ExtractDirectoryAndFilename (const char *fullPath)
 
constexpr RawString ExtractDirectoryName (const char *fullPath)
 
template<typename T , typename X = std::enable_if_t<std::is_same_v<char, typename std::remove_const_t<T>>>>
std::ostream & operator<< (std::ostream &out, const BasicRawBuffer< T > &str)
 Insertion operator for outputting str to out. More...
 
ShortHash ToShortHash (const Hash256 &hash)
 Gets the short hash corresponding to hash. More...
 
std::ostream & operator<< (std::ostream &out, const TimeSpan &timeSpan)
 Insertion operator for outputting timeSpan to out. More...
 
constexpr Timestamp operator+ (const Timestamp &timestamp, const TimeSpan &timeSpan)
 Adds timestamp and a timeSpan resulting in new timestamp. More...
 
constexpr Timestamp SubtractNonNegative (const Timestamp &timestamp, const TimeSpan &timeSpan)
 Subtracts timeSpan from timestamp and returns the maximum of the difference and zero. More...
 

Variables

const uint32_t Base32_Decoded_Block_Size = 5
 
const uint32_t Base32_Encoded_Block_Size = 8
 
constexpr auto Epoch_Time = std::chrono::duration<int64_t, std::milli>(1459468800000)
 Represents the number of milliseconds between 1970-01-01 00:00:00 UTC and 2016-04-01 00:00:00 UTC. More...
 

Typedef Documentation

◆ ArrayPointerFlagMap

template<typename TArray >
using catapult::utils::ArrayPointerFlagMap = typedef std::unordered_map<const TArray*, bool, ArrayPointerHasher<TArray>, ArrayPointerEquality<TArray> >

A map of array pointers to flags.

◆ ArrayPointerSet

template<typename TArray >
using catapult::utils::ArrayPointerSet = typedef std::unordered_set<const TArray*, ArrayPointerHasher<TArray>, ArrayPointerEquality<TArray> >

A set of array pointers.

◆ ArraySet

template<typename TArray >
using catapult::utils::ArraySet = typedef std::unordered_set<TArray, ArrayHasher<TArray> >

A set of arrays.

◆ DefaultReaderNotificationPolicy

◆ HashPointerSet

A hash pointer set.

◆ HashSet

A hash set.

◆ KeyPointerSet

A key pointer set.

◆ KeySet

A key set.

◆ MutableRawBuffer

A mutable binary buffer.

◆ RawBuffer

using catapult::utils::RawBuffer = typedef BasicRawBuffer<const uint8_t>

A const binary buffer.

◆ ShortHash

◆ ShortHashesSet

using catapult::utils::ShortHashesSet = typedef std::unordered_set<ShortHash, ShortHashHasher>

◆ SortedKeySet

using catapult::utils::SortedKeySet = typedef std::set<Key>

A sorted key set.

◆ SpinLockGuard

using catapult::utils::SpinLockGuard = typedef std::lock_guard<SpinLock>

A spin lock guard.

◆ SpinReaderWriterLock

Enumeration Type Documentation

◆ LogColorMode

Catapult (console) log color modes.

Enumerator
Ansi 

Ansi codes.

AnsiBold 

Bold ansi codes.

None 

No coloring.

◆ LogLevel

Catapult log levels.

Enumerator
Trace 

Level for logging trace events.

Debug 

Level for logging debug events.

Info 

Level for logging informational events.

Warning 

Level for logging warning events.

Error 

Level for logging error events.

Fatal 

Level for logging fatal events.

Min 

Minimum log level.

Max 

Maximum log level.

◆ LogSinkType

Catapult log sink types.

Enumerator
Sync 

A synchronous sink.

Async 

An asynchronous sink.

Function Documentation

◆ AdvanceToEnd()

constexpr const char* catapult::utils::AdvanceToEnd ( const char *  str)
constexpr

Advances str to its end (the NUL terminator).

Here is the caller graph for this function:

◆ as_const()

template<typename T >
constexpr const T& catapult::utils::as_const ( T &  ref)
constexpr

Coerces a reference (ref) to a const reference.

Here is the caller graph for this function:

◆ Base32Decode() [1/2]

template<size_t N>
std::array<uint8_t, N> catapult::utils::Base32Decode ( const RawString encodedData)

Decodes a base32 encoded string pointed to by encodedData. The string length must be a multiple of 8.

Here is the call graph for this function:

◆ Base32Decode() [2/2]

void catapult::utils::Base32Decode ( const RawString encodedData,
const MutableRawBuffer data 
)

Decodes a base32 encoded string pointed to by encodedData into data.

Note
The string length must be a multiple of 8.
Here is the caller graph for this function:

◆ Base32Encode() [1/2]

std::string catapult::utils::Base32Encode ( const RawBuffer data)

Encodes an array of bytes pointed to by data. The size must be a multiple of 5.

Here is the call graph for this function:

◆ Base32Encode() [2/2]

void catapult::utils::Base32Encode ( const RawBuffer data,
const MutableRawString encodedData 
)

Encodes an array of bytes pointed to by data into encodedData.

Note
The size must be a multiple of 5.
Here is the caller graph for this function:

◆ CatapultLogFlush()

void catapult::utils::CatapultLogFlush ( )

Flushes all buffered log records and waits for all sinks to complete processing of them.

Note
This function is only intended to be called right before a crash.

◆ checked_cast()

template<typename TSource , typename TDest >
TDest catapult::utils::checked_cast ( TSource  value)

Converts value from one integral type (TSource) to another (TDest). This cast can only be used when data truncation is possible. An exception is thrown if data truncation is detected.

◆ CheckedAdd()

template<typename T >
bool catapult::utils::CheckedAdd ( T &  value,
delta 
)

Adds delta to value if and only if there is no overflow.

Here is the caller graph for this function:

◆ DivideAndGetRemainder()

template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::DivideAndGetRemainder ( T &  value,
divisor 
)
constexpr

Divides value by divisor and returns the remainder.

Here is the caller graph for this function:

◆ ExtractDirectoryAndFilename()

constexpr const char* catapult::utils::ExtractDirectoryAndFilename ( const char *  fullPath)
constexpr

Extracts the last directory and filename from fullPath. e.g. ExtractDirectoryAndFilename("cat/baz/bar/foo.cpp") == "bar/foo.cpp"

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractDirectoryName()

constexpr RawString catapult::utils::ExtractDirectoryName ( const char *  fullPath)
constexpr

Extracts the last directory name from fullPath. e.g. ExtractLastDirectoryName("cat/baz/bar/foo.cpp") == "bar"

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractFilename()

constexpr const char* catapult::utils::ExtractFilename ( const char *  fullPath)
constexpr

Extracts the filename part from fullPath. e.g. ExtractFilename("cat/bar/baz/foo.cpp") == "foo.cpp"

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractNames()

template<typename TNamedObjects >
std::vector<std::string> catapult::utils::ExtractNames ( const TNamedObjects &  namedObjects)

Extracts all names from namedObjects.

Here is the caller graph for this function:

◆ ExtractSectionAsBag()

ConfigurationBag catapult::utils::ExtractSectionAsBag ( const ConfigurationBag bag,
const char *  section 
)

Extracts all section properties from bag into a new bag with a single section with a default (empty string) name.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractSectionAsOrderedVector()

std::pair< std::vector< std::string >, size_t > catapult::utils::ExtractSectionAsOrderedVector ( const ConfigurationBag bag,
const char *  section 
)

Extracts all section properties from bag into an ordered vector.

Note
All section properties are expected to be boolean and only ones with true values will be included.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractSectionAsUnorderedSet()

std::pair< std::unordered_set< std::string >, size_t > catapult::utils::ExtractSectionAsUnorderedSet ( const ConfigurationBag bag,
const char *  section 
)

Extracts all section properties from bag into an unordered set.

Note
All section properties are expected to be boolean and only ones with true values will be included.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDecodedDataSize()

constexpr size_t catapult::utils::GetDecodedDataSize ( size_t  encodedSize)
constexpr

Gets the decoded size of encoded data with size encodedSize.

◆ GetEncodedDataSize()

constexpr size_t catapult::utils::GetEncodedDataSize ( size_t  decodedSize)
constexpr

Gets the encoded size of decoded data with size decodedSize.

Here is the caller graph for this function:

◆ GetIniPropertyName()

std::string catapult::utils::GetIniPropertyName ( const char *  cppVariableName)

Gets the ini property name corresponding to the cpp variable name (cppVariableName).

Here is the caller graph for this function:

◆ GetNumBits()

template<typename T , typename X = std::enable_if_t<std::is_integral_v<T>>>
constexpr T catapult::utils::GetNumBits ( )
constexpr

Gets the number of bits in the specified type.

◆ HexFormat() [1/6]

template<size_t N, typename TTag >
constexpr void catapult::utils::HexFormat ( const ByteArray< N, TTag > &  )
constexpr
Here is the caller graph for this function:

◆ HexFormat() [2/6]

template<typename T , size_t N>
auto catapult::utils::HexFormat ( const std::array< T, N > &  container)

Factory function for creating a hex formatter around container.

Here is the call graph for this function:

◆ HexFormat() [3/6]

template<typename T >
auto catapult::utils::HexFormat ( const std::vector< T > &  container)

Factory function for creating a hex formatter around container.

Here is the call graph for this function:

◆ HexFormat() [4/6]

template<typename T >
auto catapult::utils::HexFormat ( const T &  data)

Factory function for creating a hex formatter around data.

Here is the call graph for this function:

◆ HexFormat() [5/6]

template<typename TContainer >
auto catapult::utils::HexFormat ( const TContainer &  container,
char  separator 
)

Factory function for creating a hex formatter around container with separator.

Here is the call graph for this function:

◆ HexFormat() [6/6]

template<typename TInputIterator >
auto catapult::utils::HexFormat ( TInputIterator  begin,
TInputIterator  end,
char  separator = 0 
)

Factory function for creating a hex formatter around iterators begin and end with separator.

◆ IsDirectorySeparator()

constexpr bool catapult::utils::IsDirectorySeparator ( char  ch)
constexpr

Gets a value indicating whether or not ch is a directory separator.

Here is the caller graph for this function:

◆ IsPowerMultiple()

template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr bool catapult::utils::IsPowerMultiple ( lhs,
rhs,
base 
)
constexpr

Returns true if rhs is equal to lhs multipled by a power of base.

Here is the call graph for this function:

◆ LoadIniProperty()

template<typename T >
void catapult::utils::LoadIniProperty ( const ConfigurationBag bag,
const char *  section,
const char *  cppVariableName,
T &  value 
)

Loads an ini property from bag into value given a section name (section) and a cpp variable name (cppVariableName).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Log2()

template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::Log2 ( value)
constexpr

Calculates log2(value).

Here is the caller graph for this function:

◆ Log2TimesPowerOfTwo()

uint64_t catapult::utils::Log2TimesPowerOfTwo ( uint64_t  value,
uint64_t  n 
)

Calculates log2(value^(2^n)).

Here is the caller graph for this function:

◆ MakeIncrementDecrementGuard()

template<typename T >
AtomicIncrementDecrementGuard<T> catapult::utils::MakeIncrementDecrementGuard ( std::atomic< T > &  value)

Factory function for creating AtomicIncrementDecrementGuard<T>.

◆ MakeSharedWithSize()

template<typename T >
std::shared_ptr<T> catapult::utils::MakeSharedWithSize ( size_t  size)

Creates a shared pointer of the specified type with custom size.

◆ MakeUniqueWithSize()

template<typename T >
std::unique_ptr<T> catapult::utils::MakeUniqueWithSize ( size_t  size)

Creates a unique pointer of the specified type with custom size.

◆ map_erase_if()

template<typename TMap , typename TPredicate >
void catapult::utils::map_erase_if ( TMap &  map,
TPredicate  predicate 
)

Removes all entries from map that fulfill the given predicate.

Here is the caller graph for this function:

◆ NetworkTime()

Timestamp catapult::utils::NetworkTime ( )

Returns the network time, i.e. the number of milliseconds since Epoch_Time.

Here is the caller graph for this function:

◆ operator+()

constexpr Timestamp catapult::utils::operator+ ( const Timestamp timestamp,
const TimeSpan timeSpan 
)
constexpr

Adds timestamp and a timeSpan resulting in new timestamp.

Here is the call graph for this function:

◆ operator<<() [1/4]

template<typename T , typename X = std::enable_if_t<std::is_same_v<char, typename std::remove_const_t<T>>>>
std::ostream& catapult::utils::operator<< ( std::ostream &  out,
const BasicRawBuffer< T > &  str 
)

Insertion operator for outputting str to out.

◆ operator<<() [2/4]

std::ostream & catapult::utils::operator<< ( std::ostream &  out,
const BlockSpan blockSpan 
)

Insertion operator for outputting blockSpan to out.

Here is the call graph for this function:

◆ operator<<() [3/4]

std::ostream & catapult::utils::operator<< ( std::ostream &  out,
const FileSize fileSize 
)

Insertion operator for outputting fileSize to out.

Here is the call graph for this function:

◆ operator<<() [4/4]

std::ostream & catapult::utils::operator<< ( std::ostream &  out,
const TimeSpan timeSpan 
)

Insertion operator for outputting timeSpan to out.

Here is the call graph for this function:

◆ ParseByte()

uint8_t catapult::utils::ParseByte ( char  ch1,
char  ch2 
)

Parses two characters (ch1 and ch2) into a byte.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseByteArray()

template<typename TByteArray >
TByteArray catapult::utils::ParseByteArray ( const std::string &  hexString)

Parses a hex string (hexString) into a byte array.

Here is the call graph for this function:

◆ ParseHexStringIntoContainer()

template<typename TContainer >
void catapult::utils::ParseHexStringIntoContainer ( const char *const  pHexData,
size_t  dataSize,
TContainer &  outputContainer 
)

Parses a hex string (pHexData with size dataSize) into outputContainer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Pow2()

template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::Pow2 ( value)
constexpr

Calculates 2^(value).

◆ Reduce()

template<typename TContainer , typename TInitial , typename TFunction >
auto catapult::utils::Reduce ( const TContainer &  container,
TInitial  initialValue,
TFunction  fun 
)

Applies an accumulator function (fun) against an initial value(initialValue) and each element of container to reduce it to a single value.

◆ ReduceNames()

std::string catapult::utils::ReduceNames ( const std::vector< std::string > &  names)
inline

Reduces names into a single string.

◆ SubtractNonNegative()

constexpr Timestamp catapult::utils::SubtractNonNegative ( const Timestamp timestamp,
const TimeSpan timeSpan 
)
constexpr

Subtracts timeSpan from timestamp and returns the maximum of the difference and zero.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sum()

template<typename TContainer , typename TFunction >
auto catapult::utils::Sum ( const TContainer &  container,
TFunction  accessor 
)

Applies accessor on each element of container and sums resulting values.

Note
this does not use Reduce in order to avoid creating another lambda.
Here is the caller graph for this function:

◆ to_underlying_type()

template<typename TEnum >
constexpr std::underlying_type_t<TEnum> catapult::utils::to_underlying_type ( TEnum  value)
constexpr

Converts a strongly typed enumeration value to its underlying integral value.

Here is the caller graph for this function:

◆ ToNetworkTime()

Timestamp catapult::utils::ToNetworkTime ( const Timestamp timestamp)

Given a unix timestamp, returns the corresponding network timestamp that the unix timestamp represents.

Here is the call graph for this function:

◆ ToShortHash()

ShortHash catapult::utils::ToShortHash ( const Hash256 hash)
inline

Gets the short hash corresponding to hash.

Here is the caller graph for this function:

◆ ToUnixTime()

Timestamp catapult::utils::ToUnixTime ( const Timestamp timestamp)

Given a network timestamp, returns the corresponding unix timestamp that the network timestamp represents.

Here is the call graph for this function:

◆ TryBase32Decode()

bool catapult::utils::TryBase32Decode ( const RawString encodedData,
const MutableRawBuffer data 
)

Tries to decode a base32 encoded string pointed to by encodedData into data.

Note
The string length must be a multiple of 8.
Here is the caller graph for this function:

◆ TryBase32Encode()

bool catapult::utils::TryBase32Encode ( const RawBuffer data,
const MutableRawString encodedData 
)

Tries to encode an array of bytes pointed to by data into encodedData.

Note
The size must be a multiple of 5.

◆ TryParseBitwiseEnumValue()

template<typename T , size_t N>
bool catapult::utils::TryParseBitwiseEnumValue ( const std::array< std::pair< const char *, T >, N > &  stringToValueMapping,
const std::string &  str,
T &  parsedValues 
)

Tries to parse str into a bitwise enum value (parsedValue) given a mapping of strings to values (stringToValueMapping).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryParseByte()

bool catapult::utils::TryParseByte ( char  ch1,
char  ch2,
uint8_t &  by 
)

Tries to parse two characters (ch1 and ch2) into a byte (by).

Here is the caller graph for this function:

◆ TryParseEnumValue()

template<typename T , size_t N>
bool catapult::utils::TryParseEnumValue ( const std::array< std::pair< const char *, T >, N > &  stringToValueMapping,
const std::string &  str,
T &  parsedValue 
)

Tries to parse str into an enum value (parsedValue) given a mapping of strings to values (stringToValueMapping).

Here is the caller graph for this function:

◆ TryParseHexStringIntoContainer()

template<typename TContainer >
bool catapult::utils::TryParseHexStringIntoContainer ( const char *const  pHexData,
size_t  dataSize,
TContainer &  outputContainer 
)

Tries to parse a hex string (pHexData with size dataSize) into outputContainer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryParseValue() [1/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
Amount parsedValue 
)

Tries to parse str into an Amount (parsedValue).

◆ TryParseValue() [2/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
BlockFeeMultiplier parsedValue 
)

Tries to parse str into a BlockFeeMultiplier (parsedValue).

◆ TryParseValue() [3/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
BlockSpan parsedValue 
)

Tries to parse str into a BlockSpan (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [4/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
bool &  parsedValue 
)

Tries to parse str into a boolean (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [5/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
FileSize parsedValue 
)

Tries to parse str into a FileSize (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [6/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
GenerationHash parsedValue 
)

Tries to parse str into a GenerationHash (parsedValue).

◆ TryParseValue() [7/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
Hash256 parsedValue 
)

Tries to parse str into a Hash256 (parsedValue).

◆ TryParseValue() [8/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
Height parsedValue 
)

Tries to parse str into a Height (parsedValue).

◆ TryParseValue() [9/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
Importance parsedValue 
)

Tries to parse str into an Importance (parsedValue).

◆ TryParseValue() [10/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
Key parsedValue 
)

Tries to parse str into a Key (parsedValue).

◆ TryParseValue() [11/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
LogColorMode parsedValue 
)

Tries to parse str into a log color mode (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [12/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
LogLevel parsedValue 
)

Tries to parse str into a log level (parsedValue).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryParseValue() [13/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
LogSinkType parsedValue 
)

Tries to parse str into a log sink type (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [14/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
MosaicId parsedValue 
)

Tries to parse str into a MosaicId (parsedValue).

◆ TryParseValue() [15/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
std::string &  parsedValue 
)

Tries to parse str into a string (parsedValue).

Note
This function just copies str into parsedValue.

◆ TryParseValue() [16/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
std::unordered_set< std::string > &  parsedValue 
)

Tries to parse str into a set of strings (parsedValue).

Note
str is expected to be comma separated

◆ TryParseValue() [17/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
TimeSpan parsedValue 
)

Tries to parse str into a TimeSpan (parsedValue).

Here is the call graph for this function:

◆ TryParseValue() [18/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
uint16_t &  parsedValue 
)

Tries to parse str into a uint16_t (parsedValue).

◆ TryParseValue() [19/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
uint32_t &  parsedValue 
)

Tries to parse str into a uint32_t (parsedValue).

◆ TryParseValue() [20/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
uint64_t &  parsedValue 
)

Tries to parse str into a uint64_t (parsedValue).

◆ TryParseValue() [21/21]

bool catapult::utils::TryParseValue ( const std::string &  str,
uint8_t &  parsedValue 
)

Tries to parse str into a uint8_t (parsedValue).

◆ UniqueToShared()

template<typename T >
std::shared_ptr<T> catapult::utils::UniqueToShared ( std::unique_ptr< T > &&  pointer)

Converts a unique pointer to a shared pointer of the same type.

◆ VerifyBagSizeLte()

void catapult::utils::VerifyBagSizeLte ( const ConfigurationBag bag,
size_t  expectedSize 
)

Verifies that the number of properties in bag is no greater than expectedSize.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ Base32_Decoded_Block_Size

const uint32_t catapult::utils::Base32_Decoded_Block_Size = 5

◆ Base32_Encoded_Block_Size

const uint32_t catapult::utils::Base32_Encoded_Block_Size = 8

◆ Epoch_Time

constexpr auto catapult::utils::Epoch_Time = std::chrono::duration<int64_t, std::milli>(1459468800000)
constexpr

Represents the number of milliseconds between 1970-01-01 00:00:00 UTC and 2016-04-01 00:00:00 UTC.