Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
metadata_version.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 * @brief A file containing the MetadataVersion class and the MetadataVersionFormat enumerator.
28 *
29 * @file metadata_version.h
30 */
31
32#ifndef API_MIP_UPE_METADATA_VERSION_H_
33#define API_MIP_UPE_METADATA_VERSION_H_
34
35#include <cstdint>
36
37#include "mip/mip_namespace.h"
38
39using std::uint32_t;
40
41MIP_NAMESPACE_BEGIN
42
43/**
44 * @brief Different algorithms to use when processing metadata.
45 */
46enum class MetadataVersionFormat : unsigned int {
47 DEFAULT = 0,
48 ONE_LABEL_PER_TENANT = 1 << 0 /**< When filtering label versions, only allow one label per tenant id*/
49};
50
51/**
52 * @brief Or (|) operator for MetadataVersionFormat type enum.
53 */
55 return static_cast<MetadataVersionFormat>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
56}
57/**
58 * @brief And (&) operator for MetadataVersionFormat type enum.
59 */
61 return static_cast<MetadataVersionFormat>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b));
62}
63/**
64 * @brief Xor (^) operator for MetadataVersionFormat type enum.
65 */
67 return static_cast<MetadataVersionFormat>(static_cast<unsigned int>(a) ^ static_cast<unsigned int>(b));
68}
69
70/**
71 * @brief Interface for a MetadataVersion. MetadataVersion determines which metadata is active and how it is processed.
72 */
74public:
75 /**
76 * @brief MetadataVersion constructor
77 * @param version numerical version to use for metadata actions
78 * @param flags flags to specify how the version is used to calculate metadata actions
79 */
80 MetadataVersion(uint32_t version, MetadataVersionFormat flags) : mVersion(version), mFlags(flags) {}
81 /**
82 * @brief Get the numerical version.
83 *
84 * @return The numerical version.
85 */
86 virtual uint32_t GetValue() const { return mVersion; }
87 /**
88 * @brief Get whether a specific flag is set.
89 *
90 * @return true if the flag is set.
91 */
92 virtual bool HasFlag(MetadataVersionFormat flag) const { return flag == (flag & mFlags); }
93 /**
94 * @brief Get the flags that define how metadata is processed for a given version.
95 *
96 * @return The flags that specify how the metadata is processed.
97 */
98 virtual MetadataVersionFormat GetFlags() const { return mFlags; }
99 /** @cond DOXYGEN_HIDE */
100 operator uint32_t() const { return mVersion; }
101 virtual ~MetadataVersion() {}
102private:
103 uint32_t mVersion;
105 /** @endcond */
106};
107
108MIP_NAMESPACE_END
109
110#endif // API_MIP_UPE_METADATA_VERSION_H_
Interface for a MetadataVersion.
virtual bool HasFlag(MetadataVersionFormat flag) const
Get whether a specific flag is set.
virtual MetadataVersionFormat GetFlags() const
Get the flags that define how metadata is processed for a given version.
virtual uint32_t GetValue() const
Get the numerical version.
MetadataVersion(uint32_t version, MetadataVersionFormat flags)
MetadataVersion constructor.
MetadataVersionFormat operator&(MetadataVersionFormat a, MetadataVersionFormat b)
And (&) operator for MetadataVersionFormat type enum.
MetadataVersionFormat operator^(MetadataVersionFormat a, MetadataVersionFormat b)
Xor (^) operator for MetadataVersionFormat type enum.
MetadataVersionFormat operator|(MetadataVersionFormat a, MetadataVersionFormat b)
Or (|) operator for MetadataVersionFormat type enum.
MetadataVersionFormat
Different algorithms to use when processing metadata.
@ ONE_LABEL_PER_TENANT
When filtering label versions, only allow one label per tenant id.
MIP namespace macros.