LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::bwf::NameMap< F > Class Template Reference

#include <bwf_base.h>

Collaboration diagram for swoc::bwf::NameMap< F >:
Collaboration graph

Public Types

using Generator = std::function<F>
 Signature for generators.
 

Public Member Functions

 NameMap ()
 Construct an empty container.
 
 NameMap (std::initializer_list< std::tuple< std::string_view, Generator const & > > list)
 Construct and assign the names and generators in list.
 
self_typeassign (std::string_view const &name, Generator const &generator)
 
bool contains (std::string_view name)
 

Protected Types

using Map = std::unordered_map<std::string_view, Generator>
 

Protected Member Functions

std::string_view localize (std::string_view const &name)
 Copy name in to local storage and return a view of it.
 

Protected Attributes

Map _map
 Name to name generator.
 
MemArena _arena {1024}
 Local name storage.
 

Detailed Description

template<typename F>
class swoc::bwf::NameMap< F >

Associate generators with names.

Template Parameters
FThe function signature for generators in this container.

This is a base class used by different types of name containers. It is not expected to be used directly. A subclass should inherit from this by providing a function type F that is suitable for the subclass generators.

Definition at line 299 of file bwf_base.h.

Member Typedef Documentation

◆ Generator

template<typename F>
using swoc::bwf::NameMap< F >::Generator = std::function<F>

Signature for generators.

Definition at line 302 of file bwf_base.h.

◆ Map

template<typename F>
using swoc::bwf::NameMap< F >::Map = std::unordered_map<std::string_view, Generator>
protected

Definition at line 305 of file bwf_base.h.

Constructor & Destructor Documentation

◆ NameMap() [1/2]

template<typename F>
swoc::bwf::NameMap< F >::NameMap ( )

Construct an empty container.

Definition at line 575 of file bwf_base.h.

◆ NameMap() [2/2]

template<typename F>
swoc::bwf::NameMap< F >::NameMap ( std::initializer_list< std::tuple< std::string_view, Generator const & > > list)

Construct and assign the names and generators in list.

Definition at line 577 of file bwf_base.h.

Member Function Documentation

◆ assign()

template<typename F>
auto swoc::bwf::NameMap< F >::assign ( std::string_view const & name,
Generator const & generator )

Assign the generator to the name.

Parameters
nameName associated with the generator.
generatorThe generator function.

Definition at line 599 of file bwf_base.h.

◆ contains()

template<typename F>
bool swoc::bwf::NameMap< F >::contains ( std::string_view name)

Check if a specific name is contained in this mapping.

Parameters
nameName to check.
Returns
true if present, false if not.

Definition at line 585 of file bwf_base.h.

◆ localize()

template<typename F>
std::string_view swoc::bwf::NameMap< F >::localize ( std::string_view const & name)
protected

Copy name in to local storage and return a view of it.

Definition at line 591 of file bwf_base.h.

Member Data Documentation

◆ _arena

template<typename F>
MemArena swoc::bwf::NameMap< F >::_arena {1024}
protected

Local name storage.

Definition at line 336 of file bwf_base.h.

◆ _map

template<typename F>
Map swoc::bwf::NameMap< F >::_map
protected

Name to name generator.

Defined generators.

Definition at line 335 of file bwf_base.h.


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