C++ Server-Side SDK
LaunchDarkly SDK
Classes | Public Member Functions | Friends | List of all members
launchdarkly::server_side::hooks::EvaluationSeriesData Class Reference

#include <hook.hpp>

Public Member Functions

 EvaluationSeriesData ()
 
std::optional< std::reference_wrapper< Value const > > Get (std::string const &key) const
 
std::optional< std::shared_ptr< std::any > > GetShared (std::string const &key) const
 
bool Has (std::string const &key) const
 
std::vector< std::string > Keys () const
 

Friends

class EvaluationSeriesDataBuilder
 

Detailed Description

Immutable data that can be passed between hook stages. Provides readonly access to data passed between hook stages.

Supports two types of data:

Lifetime: Objects of this type are valid only during the execution of a hook stage. Do not store references or pointers to this data. If you need data beyond the stage execution, copy it.

Constructor & Destructor Documentation

◆ EvaluationSeriesData()

launchdarkly::server_side::hooks::EvaluationSeriesData::EvaluationSeriesData ( )
default

Constructs empty series data.

Member Function Documentation

◆ Get()

std::optional< std::reference_wrapper< Value const > > launchdarkly::server_side::hooks::EvaluationSeriesData::Get ( std::string const &  key) const

Retrieves a Value from the series data.

Lifetime: The returned reference (if present) is valid only during the execution of the current hook stage. If you need the value beyond this call, make a copy.

Parameters
keyThe key to look up.
Returns
Reference to the value if present, or std::nullopt if not found or if the key maps to a shared_ptr.

◆ GetShared()

std::optional< std::shared_ptr< std::any > > launchdarkly::server_side::hooks::EvaluationSeriesData::GetShared ( std::string const &  key) const

Retrieves a shared_ptr to any type from the series data.

Use this for storing arbitrary objects like OpenTelemetry spans that need to be passed from beforeEvaluation to afterEvaluation.

Example:

auto span = data.GetShared("span");
if (span) {
auto typed_span = std::any_cast<MySpanType>(*span);
}
Parameters
keyThe key to look up.
Returns
The shared_ptr if present, or std::nullopt if not found or if the key maps to a Value.

◆ Has()

bool launchdarkly::server_side::hooks::EvaluationSeriesData::Has ( std::string const &  key) const

Checks if a key exists in the series data.

Parameters
keyThe key to check.
Returns
True if the key exists, false otherwise.

◆ Keys()

std::vector< std::string > launchdarkly::server_side::hooks::EvaluationSeriesData::Keys ( ) const

Returns all keys in the series data.

Lifetime: The returned vector contains copies of the keys and can be stored safely.

Returns
Vector of all keys.

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