mqtt_cpp
include
mqtt
string_check.hpp
Go to the documentation of this file.
1
// Copyright Takatoshi Kondo 2015
2
//
3
// Distributed under the Boost Software License, Version 1.0.
4
// (See accompanying file LICENSE_1_0.txt or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
6
7
#if !defined(MQTT_STRING_CHECK_HPP)
8
#define MQTT_STRING_CHECK_HPP
9
10
#include <
mqtt/namespace.hpp
>
11
#include <
mqtt/utf8encoded_strings.hpp
>
12
#include <
mqtt/exception.hpp
>
13
#include <
mqtt/string_view.hpp
>
14
#include <
mqtt/const_buffer_util.hpp
>
15
16
namespace
as
=
boost::asio
;
17
18
namespace
MQTT_NS
{
19
20
inline
void
utf8string_check
(
string_view
str) {
21
if
(!
utf8string::is_valid_length
(str))
throw
utf8string_length_error
();
22
auto
r =
utf8string::validate_contents
(str);
23
if
(r !=
utf8string::validation::well_formed
) {
24
throw
utf8string_contents_error
(r);
25
}
26
}
27
28
inline
void
utf8string_check
(as::const_buffer str) {
29
utf8string_check
(
string_view
(
get_pointer
(str),
get_size
(str)));
30
}
31
32
}
// namespace MQTT_NS
33
34
#endif
// MQTT_STRING_CHECK_HPP
const_buffer_util.hpp
exception.hpp
MQTT_NS::utf8string::validation::well_formed
@ well_formed
UTF-8 string is well_formed. See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3....
MQTT_NS::utf8string::is_valid_length
constexpr bool is_valid_length(string_view str)
Definition:
utf8encoded_strings.hpp:42
MQTT_NS::utf8string::validate_contents
constexpr validation validate_contents(string_view str)
Definition:
utf8encoded_strings.hpp:47
MQTT_NS
Definition:
any.hpp:27
MQTT_NS::string_view
boost::string_ref string_view
Definition:
string_view.hpp:64
MQTT_NS::utf8string_check
void utf8string_check(string_view str)
Definition:
string_check.hpp:20
MQTT_NS::get_pointer
char const * get_pointer(as::const_buffer const &cb)
Definition:
const_buffer_util.hpp:17
MQTT_NS::get_size
std::size_t get_size(as::const_buffer const &cb)
Definition:
const_buffer_util.hpp:21
namespace.hpp
boost::asio
Definition:
buffer.hpp:242
string_view.hpp
MQTT_NS::utf8string_contents_error
Definition:
exception.hpp:51
MQTT_NS::utf8string_length_error
Definition:
exception.hpp:45
utf8encoded_strings.hpp
Generated by
1.9.1