Bond
 
Loading...
Searching...
No Matches
rapidjson_utils_impl.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7#include <bond/core/exception.h>
8
9#include <boost/lexical_cast.hpp>
10#include <boost/locale.hpp>
11
12namespace bond
13{
14namespace detail
15{
16
17BOND_DETAIL_HEADER_ONLY_INLINE
18std::basic_string<uint16_t> utf_to_utf(const char* begin, const char* end)
19{
20 try
21 {
22 return boost::locale::conv::utf_to_utf<uint16_t>(begin, end, boost::locale::conv::stop);
23 }
24 catch (const boost::locale::conv::conversion_error&)
25 {
26 UnicodeConversionException();
27 }
28}
29
30
31BOND_DETAIL_HEADER_ONLY_INLINE
32bool try_lexical_convert(const char* str, uint16_t& result)
33{
34 return boost::conversion::try_lexical_convert(str, result);
35}
36
37
38} // namespace detail
39
40} // namespace bond
namespace bond
Definition: apply.h:17