added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / core / realm / sync / feature_token.hpp
1 /*************************************************************************
2  *
3  * REALM CONFIDENTIAL
4  * __________________
5  *
6  *  [2011] - [2012] Realm Inc
7  *  All Rights Reserved.
8  *
9  * NOTICE:  All information contained herein is, and remains
10  * the property of Realm Incorporated and its suppliers,
11  * if any.  The intellectual and technical concepts contained
12  * herein are proprietary to Realm Incorporated
13  * and its suppliers and may be covered by U.S. and Foreign Patents,
14  * patents in process, and are protected by trade secret or copyright law.
15  * Dissemination of this information or reproduction of this material
16  * is strictly forbidden unless prior written permission is obtained
17  * from Realm Incorporated.
18  *
19  **************************************************************************/
20 #ifndef REALM_SYNC_FEATURE_TOKEN_HPP
21 #define REALM_SYNC_FEATURE_TOKEN_HPP
22
23 #include <realm/util/features.h>
24
25 #if !REALM_MOBILE && !defined(REALM_EXCLUDE_FEATURE_TOKENS)
26 #define REALM_HAVE_FEATURE_TOKENS 1
27 #else
28 #define REALM_HAVE_FEATURE_TOKENS 0
29 #endif
30
31 #if REALM_HAVE_FEATURE_TOKENS
32
33 #include <memory>
34
35 #include <realm/string_data.hpp>
36
37 namespace realm {
38 namespace sync {
39
40 class FeatureGate {
41 public:
42
43     // The constructor takes a JWT token as argument.
44     // The constructor throws a std::runtime_error if
45     // the token is invalid. An invalid token is a token
46     // that has bad syntax, is not signed by Realm, or is 
47     // expired.
48     FeatureGate(StringData token);
49
50     // Constructs a feature gate without any features.
51     FeatureGate();
52     ~FeatureGate();
53
54     FeatureGate(FeatureGate&&);
55     FeatureGate& operator=(FeatureGate&&);
56
57     bool has_feature(StringData feature_name);
58
59 private:
60     struct Impl;
61     std::unique_ptr<Impl> m_impl;
62 };
63
64
65 } // namespace sync
66 } // namespace realm
67
68 #endif // REALM_HAVE_FEATURE_TOKENS
69 #endif // REALM_SYNC_FEATURE_TOKEN_HPP