added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / core / realm / impl / clamped_hex_dump.hpp
1 /*************************************************************************
2  *
3  * REALM CONFIDENTIAL
4  * __________________
5  *
6  *  [2011] - [2015] Realm Inc
7  *  All Rights Reserved.
8  *
9  * NOTICE:  All information contained herein is, and remains
10  * the property of Realm Incorporated and its suppliers,
11  * if any.  The intellectual and technical concepts contained
12  * herein are proprietary to Realm Incorporated
13  * and its suppliers and may be covered by U.S. and Foreign Patents,
14  * patents in process, and are protected by trade secret or copyright law.
15  * Dissemination of this information or reproduction of this material
16  * is strictly forbidden unless prior written permission is obtained
17  * from Realm Incorporated.
18  *
19  **************************************************************************/
20
21 #ifndef REALM_IMPL_CLAMPED_HEX_DUMP_HPP
22 #define REALM_IMPL_CLAMPED_HEX_DUMP_HPP
23
24 #include <realm/util/hex_dump.hpp>
25 #include <realm/binary_data.hpp>
26
27 namespace realm {
28 namespace _impl {
29
30 /// Limit the amount of dumped data to 1024 bytes. For use in connection with
31 /// logging.
32 inline std::string clamped_hex_dump(BinaryData blob)
33 {
34     bool was_clipped = false;
35     std::size_t max_size = 1024;
36     std::size_t size_2 = blob.size();
37     if (size_2 > max_size) {
38         size_2 = max_size;
39         was_clipped = true;
40     }
41     std::string str = util::hex_dump(blob.data(), size_2); // Throws
42     if (was_clipped)
43         str += "..."; // Throws
44     return str;
45 }
46
47 } // namespace _impl
48 } // namespace realm
49
50 #endif // REALM_IMPL_CLAMPED_HEX_DUMP_HPP