Realm C++ SDK Version v2.2.0

status.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_REALM_STATUS_HPP
20#define CPPREALM_BRIDGE_REALM_STATUS_HPP
21
22#include <cpprealm/internal/bridge/utils.hpp>
23
24namespace realm {
25 class Status;
26 struct ErrorCategory;
27}
28namespace realm::internal::bridge {
29
31 enum type {
32 logic_error,
33 runtime_error,
34 invalid_argument,
35 file_access,
36 system_error,
38 client_error,
39 json_error,
40 service_error,
41 http_error,
42 custom_error,
43 websocket_error,
45 };
46 error_category() = default;
47 error_category(error_category&&) = default;
48 error_category(const error_category&) = default;
49 error_category& operator=(const error_category&) = default;
50 error_category& operator=(error_category&&) = default;
51 ~error_category() = default;
52 bool test(type cat);
53 error_category& set(type cat);
54 void reset(type cat);
55 bool operator==(const error_category& other) const;
56 bool operator!=(const error_category& other) const;
57 int value() const;
58
59 private:
60 unsigned m_error_category = 0;
61 };
62
63 struct status {
64 static status ok();
65 status(const ::realm::Status&);
66 status(::realm::Status&&);
67 status(const status&);
68 status(status&&);
69 status& operator=(const status&);
70 status& operator=(status&&);
71 ~status();
72
73 bool is_ok() const noexcept;
74 const std::string& reason() const noexcept;
75 std::string_view code_string() const noexcept;
76 operator ::realm::Status() const noexcept;
77 private:
78#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
79 storage::Status m_status[1];
80#else
81 std::shared_ptr<Status> m_status;
82#endif
83 };
84
85} // namespace realm::internal::bridge
86#endif //CPPREALM_BRIDGE_REALM_STATUS_HPP
Definition: app.hpp:53
Definition: set.hpp:48
Definition: status.hpp:63
Definition: sync_error.hpp:40