Realm C++ SDK Version v2.2.0

uuid.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_BRIDGE_UUID_HPP
20#define CPPREALM_BRIDGE_UUID_HPP
21
22#include <cpprealm/internal/bridge/utils.hpp>
23#include <string_view>
24#include <array>
25
26namespace realm {
27 struct uuid;
28 class UUID;
29}
30
31namespace realm::internal::bridge {
32 struct uuid {
33 uuid();
34 uuid(const uuid& other) = default;
35 uuid& operator=(const uuid& other) = default;
36 uuid(uuid&& other) = default;
37 uuid& operator=(uuid&& other) = default;
38 ~uuid() = default;
39 uuid(const UUID&); //NOLINT(google-explicit-constructor);
40 explicit uuid(const std::string&);
41 uuid(const std::array<uint8_t, 16>&);
42 uuid(const struct ::realm::uuid&); //NOLINT(google-explicit-constructor);
43 operator UUID() const; //NOLINT(google-explicit-constructor);
44 operator ::realm::uuid() const; //NOLINT(google-explicit-constructor);
45 [[nodiscard]] std::string to_string() const;
46 [[nodiscard]] std::string to_base64() const;
47 [[nodiscard]] std::array<uint8_t, 16> to_bytes() const;
48 private:
49 std::array<uint8_t, 16> m_uuid;
50 friend bool operator ==(const uuid&, const uuid&);
51 friend bool operator !=(const uuid&, const uuid&);
52 friend bool operator >(const uuid&, const uuid&);
53 friend bool operator <(const uuid&, const uuid&);
54 friend bool operator >=(const uuid&, const uuid&);
55 friend bool operator <=(const uuid&, const uuid&);
56 };
57
58 bool operator ==(const uuid&, const uuid&);
59 bool operator !=(const uuid&, const uuid&);
60 bool operator >(const uuid&, const uuid&);
61 bool operator <(const uuid&, const uuid&);
62 bool operator >=(const uuid&, const uuid&);
63 bool operator <=(const uuid&, const uuid&);
64}
65
66#endif //CPPREALM_BRIDGE_UUID_HPP
Definition: uuid.hpp:32