CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
25 #include <unordered_set>
35 namespace catapult {
namespace utils {
47 bool TryParseValue(
const std::string& str,
bool& parsedValue);
50 bool TryParseValue(
const std::string& str, uint8_t& parsedValue);
53 bool TryParseValue(
const std::string& str, uint16_t& parsedValue);
56 bool TryParseValue(
const std::string& str, uint32_t& parsedValue);
59 bool TryParseValue(
const std::string& str, uint64_t& parsedValue);
71 bool TryParseValue(
const std::string& str, Importance& parsedValue);
74 bool TryParseValue(
const std::string& str, MosaicId& parsedValue);
77 bool TryParseValue(
const std::string& str, TimeSpan& parsedValue);
80 bool TryParseValue(
const std::string& str, BlockSpan& parsedValue);
83 bool TryParseValue(
const std::string& str, FileSize& parsedValue);
96 bool TryParseValue(
const std::string& str, std::string& parsedValue);
100 bool TryParseValue(
const std::string& str, std::unordered_set<std::string>& parsedValue);
103 template<
typename T,
size_t N>
104 bool TryParseEnumValue(
const std::array<std::pair<const char*, T>, N>& stringToValueMapping,
const std::string& str, T& parsedValue) {
105 auto iter = std::find_if(stringToValueMapping.cbegin(), stringToValueMapping.cend(), [&str](
const auto& pair) {
106 return pair.first == str;
109 if (stringToValueMapping.cend() == iter)
112 parsedValue = iter->second;
117 template<
typename T,
size_t N>
119 const std::array<std::pair<const char*, T>, N>& stringToValueMapping,
120 const std::string& str,
122 std::unordered_set<std::string> parts;
126 T values = static_cast<T>(0);
127 for (
const auto& part : parts) {
135 parsedValues = values;
static constexpr BlockSpan FromDays(uint64_t days)
Creates a block span from the given number of days.
Definition: BlockSpan.h:45
utils::ByteArray< Hash256_Size, Hash256_tag > Hash256
Definition: src/catapult/types.h:47
utils::BaseValue< uint64_t, Amount_tag > Amount
Definition: src/catapult/types.h:76
utils::BaseValue< uint64_t, Height_tag > Height
Definition: src/catapult/types.h:85
LogColorMode
Catapult (console) log color modes.
Definition: Logging.h:80
static constexpr TimeSpan FromMilliseconds(uint64_t milliseconds)
Creates a time span from the given number of milliseconds.
Definition: TimeSpan.h:59
Level for logging fatal events.
Represents a time duration.
Definition: TimeSpan.h:30
Level for logging error events.
static constexpr TimeSpan FromSeconds(uint64_t seconds)
Creates a time span from the given number of seconds.
Definition: TimeSpan.h:54
static constexpr FileSize FromMegabytes(uint64_t megabytes)
Creates a file size from the given number of megabytes.
Definition: FileSize.h:41
Level for logging debug events.
Level for logging informational events.
Represents a block duration.
Definition: BlockSpan.h:28
Level for logging trace events.
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 (stringToVal...
Definition: ConfigurationValueParsers.h:104
LogSinkType
Catapult log sink types.
Definition: Logging.h:67
static constexpr TimeSpan FromHours(uint64_t hours)
Creates a time span from the given number of hours.
Definition: TimeSpan.h:44
LogLevel
Catapult log levels.
Definition: Logging.h:36
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 (stri...
Definition: ConfigurationValueParsers.h:118
static constexpr TimeSpan FromMinutes(uint64_t minutes)
Creates a time span from the given number of minutes.
Definition: TimeSpan.h:49
Represents a file size.
Definition: FileSize.h:29
utils::BaseValue< uint32_t, BlockFeeMultiplier_tag > BlockFeeMultiplier
Definition: src/catapult/types.h:91
static constexpr BlockSpan FromHours(uint64_t hours)
Creates a block span from the given number of hours.
Definition: BlockSpan.h:40
static constexpr FileSize FromKilobytes(uint64_t kilobytes)
Creates a file size from the given number of kilobytes.
Definition: FileSize.h:46
bool TryParseHexStringIntoContainer(const char *const pHexData, size_t dataSize, TContainer &outputContainer)
Tries to parse a hex string (pHexData with size dataSize) into outputContainer.
Definition: HexParser.h:35
Definition: AddressExtractionExtension.cpp:28
static constexpr FileSize FromBytes(uint64_t bytes)
Creates a file size from the given number of bytes.
Definition: FileSize.h:51
utils::ByteArray< Hash256_Size, GenerationHash_tag > GenerationHash
Definition: src/catapult/types.h:53
static constexpr uint8_t Base
Definition: ConfigurationValueParsers.cpp:82
bool TryParseValue(const std::string &str, LogLevel &parsedValue)
Tries to parse str into a log level (parsedValue).
Definition: ConfigurationValueParsers.cpp:60
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
Level for logging warning events.