Realm C++ SDK Version v2.2.0

binary.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_BINARY_HPP
20#define CPPREALM_BRIDGE_BINARY_HPP
21
22#include <vector>
23#include <cpprealm/internal/bridge/utils.hpp>
24
25namespace realm {
26 class BinaryData;
27 class OwnedBinaryData;
28}
29namespace realm::internal::bridge {
30 struct binary {
31 binary();
32 binary(const binary& other) ;
33 binary& operator=(const binary& other) ;
34 binary(binary&& other);
35 binary& operator=(binary&& other);
36 ~binary();
37 binary(const BinaryData&); //NOLINT(google-explicit-constructor)
38 binary(const std::vector<uint8_t>&); //NOLINT(google-explicit-constructor)
39 [[nodiscard]] const char* data() const;
40 [[nodiscard]] size_t size() const;
41 operator std::vector<uint8_t>() const; //NOLINT(google-explicit-constructor)
42 operator OwnedBinaryData() const; //NOLINT(google-explicit-constructor)
43 operator BinaryData() const; //NOLINT(google-explicit-constructor)
44 char operator[](size_t i) const noexcept;
45 private:
46#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
47 storage::OwnedBinaryData m_data[1];
48#else
49 char* m_data;
50 size_t m_size = 0;
51#endif
52 };
53
54 bool operator ==(const binary& lhs, const binary& rhs);
55 bool operator !=(const binary& lhs, const binary& rhs);
56}
57
58#endif //CPPREALM_BRIDGE_BINARY_HPP
Definition: binary.hpp:30