forked from cel-expr/cel-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_object.h
More file actions
38 lines (29 loc) · 1.04 KB
/
Copy pathcustom_object.h
File metadata and controls
38 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Helper base classes and function for custom objects.
#ifndef THIRD_PARTY_CEL_CPP_COMMON_CUSTOM_OBJECT_H_
#define THIRD_PARTY_CEL_CPP_COMMON_CUSTOM_OBJECT_H_
#include "common/value.h"
namespace google {
namespace api {
namespace expr {
namespace common {
// An object base class for objects that do not support direct member access.
class OpaqueObject : public Object {
public:
// Does not contain any accessible members.
Value GetMember(absl::string_view name) const final;
google::rpc::Status ForEach(
const std::function<google::rpc::Status(absl::string_view, const Value&)>&
call) const final;
// Assume to own value (can be overridden).
inline bool owns_value() const override { return true; }
// Require a custom ToString function.
std::string ToString() const override = 0;
protected:
// Require a custom hash function.
std::size_t ComputeHash() const override = 0;
};
} // namespace common
} // namespace expr
} // namespace api
} // namespace google
#endif // THIRD_PARTY_CEL_CPP_COMMON_CUSTOM_OBJECT_H_