OpenVPN 3 Core Library
Loading...
Searching...
No Matches
to_string.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12// Define openvpn::to_string() to work around the fact that
13// std::to_string() is missing on Android.
14// http://stackoverflow.com/questions/22774009/android-ndk-stdto-string-support
15
16#ifndef OPENVPN_COMMON_TO_STRING_H
17#define OPENVPN_COMMON_TO_STRING_H
18
19#include <string>
20#include <sstream>
21#include <type_traits>
22
24
25namespace openvpn {
26
27// Convert an arbitrary argument to a string.
28
29#ifndef OPENVPN_PLATFORM_ANDROID
30// numeric types
31template <typename T,
32 typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
33inline std::string to_string(T value)
34{
35 return std::to_string(value);
36}
37#endif
38
39// non-numeric types
40template <typename T
41#ifndef OPENVPN_PLATFORM_ANDROID
42 ,
43 typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0
44#endif
45 >
46inline std::string to_string(const T &value)
47{
48 std::ostringstream os;
49 os << value;
50 return os.str();
51}
52} // namespace openvpn
53
54#endif
Support deferred server-side state creation when client connects.
Definition ovpncli.cpp:95
std::string to_string(T value)
Definition to_string.hpp:33