C++ Server-Side SDK
LaunchDarkly SDK
Public Member Functions | Friends | List of all members
launchdarkly::AttributesBuilder< BuilderReturn, BuildType > Class Template Referencefinal

#include <attributes_builder.hpp>

Public Member Functions

 AttributesBuilder (BuilderReturn &builder, std::string kind, std::string key)
 
 AttributesBuilder (BuilderReturn &builder, std::string kind, Attributes const &attributes)
 
 AttributesBuilder (AttributesBuilder const &builder)=delete
 
AttributesBuilderoperator= (AttributesBuilder const &)=delete
 
AttributesBuilderoperator= (AttributesBuilder &&)=delete
 
 AttributesBuilder (AttributesBuilder &&builder)=default
 
AttributesBuilderName (std::string name)
 
AttributesBuilderAnonymous (bool anonymous)
 
AttributesBuilderSet (std::string name, launchdarkly::Value value)
 
AttributesBuilderSetPrivate (std::string name, launchdarkly::Value value)
 
AttributesBuilderAddPrivateAttribute (AttributeReference ref)
 
template<typename IterType >
AttributesBuilderAddPrivateAttributes (IterType attributes)
 
AttributesBuilderKind (std::string kind, std::string key)
 
AttributesBuilderKind (std::string const &kind)
 
BuildType Build () const
 
AttributesBuilder< ContextBuilder, Context > & Name (std::string name)
 
AttributesBuilder< ContextBuilder, Context > & Anonymous (bool anonymous)
 
AttributesBuilder< ContextBuilder, Context > & Set (std::string name, Value value, bool private_attribute)
 
AttributesBuilder< ContextBuilder, Context > & Set (std::string name, Value value)
 
AttributesBuilder< ContextBuilder, Context > & SetPrivate (std::string name, Value value)
 
AttributesBuilder< ContextBuilder, Context > & AddPrivateAttribute (AttributeReference ref)
 

Friends

class ContextBuilder
 

Detailed Description

template<class BuilderReturn, class BuildType>
class launchdarkly::AttributesBuilder< BuilderReturn, BuildType >

This is used in the implementation of the context builder for setting attributes for a single context. This is not intended to be directly used by an SDK consumer.

Template Parameters
BuilderReturnThe type of builder using the AttributesBuilder.
BuildTypeThe type of object being built.

Constructor & Destructor Documentation

◆ AttributesBuilder() [1/3]

template<class BuilderReturn , class BuildType >
launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::AttributesBuilder ( BuilderReturn &  builder,
std::string  kind,
std::string  key 
)
inline

Create an attributes builder with the given kind and key.

Parameters
builderThe context builder associated with this attributes builder.
kindThe kind being added.
keyThe key for the kind.

◆ AttributesBuilder() [2/3]

template<class BuilderReturn , class BuildType >
launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::AttributesBuilder ( BuilderReturn &  builder,
std::string  kind,
Attributes const &  attributes 
)
inline

Crate an attributes builder with the specified kind, and pre-populated with the given attributes.

Parameters
builderThe context builder associated with this attributes builder.
kindThe kind being added.
attributesAttributes to populate the builder with.

◆ AttributesBuilder() [3/3]

template<class BuilderReturn , class BuildType >
launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::AttributesBuilder ( AttributesBuilder< BuilderReturn, BuildType > const &  builder)
delete

The attributes builder should never be copied. We depend on a stable reference stored in the context builder.

Member Function Documentation

◆ AddPrivateAttribute()

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::AddPrivateAttribute ( AttributeReference  ref)

Designate a context attribute, or properties within them, as private: that is, their values will not be sent to LaunchDarkly in analytics events.

Each parameter can be a simple attribute name, such as "email". Or, if the first character is a slash, the parameter is interpreted as a slash-delimited path to a property within a JSON object, where the first path component is a Context attribute name and each following component is a nested property name: for example, suppose the attribute "address" had the following JSON object value:

