// Copyright © 2017-2020 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

// #pragma once

// #include <boost/algorithm/hex.hpp>

// #include <array>
// #include <string>
// #include <tuple>

// namespace TW
// {
//     /// Parses a string of hexadecimal values.
//     ///
//     /// \returns the array or parsed bytes or an empty array if the string is not
//     /// valid hexadecimal.
//     template <typename Iter>
//     inline bool is_valid_hex(const Iter begin, const Iter end)
//     {
//         auto it = begin;

//         // Skip `0x`
//         if (end - begin >= 2 && *begin == '0' && *(begin + 1) == 'x')
//         {
//             it += 2;
//         }
//         try
//         {
//             std::string temp;
//             boost::algorithm::unhex(it, end, std::back_inserter(temp));
//             return true;
//         }
//         catch (...)
//         {
//             return false;
//         }
//     }

//     /// Parses a string of hexadecimal values.
//     ///
//     /// \returns the array or parsed bytes or an empty array if the string is not
//     /// valid hexadecimal.
//     inline bool is_valid_hex(const std::string &string, bool padLeft = false)
//     {
//         if (string.size() % 2 != 0 && padLeft)
//         {
//             std::string temp = string;
//             if (temp.compare(0, 2, "0x") == 0)
//             {
//                 temp.erase(0, 2);
//             }
//             temp.insert(0, 1, '0');
//             return is_valid_hex(temp.begin(), temp.end());
//         }
//         return is_valid_hex(string.begin(), string.end());
//     }

// } // namespace TW
