Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecsCpp::SpecDataValueCollection Class Reference

#include <SpecDataValueCollection.h>

Inheritance diagram for SpecsCpp::SpecDataValueCollection:
SpecsCpp::ISpecDataValueCollection

Public Member Functions

 ~SpecDataValueCollection () override
 
void add (ISpecDataValue *value) override
 
ISpecDataValueget (const char *key) const override
 
bool has (const char *key) const override
 
void foreach_value (ForEachSpecDataFn *fn) const override
 
void merge (ISpecDataValueCollection *other) override
 
void clear () override
 
- Public Member Functions inherited from SpecsCpp::ISpecDataValueCollection
virtual ~ISpecDataValueCollection ()=default
 
virtual void add (ISpecDataValue *)=0
 
virtual bool has (const char *name) const =0
 
virtual ISpecDataValueget (const char *name) const =0
 
virtual bool get_bool (const char *name) const
 
virtual int get_int (const char *name) const
 
virtual unsigned int get_unsigned_int (const char *name) const
 
virtual double get_float (const char *name) const
 
virtual const char * get_string (const char *name) const
 
virtual void * get_pointer (const char *name) const
 
virtual void foreach_value (ForEachSpecDataFn *) const =0
 
virtual void merge (ISpecDataValueCollection *)=0
 
virtual void clear ()=0
 
void foreach (std::function< void(ISpecDataValue *)> fn) const
 

Additional Inherited Members

- Public Types inherited from SpecsCpp::ISpecDataValueCollection
using ForEachSpecDataFn = IFunctionPointer< void(ISpecDataValue *)>
 

Detailed Description

Definition at line 10 of file SpecDataValueCollection.h.

Constructor & Destructor Documentation

◆ ~SpecDataValueCollection()

SpecsCpp::SpecDataValueCollection::~SpecDataValueCollection ( )
inlineoverride

Definition at line 19 of file SpecDataValueCollection.h.

19 {
20 for (auto& [key, value] : _values) delete value;
21 }

Member Function Documentation

◆ add()

void SpecsCpp::SpecDataValueCollection::add ( ISpecDataValue value)
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 23 of file SpecDataValueCollection.h.

23{ _values.emplace(value->key(), value); }

Referenced by SpecsCpp::GlobalSpecGroup::add_meta_data_for_next_component().

◆ clear()

void SpecsCpp::SpecDataValueCollection::clear ( )
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 38 of file SpecDataValueCollection.h.

38{ _values.clear(); }

◆ foreach_value()

void SpecsCpp::SpecDataValueCollection::foreach_value ( ForEachSpecDataFn fn) const
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 32 of file SpecDataValueCollection.h.

32 {
33 for (auto& [key, value] : _values) fn->invoke(value);
34 }

◆ get()

ISpecDataValue * SpecsCpp::SpecDataValueCollection::get ( const char *  key) const
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 24 of file SpecDataValueCollection.h.

24 {
25 auto found = _values.find(key);
26 return found == _values.end() ? nullptr : found->second;
27 }

◆ has()

bool SpecsCpp::SpecDataValueCollection::has ( const char *  key) const
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 28 of file SpecDataValueCollection.h.

28 {
29 auto found = _values.find(key);
30 return found != _values.end();
31 }

◆ merge()

void SpecsCpp::SpecDataValueCollection::merge ( ISpecDataValueCollection other)
inlineoverridevirtual

Implements SpecsCpp::ISpecDataValueCollection.

Definition at line 35 of file SpecDataValueCollection.h.

35 {
36 other->foreach_value(&_merge_foreach);
37 }

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