mirror of
https://github.com/monero-project/monero
synced 2024-11-19 05:57:27 +01:00
add string_tools::validate_hex()
This commit is contained in:
parent
fd773d88cd
commit
a13540be6f
@ -39,6 +39,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <regex>
|
||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
@ -349,6 +350,11 @@ POP_WARNINGS
|
|||||||
s = *(t_pod_type*)bin_buff.data();
|
s = *(t_pod_type*)bin_buff.data();
|
||||||
return true;
|
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)
|
inline std::string get_extension(const std::string& str)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user