Microsoft Information Protection (MIP) SDK for C++: Reference 1.16
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
storage_table.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 */
27/**
28 * @brief Defines StorageTable interface
29 *
30 * @file storage_table.h
31 */
32
33#ifndef API_MIP_STORAGE_TABLE_H_
34#define API_MIP_STORAGE_TABLE_H_
35
36#include <cstdint>
37#include <string>
38#include <vector>
39
40#include "mip/mip_namespace.h"
41
42using std::uint32_t;
43
44MIP_NAMESPACE_BEGIN
45
46/**
47 * @brief Defines actions for column specification based on values.
48 */
49enum class ColumnMatch {
50 Equals = 0, /*< Match column if data equals a specific value (=) */
51 LessThan = 1, /*< Match column if data is less than a specific value (<) */
52 GreaterThan = 2, /*< Match column if data is greater than a specific value (>) */
53 LessThanEqualTo = 3, /*< Match column if data is less than or equal to a specific value (<=) */
54 GreaterThanEqualTo = 4, /*< Match column if data is greater than or equal to a specific value (>=) */
55 NotEquals = 5, /*< Match column if data is not equal to a specific value (<>) */
56};
57
58/**
59 * @brief A class that defines the interface to the MIP SDK storage table used for caching
60 */
62public:
63 /**
64 * @brief Adds a row to the table
65 *
66 * @param allColumnValues All column values in sequence as represented in storage table.
67 *
68 * @deprecated This method will soon be deprecated in favor of InsertOrReplace. If the new version
69 * has been implemented, there is no need to implement this version.
70 */
71#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
72 [[deprecated("Insert method is deprecated, instead use InsertOrReplace method")]]
73#endif
74 virtual void Insert(const std::vector<std::string>& allColumnValues)
75 {
76 InsertOrReplace(allColumnValues);
77 }
78
79 /**
80 * @brief Adds a row to the table
81 *
82 * @param allColumnValues All column values in sequence as represented in storage table.
83 */
84 virtual void InsertOrReplace(const std::vector<std::string>& allColumnValues) = 0;
85
86 /**
87 * @brief List all the rows in the table
88 *
89 * @return List of all rows where each row is a vector of column values
90 */
91 virtual std::vector<std::vector<std::string>> List() = 0;
92
93 /**
94 * @brief Update a set of rows within the table.
95 *
96 * @param updateColumns List of column names that define the new row data.
97 * @param updateValues List of column values corresponding to @p updateColumns.
98 * @param queryColumns List of column names that identify the table rows to update.
99 * @param queryValues List of column values corresponding to @p queryColumns.
100 *
101 */
102 virtual void Update(
103 const std::vector<std::string>& updateColumns,
104 const std::vector<std::string>& updateValues,
105 const std::vector<std::string>& queryColumns,
106 const std::vector<std::string>& queryValues) = 0;
107
108 /**
109 * @brief Delete a set of rows specified by queryColumns and queryValues
110 *
111 * @param queryColumns List of column names that identify the table rows to delete.
112 * @param queryValues List of column values corresponding to @p queryColumns.
113 *
114 */
115 virtual void Delete(
116 const std::vector<std::string>& queryColumns,
117 const std::vector<std::string>& queryValues) = 0;
118
119 /**
120 * @brief Find a set of rows specified by @p queryColumns and @p queryValues. This method can return multiple rows based on the filter.
121 *
122 * @param queryColumns List of column names that identify the table rows to find.
123 * @param queryValues List of column values corresponding to @p queryColumns.
124 *
125 * @return List of all rows where each row is a list containing column values
126 */
127 virtual std::vector<std::vector<std::string>> Find(
128 const std::vector<std::string>& queryColumns,
129 const std::vector<std::string>& queryValues) = 0;
130
131 /** @cond DOXYGEN_HIDE */
132 virtual ~StorageTable() {}
133protected:
134 StorageTable() {}
135 /** @endcond */
136};
137
138/**
139 * @brief An extension to the class that defines the interface to the MIP SDK storage table used for caching
140 *
141 * @note To use the additional functionality of this class, the storage table version on StorageDelegate::StorageSettings must be >= StorageTableVersion::Two
142 */
144public:
145 /**
146 * @brief Delete a set of rows with values greater or lesser than a target value.
147 * Need to set storage table version on StorageSettings to be >= StorageTableVersion::Two
148 *
149 * @param queryColumns Column names to determine the table rows to delete.
150 * @param queryValues Column values which combine with a specific relation to get the delete set. Corresponding to the data in @p queryColumns
151 * @param relations The relation to use to specify data. Corresponding to the data in @p queryValues
152 *
153 * @return Number of rows deleted
154 *
155 * @note Intended for use on ISO time values, where sorting alphabetically is equivalent to sorting chronologically.
156 * @warning Will not work on encrypted columns.
157 */
158 virtual uint32_t DeleteRange(
159 const std::vector<std::string>& queryColumns,
160 const std::vector<std::string>& queryValues,
161 const std::vector<ColumnMatch>& relations) = 0;
162
163 /** @cond DOXYGEN_HIDE */
164 virtual ~StorageTableV2() {}
165protected:
167 /** @endcond */
168};
169
170MIP_NAMESPACE_END
171#endif // API_MIP_STORAGE_TABLE_H_
An extension to the class that defines the interface to the MIP SDK storage table used for caching.
virtual uint32_t DeleteRange(const std::vector< std::string > &queryColumns, const std::vector< std::string > &queryValues, const std::vector< ColumnMatch > &relations)=0
Delete a set of rows with values greater or lesser than a target value. Need to set storage table ver...
A class that defines the interface to the MIP SDK storage table used for caching.
virtual void Delete(const std::vector< std::string > &queryColumns, const std::vector< std::string > &queryValues)=0
Delete a set of rows specified by queryColumns and queryValues.
virtual void Insert(const std::vector< std::string > &allColumnValues)
Adds a row to the table.
virtual void InsertOrReplace(const std::vector< std::string > &allColumnValues)=0
Adds a row to the table.
virtual void Update(const std::vector< std::string > &updateColumns, const std::vector< std::string > &updateValues, const std::vector< std::string > &queryColumns, const std::vector< std::string > &queryValues)=0
Update a set of rows within the table.
virtual std::vector< std::vector< std::string > > List()=0
List all the rows in the table.
virtual std::vector< std::vector< std::string > > Find(const std::vector< std::string > &queryColumns, const std::vector< std::string > &queryValues)=0
Find a set of rows specified by queryColumns and queryValues. This method can return multiple rows ba...
MIP namespace macros.
ColumnMatch
Defines actions for column specification based on values.