Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
security
authorization
mock_cel
cel_value.h
Go to the documentation of this file.
1
// Copyright 2020 gRPC authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
16
#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
17
18
// CelValue is a holder, capable of storing all kinds of data
19
// supported by CEL.
20
// CelValue defines explicitly typed/named getters/setters.
21
// When storing pointers to objects, CelValue does not accept ownership
22
// to them and does not control their lifecycle. Instead objects are expected
23
// to be either external to expression evaluation, and controlled beyond the
24
// scope or to be allocated and associated with some allocation/ownership
25
// controller (Arena).
26
// Usage examples:
27
// (a) For primitive types:
28
// CelValue value = CelValue::CreateInt64(1);
29
// (b) For string:
30
// std::string* msg("test");
31
// CelValue value = CelValue::CreateString(msg);
32
33
#include <
grpc/support/port_platform.h
>
34
35
#include <
stdint.h
>
36
37
#include <memory>
38
#include <string>
39
#include <utility>
40
41
#include "absl/memory/memory.h"
42
#include "absl/strings/string_view.h"
43
#include "absl/types/span.h"
44
45
namespace
grpc_core
{
46
namespace
mock_cel {
47
48
// Break cyclic depdendencies for container types.
49
class
CelMap
{
50
public
:
51
CelMap
() =
default
;
52
};
53
54
// This is a temporary stub implementation of CEL APIs.
55
// Once gRPC imports the CEL library, this class will be removed.
56
class
CelValue
{
57
public
:
58
// Default constructor.
59
// Creates CelValue with null data type.
60
CelValue
() :
CelValue
(nullptr) {}
61
62
// We will use factory methods instead of public constructors
63
// The reason for this is the high risk of implicit type conversions
64
// between bool/int/pointer types.
65
// We rely on copy elision to avoid extra copying.
66
static
CelValue
CreateNull
() {
return
CelValue
(
nullptr
); }
67
68
static
CelValue
CreateInt64
(
int64_t
/*value*/
) {
return
CreateNull
(); }
69
70
static
CelValue
CreateUint64
(
uint64_t
/*value*/
) {
return
CreateNull
(); }
71
72
static
CelValue
CreateStringView
(
absl::string_view
/*value*/
) {
73
return
CreateNull
();
74
}
75
76
static
CelValue
CreateString
(
const
std::string
*
/*str*/
) {
77
return
CreateNull
();
78
}
79
80
static
CelValue
CreateMap
(
const
CelMap
*
/*value*/
) {
return
CreateNull
(); }
81
82
private
:
83
// Constructs CelValue wrapping value supplied as argument.
84
// Value type T should be supported by specification of ValueHolder.
85
template
<
class
T>
86
explicit
CelValue
(
T
/*value*/
) {}
87
};
88
89
// CelMap implementation that uses STL map container as backing storage.
90
class
ContainerBackedMapImpl
:
public
CelMap
{
91
public
:
92
ContainerBackedMapImpl
() =
default
;
93
94
static
std::unique_ptr<CelMap>
Create
(
95
absl::Span
<std::pair<CelValue, CelValue>>
/*key_values*/
) {
96
return
absl::make_unique<ContainerBackedMapImpl>();
97
}
98
};
99
100
}
// namespace mock_cel
101
}
// namespace grpc_core
102
103
#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
absl::Span
Definition:
abseil-cpp/absl/types/span.h:152
grpc_core
Definition:
call_metric_recorder.h:31
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::mock_cel::ContainerBackedMapImpl::ContainerBackedMapImpl
ContainerBackedMapImpl()=default
T
#define T(upbtypeconst, upbtype, ctype, default_value)
grpc_core::mock_cel::CelValue::CreateNull
static CelValue CreateNull()
Definition:
cel_value.h:66
grpc_core::mock_cel::CelMap
Definition:
cel_value.h:49
int64_t
signed __int64 int64_t
Definition:
stdint-msvc2008.h:89
grpc_core::mock_cel::CelValue::CelValue
CelValue()
Definition:
cel_value.h:60
grpc_core::mock_cel::CelValue::CreateUint64
static CelValue CreateUint64(uint64_t)
Definition:
cel_value.h:70
uint64_t
unsigned __int64 uint64_t
Definition:
stdint-msvc2008.h:90
grpc_core::mock_cel::CelMap::CelMap
CelMap()=default
stdint.h
grpc_core::mock_cel::ContainerBackedMapImpl::Create
static std::unique_ptr< CelMap > Create(absl::Span< std::pair< CelValue, CelValue >>)
Definition:
cel_value.h:94
grpc_core::mock_cel::CelValue::CreateInt64
static CelValue CreateInt64(int64_t)
Definition:
cel_value.h:68
grpc_core::mock_cel::CelValue::CreateMap
static CelValue CreateMap(const CelMap *)
Definition:
cel_value.h:80
grpc_core::mock_cel::CelValue::CreateStringView
static CelValue CreateStringView(absl::string_view)
Definition:
cel_value.h:72
grpc_core::mock_cel::CelValue::CelValue
CelValue(T)
Definition:
cel_value.h:86
grpc_core::mock_cel::ContainerBackedMapImpl
Definition:
cel_value.h:90
grpc_core::mock_cel::CelValue::CreateString
static CelValue CreateString(const std::string *)
Definition:
cel_value.h:76
grpc_core::mock_cel::CelValue
Definition:
cel_value.h:56
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:43