/usr/include/caf/string_serialization.hpp is in libcaf-dev 0.13.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_STRING_SERIALIZATION_HPP
#define CAF_STRING_SERIALIZATION_HPP
#include <string>
#include "caf/fwd.hpp"
#include "caf/optional.hpp"
#include "caf/uniform_type_info.hpp"
namespace std {
class exception;
}
namespace caf {
/**
* @relates message
*/
std::string to_string(const message& what);
/**
* @relates group
*/
std::string to_string(const group& what);
/**
* @relates channel
*/
std::string to_string(const channel& what);
/**
* @relates message_id
*/
std::string to_string(const message_id& what);
/**
* @relates actor_addr
*/
std::string to_string(const actor_addr& what);
/**
* @relates actor
*/
std::string to_string(const actor& what);
/**
* @relates node_id
*/
std::string to_string(const node_id& what);
/**
* @relates atom_value
*/
std::string to_string(const atom_value& what);
/**
* @relates mailbox_element
*/
std::string to_string(const mailbox_element& what);
/**
* @relates optional
*/
template <class T>
std::string to_string(const optional<T>& what) {
if (!what) {
return "none";
}
return to_string(*what);
}
/**
* Converts `e` to a string including `e.what()`.
*/
std::string to_verbose_string(const std::exception& e);
/**
* Converts a string created by `to_string` to its original value.
*/
uniform_value from_string_impl(const std::string& what);
/**
* Convenience function that tries to deserializes a value from
* `what` and converts the result to `T`.
*/
template <class T>
optional<T> from_string(const std::string& what) {
auto uti = uniform_typeid<T>();
auto uv = from_string_impl(what);
if (!uv || uv->ti != uti) {
// try again using the type name
std::string tmp = uti->name();
tmp += " ( ";
tmp += what;
tmp += " )";
uv = from_string_impl(tmp);
}
if (uv && uv->ti == uti) {
return T{std::move(*reinterpret_cast<T*>(uv->val))};
}
return none;
}
} // namespace caf
#endif // CAF_STRING_SERIALIZATION_HPP
|