Debian Codegraph @

intl/icu_capi/bindings/cpp/ICU4XLogger.hpp

raw
1 #ifndef ICU4XLogger_HPP
2 #define ICU4XLogger_HPP
3 #include <stdint.h>
4 #include <stddef.h>
5 #include <stdbool.h>
6 #include <algorithm>
7 #include <memory>
8 #include <variant>
9 #include <optional>
10 #include "diplomat_runtime.hpp"
11
12 #include "ICU4XLogger.h"
13
14
15 /**
16 * A destruction policy for using ICU4XLogger with std::unique_ptr.
17 */
18 struct ICU4XLoggerDeleter {
19 void operator()(capi::ICU4XLogger* l) const noexcept {
20 capi::ICU4XLogger_destroy(l);
21 }
22 };
23
24 /**
25 * An object allowing control over the logging used
26 */
27 class ICU4XLogger {
28 public:
29
30 /**
31 * Initialize the logger using `simple_logger`
32 *
33 * Requires the `simple_logger` Cargo feature.
34 *
35 * Returns `false` if there was already a logger set.
36 */
37 static bool init_simple_logger();
38
39 /**
40 * Deprecated: since ICU4X 1.4, this now happens automatically if the `log` feature is enabled.
41 */
42 static bool init_console_logger();
43 inline const capi::ICU4XLogger* AsFFI() const { return this->inner.get(); }
44 inline capi::ICU4XLogger* AsFFIMut() { return this->inner.get(); }
45 inline explicit ICU4XLogger(capi::ICU4XLogger* i) : inner(i) {}
46 ICU4XLogger() = default;
47 ICU4XLogger(ICU4XLogger&&) noexcept = default;
48 ICU4XLogger& operator=(ICU4XLogger&& other) noexcept = default;
49 private:
50 std::unique_ptr<capi::ICU4XLogger, ICU4XLoggerDeleter> inner;
51 };
52
53
54 inline bool ICU4XLogger::init_simple_logger() {
55 return capi::ICU4XLogger_init_simple_logger();
56 }
57 inline bool ICU4XLogger::init_console_logger() {
58 return capi::ICU4XLogger_init_console_logger();
59 }
60 #endif