{"street": {"line1": "abc", "line2": "def"}}

Using ["/address/street/line1"] in this case would cause the "line1" property to be marked as private. This syntax deliberately resembles JSON Pointer, but other JSON Pointer features such as array indexing are not supported for Private.

This action only affects analytics events that involve this particular Context. To mark some (or all) Context attributes as private for all contexts, use the overall configuration for the SDK. See launchdarkly::config::shared::builders::EventsBuilder<SDK>::AllAttributesPrivate and launchdarkly::config::shared::builders::EventsBuilder<SDK>::PrivateAttribute.

The attributes "kind" and "key", and the "_meta" attributes cannot be made private.

In this example, firstName is marked as private, but lastName is not:

[TODO]

This is a metadata property, rather than an attribute that can be addressed in evaluations: that is, a rule clause that references the attribute name "privateAttributes", will not use this value, but would use a "privateAttributes" attribute set on the context.

Parameters
refThe reference to set private.
Returns
A reference to the current builder.

◆ AddPrivateAttributes()

template<class BuilderReturn , class BuildType >
template<typename IterType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::AddPrivateAttributes ( IterType  attributes)
inline

Add items from an iterable collection. One that provides a begin/end iterator and iterates over AttributeReferences or a convertible type.

Template Parameters
IterTypeThe type of iterable.
Parameters
attributesThe attributes to add as private.
Returns
A reference to the current builder.

◆ Anonymous()

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Anonymous ( bool  anonymous)

If true, the context will not appear on the Contexts page in the LaunchDarkly dashboard.

Parameters
anonymousThe value to set.
Returns
A reference to the current builder.

◆ Build()

template<class BuilderReturn , class BuildType >
BuildType launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Build ( ) const
inline

Build the context.

Returns
The built context.

◆ Kind() [1/2]

template<class BuilderReturn , class BuildType >
AttributesBuilder* launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Kind ( std::string const &  kind)
inline

Start updating an existing kind.

Parameters
kindThe kind to start updating.
Returns
A builder which allows adding attributes for the kind, or nullptr if the kind doesn't already exist.

◆ Kind() [2/2]

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Kind ( std::string  kind,
std::string  key 
)
inline

Start adding a kind to the context.

If you call this function multiple times with the same kind, then the same builder will be returned each time. If you previously called the function with the same kind, but different key, then the key will be updated.

Parameters
kindThe kind being added.
keyThe key for the kind.
Returns
A builder which allows adding attributes for the kind.

◆ Name()

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Name ( std::string  name)

The context's name.

You can search for contexts on the Contexts page by name.

Parameters
name
Returns
A reference to the current builder.

◆ Set()

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::Set ( std::string  name,
launchdarkly::Value  value 
)

Add or update an attribute in the context.

This method cannot be used to set the key, kind, name, anonymous, or _meta property of a context. The specific methods on the context builder, or attributes builder, should be used.

Parameters
nameThe name of the attribute.
valueThe value for the attribute.
private_attributeIf the attribute should be considered private: that is, the value will not be sent to LaunchDarkly in analytics events.
Returns
A reference to the current builder.

◆ SetPrivate()

template<class BuilderReturn , class BuildType >
AttributesBuilder& launchdarkly::AttributesBuilder< BuilderReturn, BuildType >::SetPrivate ( std::string  name,
launchdarkly::Value  value 
)

Add or update a private attribute in the context.

This method cannot be used to set the key, kind, name, or anonymous property of a context. The specific methods on the context builder, or attributes builder, should be used.

Once you have set an attribute private it will remain in the private list even if you call set afterward. This method is just a convenience which also adds the attribute to the PrivateAttributes.

Parameters
nameThe name of the attribute.
valueThe value for the attribute.
private_attributeIf the attribute should be considered private: that is, the value will not be sent to LaunchDarkly in analytics events.
Returns
A reference to the current builder.

The documentation for this class was generated from the following file: