6 #include <launchdarkly/attributes.hpp>
7 #include <launchdarkly/value.hpp>
9 namespace launchdarkly {
12 inline static const std::string kInvalidKind =
13 "\"Kind contained invalid characters. A kind may contain ASCII letters "
15 "numbers, as well as '.', '-', and '_'.\"";
18 inline static const std::string kInvalidKey =
19 "\"The key for a context may not be empty.\"";
20 inline static const std::string kMissingKinds =
21 "\"The context must contain at least 1 kind.\"";
38 [[nodiscard]] std::vector<std::string>
const&
Kinds()
const;
49 std::string
const& kind)
const;
61 std::string
const& kind,
69 [[nodiscard]]
bool Valid()
const {
return valid_; }
81 [[nodiscard]] std::map<std::string, std::string>
const&
KindsToKeys()
const;
90 std::string
const&
errors() {
return errors_; }
92 friend std::ostream& operator<<(std::ostream& out,
Context const& context) {
94 out <<
"{contexts: [";
96 for (
auto const& kind : context.attributes_) {
102 out <<
"kind: " << kind.first <<
" attributes: " << kind.second;
106 out <<
"{invalid: errors: [" << context.errors_ <<
"]";
112 ~Context() =
default;
113 Context(Context
const& context) =
default;
114 Context(Context&& context) =
default;
115 Context& operator=(Context
const&) =
default;
116 Context& operator=(Context&&) =
default;
122 Context(std::string error_message);
128 Context(std::map<std::string, launchdarkly::Attributes> attributes);
130 std::map<std::string, launchdarkly::Attributes> attributes_;
131 std::vector<std::string> kinds_;
132 std::map<std::string, std::string> kinds_to_keys_;
135 std::string canonical_key_;
137 std::string make_canonical_key();
Definition: attribute_reference.hpp:34
Definition: attributes.hpp:15
Definition: context_builder.hpp:62
Definition: context.hpp:29
Value const & Get(std::string const &kind, launchdarkly::AttributeReference const &ref) const
Definition: context.cpp:42
bool Valid() const
Definition: context.hpp:69
launchdarkly::Attributes const & Attributes(std::string const &kind) const
Definition: context.cpp:51
std::map< std::string, std::string > const & KindsToKeys() const
Definition: context.cpp:59
std::vector< std::string > const & Kinds() const
Definition: context.cpp:25
std::string const & CanonicalKey() const
Definition: context.cpp:55
std::string const & errors()
Definition: context.hpp:90
Definition: context.hpp:11