ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
ICU4XList.hpp
Go to the documentation of this file.
1#ifndef ICU4XList_HPP
2#define ICU4XList_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 "ICU4XList.h"
13
14class ICU4XList;
15
19struct ICU4XListDeleter {
20 void operator()(capi::ICU4XList* l) const noexcept {
21 capi::ICU4XList_destroy(l);
22 }
23};
24
28class ICU4XList {
29 public:
30
34 static ICU4XList create();
35
40 static ICU4XList create_with_capacity(size_t capacity);
41
48 void push(const std::string_view val);
49
53 size_t len() const;
54
58 bool is_empty() const;
59 inline const capi::ICU4XList* AsFFI() const { return this->inner.get(); }
60 inline capi::ICU4XList* AsFFIMut() { return this->inner.get(); }
61 inline explicit ICU4XList(capi::ICU4XList* i) : inner(i) {}
62 ICU4XList() = default;
63 ICU4XList(ICU4XList&&) noexcept = default;
64 ICU4XList& operator=(ICU4XList&& other) noexcept = default;
65 private:
66 std::unique_ptr<capi::ICU4XList, ICU4XListDeleter> inner;
67};
68
69
71 return ICU4XList(capi::ICU4XList_create());
72}
74 return ICU4XList(capi::ICU4XList_create_with_capacity(capacity));
75}
76inline void ICU4XList::push(const std::string_view val) {
77 capi::ICU4XList_push(this->inner.get(), val.data(), val.size());
78}
79inline size_t ICU4XList::len() const {
80 return capi::ICU4XList_len(this->inner.get());
81}
82inline bool ICU4XList::is_empty() const {
83 return capi::ICU4XList_is_empty(this->inner.get());
84}
85#endif
Definition ICU4XList.hpp:28
static ICU4XList create()
Definition ICU4XList.hpp:70
ICU4XList(ICU4XList &&) noexcept=default
ICU4XList(capi::ICU4XList *i)
Definition ICU4XList.hpp:61
ICU4XList()=default
static ICU4XList create_with_capacity(size_t capacity)
Definition ICU4XList.hpp:73
bool is_empty() const
Definition ICU4XList.hpp:82
void push(const std::string_view val)
Definition ICU4XList.hpp:76
size_t len() const
Definition ICU4XList.hpp:79