Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountUtils.hpp
1#pragma once
2
3#include <xrpl/basics/StringUtilities.h>
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/tokens.h>
6
7#include <cctype>
8#include <optional>
9#include <string>
10
11namespace util {
12
22template <class T>
23[[nodiscard]] std::optional<T>
24parseBase58Wrapper(std::string const& str)
25{
26 if (!std::all_of(std::begin(str), std::end(str), [](unsigned char c) {
27 return std::isalnum(c);
28 }))
29 return std::nullopt;
30
31 return ripple::parseBase58<T>(str);
32}
33
44template <class T>
45[[nodiscard]] std::optional<T>
46parseBase58Wrapper(ripple::TokenType type, std::string const& str)
47{
48 if (!std::all_of(std::begin(str), std::end(str), [](unsigned char c) {
49 return std::isalnum(c);
50 }))
51 return std::nullopt;
52
53 return ripple::parseBase58<T>(type, str);
54}
55
56} // namespace util
This namespace contains various utilities.
Definition AccountUtils.hpp:11
std::optional< T > parseBase58Wrapper(std::string const &str)
A wrapper of parseBase58 function. It adds the check if all characters in the input string are alphan...
Definition AccountUtils.hpp:24