Microsoft Information Protection SDK - C++ 1.18
API Reference Documentation for C++
Loading...
Searching...
No Matches
storage_delegate.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
33#ifndef API_MIP_STORAGE_DELEGATE_H_
34#define API_MIP_STORAGE_DELEGATE_H_
35
36#include <string>
37#include <vector>
38
39#include "mip/common_types.h"
41#include "mip/mip_namespace.h"
42#include "mip/storage_table.h"
43
44MIP_NAMESPACE_BEGIN
45
49enum class MipComponent : unsigned int {
50 Policy = 0, /* For Policy sdk */
51 File = 1, /* For File sdk */
52 Protection = 2, /* For Protection sdk */
53 Core = 3, /* For MIP Core*/
54};
55
59typedef mip::DelegateResponse<mip::StorageTable> StorageTableResult;
60
65public:
66
80 virtual mip::StorageTableResult CreateStorageTable(
81 const std::string& path,
82 const MipComponent mipComponent,
83 const std::string& tableName,
84 const std::vector<std::string>& allColumns,
85 const std::vector<std::string>& encryptedColumns,
86 const std::vector<std::string>& keyColumns) const = 0;
87
92 public:
102 bool isRemoteStorage,
103 bool isInMemoryStorageSupported,
104 const std::string& onDiskExtension = GetSqliteExtension(),
105 StorageTableVersion storageTableVersion = StorageTableVersion::One)
106 : mIsRemoteStorage(isRemoteStorage),
107 mIsInMemoryStorageSupported(isInMemoryStorageSupported),
108 mOnDiskExtension(onDiskExtension),
109 mStorageTableVersion(static_cast<unsigned int>(storageTableVersion)) {
110 if (mStorageTableVersion < static_cast<unsigned int>(StorageTableVersion::One) || mStorageTableVersion > static_cast<unsigned int>(StorageTableVersion::Two)) {
111 throw std::invalid_argument("Storage table version must be between StorageTableVersion::One and StorageTableVersion::Two");
112 }
113 }
114
120 bool IsRemoteStorage() const { return mIsRemoteStorage; }
121
127 bool IsInMemoryStorageSupported() const { return mIsInMemoryStorageSupported; }
128
136 std::string OnDiskExtension() const { return mOnDiskExtension; }
137
143 unsigned int GetStorageTableVersion() const { return mStorageTableVersion; }
144
146 ~StorageSettings() { }
148 private:
149 bool mIsRemoteStorage;
150 bool mIsInMemoryStorageSupported;
151 std::string mOnDiskExtension;
152 unsigned int mStorageTableVersion;
154 };
155
161 virtual StorageSettings GetSettings() const = 0;
162
164 virtual ~StorageDelegate() {}
165
166protected:
167 StorageDelegate() {}
169};
170
171MIP_NAMESPACE_END
172#endif // API_MIP_STORAGE_DELEGATE_H_
173
Settings used by StorageDelegate.
Definition storage_delegate.h:91
bool IsInMemoryStorageSupported() const
Gets whether the delegate supports in-memory storage.
Definition storage_delegate.h:127
std::string OnDiskExtension() const
Gets the extension that the delegate will use when storing a table on disk.
Definition storage_delegate.h:136
unsigned int GetStorageTableVersion() const
Gets the version of the underlying storage tables that will be created by this StorageDelegate.
Definition storage_delegate.h:143
StorageSettings(bool isRemoteStorage, bool isInMemoryStorageSupported, const std::string &onDiskExtension=GetSqliteExtension(), StorageTableVersion storageTableVersion=StorageTableVersion::One)
Interface for configuring the storage settings.
Definition storage_delegate.h:101
bool IsRemoteStorage() const
Gets whether remote storage is used or not.
Definition storage_delegate.h:120
A class that defines the interface to the MIP SDK storage for caching.
Definition storage_delegate.h:64
virtual StorageSettings GetSettings() const =0
Gets settings used by StorageDelegate.
virtual mip::StorageTableResult CreateStorageTable(const std::string &path, const MipComponent mipComponent, const std::string &tableName, const std::vector< std::string > &allColumns, const std::vector< std::string > &encryptedColumns, const std::vector< std::string > &keyColumns) const =0
Creates an instance of a storage table that MIP uses for caching. If a table already exists & schema ...
A file Containing the common types used by the upe, file and protection modules.
const std::string & GetSqliteExtension()
Definition common_types.h:256
StorageTableVersion
The features available in the storage tables being used.
Definition common_types.h:270
A simple framework to create a response to delegate calls that can result in error.
MIP namespace macros.
mip::DelegateResponse< mip::StorageTable > StorageTableResult
A delegate response type for StorageTable.
Definition storage_delegate.h:59
MipComponent
Describes the MIP component to be used in the application.
Definition storage_delegate.h:49
Defines StorageTable interface.