aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/string_tools.h
diff options
context:
space:
mode:
authorJaquee <jaquee.monero@gmail.com>2017-08-04 19:06:11 +0200
committerJaquee <jaquee.monero@gmail.com>2017-10-15 17:32:13 +0200
commita13540be6f3ff37a696fbbf05aba98bd6e2d1a84 (patch)
treec5e1e38d59af2103315c55ebc8185fd45a28bd8b /contrib/epee/include/string_tools.h
parentrefactor cryptonote_basic::add_tx_pub_key_to_extra (diff)
downloadmonero-a13540be6f3ff37a696fbbf05aba98bd6e2d1a84.tar.xz
add string_tools::validate_hex()
Diffstat (limited to '')
-rw-r--r--contrib/epee/include/string_tools.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index ce7b2fb87..25639263c 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -39,6 +39,7 @@
#include <cstdlib>
#include <string>
#include <type_traits>
+#include <regex>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
@@ -349,6 +350,11 @@ POP_WARNINGS
s = *(t_pod_type*)bin_buff.data();
return true;
}
+ //----------------------------------------------------------------------------
+ inline bool validate_hex(uint64_t length, const std::string& str)
+ {
+ return std::regex_match(str, std::regex("'^[0-9abcdefABCDEF]+$'")) && str.size() == length;
+ }
//----------------------------------------------------------------------------
inline std::string get_extension(const std::string& str)
{