2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief ParseString non-inline template implementation */
17 //#include "ParseString.ih"
20 #include <boost/tokenizer.hpp>
21 #include <boost/numeric/conversion/cast.hpp>
22 #include <senf/Utils/String.hh>
23 #include <senf/Socket/Protocols/AddressExceptions.hh>
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 template <class ForwardIterator>
29 prefix_ void senf::detail::parseHexString(std::string const & value,
30 char const * separator, ForwardIterator f,
33 typedef boost::char_separator<char> Separator;
34 typedef boost::tokenizer<Separator> Tokenizer;
35 Separator sep (separator);
36 Tokenizer tok (value, sep);
37 Tokenizer::iterator i (tok.begin());
38 Tokenizer::iterator const i_end (tok.end());
40 for (; i!=i_end && f!=l; ++i, ++f)
41 *f = boost::numeric_cast<typename std::iterator_traits<ForwardIterator>::value_type>(
42 senf::lexical_cast<unsigned long>()[std::hex](
43 std::string(boost::begin(*i),boost::end(*i))));
45 catch (std::bad_cast &) {
46 throw AddressSyntaxException(value);
49 throw AddressSyntaxException(value);
52 //-/////////////////////////////////////////////////////////////////////////////////////////////////
60 // c-file-style: "senf"
61 // indent-tabs-mode: nil
62 // ispell-local-dictionary: "american"
63 // compile-command: "scons -u test"