C++  1.4.6
CloudBackend Software Development Kit - SDK API for C++
Types.h
1 /*
2  SDK type definitions.
3  Copyright © CloudBackend AB 2020 - 2022.-2022.
4 */
5 #ifndef INCLUDE_CBE_TYPES_H_
6 #define INCLUDE_CBE_TYPES_H_
7 
8 #include <stdint.h>
9 #include <vector>
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <utility>
14 
15 namespace CBE {
16  typedef uint64_t container_id_t;
17  typedef uint64_t date_t;
18  typedef uint64_t device_id_t;
19  typedef uint64_t document_id_t;
20  typedef uint64_t drive_id_t;
21  typedef uint64_t favorite_id_t;
22  typedef uint64_t folder_id_t;
23  typedef uint64_t group_id_t;
24  typedef uint64_t item_id_t;
25  typedef uint64_t object_id_t;
26  typedef uint64_t sync_id_t;
27  typedef uint64_t user_id_t;
28  typedef uint64_t webshare_id_t;
29  typedef uint64_t share_id_t;
30 
31  typedef uint32_t account_status_t;
32  typedef uint32_t failed_status_t;
33  typedef uint32_t http_t;
34  typedef uint32_t network_action_t;
35  typedef uint32_t persistence_t;
36  typedef uint32_t service_t;
37  typedef uint32_t sync_direction_t;
38  typedef uint32_t sync_status_t;
39  typedef uint32_t transfer_t;
40  typedef uint32_t webshare_access_t;
41  typedef uint32_t webshare_visibility_t;
42 
43  typedef signed int permission_status_t;
44  typedef int item_t;
45  typedef int stream_t;
46  typedef int visibility;
47  typedef int application_t;
48  typedef int object_t;
49  namespace XmlNamespaces {
50  static const std::string ATOM = "http://www.w3.org/2005/Atom";
51  static const std::string OS = "http://a9.com/-/spec/opensearch/1.1/";
52  static const std::string DC = "http://xcerion.com/directory.xsd";
53  static const std::string NI = "http://xcerion.com/noindex.xsd";
54  }
55 
56  namespace Service {
57  static const CBE::service_t Network = 1;
58  static const CBE::service_t LocalDB = 2;
59  }
60 
64  enum ApplicationType : application_t {
65  Open = 1,
66  Invite = 2,
67  Review = 3,
68  Closed = 4
69  };
70 
71  enum ObjectType : object_t {
72  Other = 1,
73  GroupInvites = 2,
74  ShareInvite = 3
75  };
76 
81  enum Visibility : visibility {
82  Public = 1,
83  Private = 2
84  };
85 
90  enum Permissions : permission_status_t
91  {
92  Read = 1,
93  Write = 2,
94  ReadWrite = 3,
95  Delete = 4,
96  ReadDelete = 5,
97  WriteDelete = 6,
98  ReadWriteDelete = 7,
99  ChangeACL = 8,
100  ReadChangeACL = 9,
101  WriteChangeACL = 10,
102  ReadWriteChangeACL = 11,
103  DeleteChangeACL = 12,
104  ReadDeleteChangeACL = 13,
105  WriteDeleteChangeACL = 14,
106  AllPermissions = 15,
107  NoPermissions = 0
108  };
109 
113  enum FilterOrder : uint32_t {
114  Title = 1,
115  Relevance = 2, //Note* group Searches does not use Relevance as order.
116  Published = 3,
117  Updated = 4,
118  Length = 5,
119  S1 = 6,
120  S2 = 7,
121  S3 = 8,
122  S4 = 9
123  };
124 
128  namespace Operations {
129  enum Type {
130  NoneOperation = 1,
131  FolderOperation = 2,
132  FileOperation = 3,
133  DataLoaderOperation = 4,
134  AccountOperation = 5,
135  ShareOperation = 6,
136  GroupOperation = 7
137  };
138  }
139 
144  namespace ItemType {
145  static const CBE::item_t Unapplicable = 1;
146  static const CBE::item_t Unknown = 2;
147  static const CBE::item_t Object = 4;
148  static const CBE::item_t Document = 4;
149  static const CBE::item_t Container = 8;
150  static const CBE::item_t Folder = 8;
151  static const CBE::item_t Tag = 16;
152  static const CBE::item_t Group = 32;
153  }
154 
155  namespace SyncFolderType {
156  static const uint32_t Folder = 1;
157  static const uint32_t Favorite = 2;
158  }
159 
160  namespace Access {
161  static const CBE::webshare_access_t Read = 1;
162  static const CBE::webshare_access_t Update = 2;
163  static const CBE::webshare_access_t Create = 3;
164  }
165 
166  namespace WebShareVisibility {
167  static const CBE::webshare_visibility_t Public = 1;
168  static const CBE::webshare_visibility_t Friends = 2;
169  static const CBE::webshare_visibility_t Private = 3;
170  }
171 
172  namespace AccountStatus {
173  static const CBE::account_status_t NotLoggedIn = 1;
174  static const CBE::account_status_t LoggedIn = 2;
175  static const CBE::account_status_t Failed = 3;
176  }
177 
178  namespace NetworkAction {
179  static const CBE::network_action_t Copy = 1;
180  static const CBE::network_action_t Create = 2;
181  static const CBE::network_action_t Login = 3;
182  static const CBE::network_action_t Move = 4;
183  static const CBE::network_action_t Remove = 5;
184  static const CBE::network_action_t Rename = 6;
185  static const CBE::network_action_t Restore = 7;
186  }
187 
188  namespace PersistenceOperation {
189  static const persistence_t None = 0;
190  static const persistence_t Copy = 1;
191  static const persistence_t Create = 2;
192  static const persistence_t Login = 3;
193  static const persistence_t Move = 4;
194  static const persistence_t Remove = 5;
195  static const persistence_t Rename = 6;
196  static const persistence_t Restore = 7;
197  static const persistence_t Update = 8;
198  static const persistence_t ReadOnly = 9;
199  static const persistence_t List = 10;
200  static const persistence_t Upload = 11;
201  static const persistence_t Download = 12;
202  static const persistence_t Save = 13;
203  static const persistence_t Share = 14;
204  static const persistence_t listShares = 15;
205  static const persistence_t listMyShares = 16;
206  static const persistence_t Invite = 17;
207  static const persistence_t UnShare = 18;
208  static const persistence_t SetContainerACL = 19;
209  static const persistence_t SetObjectACL = 20;
210  static const persistence_t GetContainerACL = 21;
211  static const persistence_t GetObjectACL = 22;
212  static const persistence_t Join = 23;
213  static const persistence_t Leave = 24;
214  static const persistence_t Search = 25;
215  static const persistence_t AcceptJoinRequest = 26;
216  static const persistence_t RejectJoinRequest = 27;
217  static const persistence_t Kick = 28;
218  static const persistence_t Ban = 29;
219  static const persistence_t UnBan = 30;
220 
221  }
222 
223  namespace PersistenceState {
224  static const CBE::persistence_t Memory = 1;
225  static const CBE::persistence_t Local = 2;
226  static const CBE::persistence_t Cloud = 3;
227  }
228 
229  /* Forward declarations */
230  class AccountEventProtocol;
231  class EventProtocol;
232  class GroupEventProtocol;
233  class ItemEventProtocol;
234  class ItemDataEventProtocol;
235  class NetworkEventProtocol;
236  class RemoteEventProtocol;
237  class ShareEventProtocol;
238  class TransferDownloadEventProtocol;
239  class TransferEventProtocol;
240  class TransferUploadEventProtocol;
241 
242  class Account;
243  class CloudBackend;
244  class Connection;
245  class Container;
246  class Document;
247  class Folder;
248  class Group;
249  class Item;
250  class Object;
251  class Stream;
252  class Tag;
253  class Member;
254  class Transfer;
255  class GroupInvite;
256  class QueryResult;
257  class GroupQuery;
258  class QueryChain;
259 
260  //This is the data used from shares(shareId) to keep track of user/group-id relating to a shareid
261  struct ShareData {
262  //DEFAULT = 0, ID for userId or groupId
263  uint64_t id = 0;
264  //DEFAULT == TRUE, UserId = True if userID and false if groupId
265  bool isUserId = true;
266  };
267 
268  //This class is used to be able to search lists with ID: Example:
269  //bool alreadyExists = std::find_if(vector.begin(), vector.end(), CBE::MatchesID<uint64_t>(id)) != vector.end();
270  template<typename IDType>
271  class MatchesID
272  {
273  IDType _id;
274 
275  public:
276  MatchesID(const IDType &id) : _id(id) {}
277 
278  template<class ItemType>
279  bool operator()(const ItemType &item) const
280  {
281  return item.id == _id;
282  }
283  };
284 
285  // if you have c++11 or higher SDK_CBE will be defined as std else it will be boost.
286  typedef std::shared_ptr<CBE::Item> ItemPtr;
287  typedef std::shared_ptr<CBE::Object> ObjectPtr;
288  typedef std::shared_ptr<CBE::Container> ContainerPtr;
289  typedef std::shared_ptr<CBE::Group> GroupPtr;
290  typedef std::shared_ptr<CBE::Member> MemberPtr;
291  typedef std::shared_ptr<CBE::GroupInvite> GroupInvitePtr;
292  typedef std::shared_ptr<CBE::Account> AccountPtr;
293  typedef std::shared_ptr<CBE::CloudBackend> CloudBackendPtr;
294 
295  typedef std::shared_ptr<AccountEventProtocol> AccountDelegatePtr;
296  typedef std::shared_ptr<ItemEventProtocol> ItemDelegatePtr;
297  typedef std::shared_ptr<ItemDataEventProtocol> ItemDataDelegatePtr;
298  typedef std::shared_ptr<TransferEventProtocol> TransferDelegatePtr;
299  typedef std::shared_ptr<TransferDownloadEventProtocol> TransferDownloadDelegatePtr;
300  typedef std::shared_ptr<TransferUploadEventProtocol> TransferUploadDelegatePtr;
301  typedef std::shared_ptr<ShareEventProtocol> ShareDelegatePtr;
302  typedef std::shared_ptr<GroupEventProtocol> GroupDelegatePtr;
303  typedef std::shared_ptr<QueryResult> QueryResultPtr;
304  typedef std::shared_ptr<GroupQuery> GroupQueryPtr;
305  typedef std::shared_ptr<QueryChain> QueryChainPtr;
306 
307  //The generic metadata_type for keyValue
308  typedef std::map<std::string, std::pair<std::string, bool>> metadata_type;
309  //Data index values, just because its nice
310  #define metadata_dataindex_value 0
311  #define metadata_dataindex_indexed 1
312 
313 }// namespace CBE
314 #endif // INCLUDE_CBE_TYPES_H_
CBE::Container
Definition: Container.h:17
CBE::Object
Definition: Object.h:18
CBE::ShareData
Definition: Types.h:261
CBE::Group
Definition: Group.h:13
CBE::MatchesID
Definition: Types.h:271