C++ Server-Side SDK
LaunchDarkly SDK
Loading...
Searching...
No Matches
attribute_reference.hpp
1#pragma once
2
3#include <algorithm>
4#include <cstddef>
5#include <ostream>
6#include <set>
7#include <string>
8#include <vector>
9
10namespace launchdarkly {
11
35 public:
36 using SetType = std::set<AttributeReference>;
37
48 [[nodiscard]] std::string const& Component(std::size_t depth) const;
49
56 [[nodiscard]] std::size_t Depth() const;
57
63 [[nodiscard]] bool IsKind() const;
64
69 [[nodiscard]] bool Valid() const;
70
77 [[nodiscard]] std::string const& RedactionName() const;
78
85 static AttributeReference FromReferenceStr(std::string ref_str);
86
95 static AttributeReference FromLiteralStr(std::string lit_str);
96
104 static std::string PathToStringReference(
105 std::vector<std::string_view> path);
106
107 friend std::ostream& operator<<(std::ostream& os,
108 AttributeReference const& ref) {
109 os << (ref.Valid() ? "valid" : "invalid") << "(" << ref.RedactionName()
110 << ")";
111 return os;
112 }
113
118 AttributeReference(std::string ref_str);
119
124 AttributeReference(char const* ref_str);
125
130
131 bool operator==(AttributeReference const& other) const {
132 return components_ == other.components_;
133 }
134
135 bool operator==(std::vector<std::string_view> const& path) const {
136 return components_.size() == path.size() &&
137 std::equal(components_.begin(), components_.end(), path.begin());
138 }
139
140 bool operator!=(AttributeReference const& other) const {
141 return !(*this == other);
142 }
143
144 bool operator!=(std::vector<std::string_view> const& path) const {
145 return !(*this == path);
146 }
147
148 bool operator<(AttributeReference const& rhs) const {
149 return components_ < rhs.components_;
150 }
151
152 private:
153 AttributeReference(std::string str, bool is_literal);
154
155 bool valid_ = false;
156
157 std::string redaction_name_;
158 std::vector<std::string> components_;
159 inline static const std::string empty_;
160};
161
162} // namespace launchdarkly
Definition attribute_reference.hpp:34
bool IsKind() const
Definition attribute_reference.cpp:215
static AttributeReference FromReferenceStr(std::string ref_str)
Definition attribute_reference.cpp:200
std::string const & RedactionName() const
Definition attribute_reference.cpp:223
static AttributeReference FromLiteralStr(std::string lit_str)
Definition attribute_reference.cpp:196
bool Valid() const
Definition attribute_reference.cpp:219
std::size_t Depth() const
Definition attribute_reference.cpp:211
AttributeReference()
Definition attribute_reference.cpp:233
static std::string PathToStringReference(std::vector< std::string_view > path)
Definition attribute_reference.cpp:235
std::string const & Component(std::size_t depth) const
Definition attribute_reference.cpp:204