commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
comms::FlagSet Class Reference

An insertion-ordered set of unique flags, deduplicated by name. More...

#include <flag.hpp>

Public Member Functions

template<AnyFlag F>
bool insert ()
 Insert a flag by type.
 
bool insert (const FlagRef &f)
 Insert a FlagRef, deduplicating by name. Returns true if newly added.
 
std::size_t count (const std::string_view name) const
 0 or 1 — flags are unique by name, so this mirrors std::set::count.
 
bool erase (const std::string_view name)
 Erase the flag with the given name. Returns true if one was removed.
 
std::map< std::string_view, std::vector< FlagRef > > group_by_category () const
 Flags grouped by category name.
 

Static Public Member Functions

template<AnyFlag... Fs>
static FlagSet of ()
 Build a set from a flag type pack, inserting each in order.
 

Detailed Description

An insertion-ordered set of unique flags, deduplicated by name.

Backed by a std::vector<FlagRef> so iteration preserves insertion order — hence it wraps a vector and exposes std::set-style names rather than deriving from std::set, which would sort.

Member Function Documentation

◆ group_by_category()

std::map< std::string_view, std::vector< FlagRef > > comms::FlagSet::group_by_category ( ) const
inline

Flags grouped by category name.

Within each group, insertion order is preserved; the outer map is ordered by category name (std::map).

◆ insert()

template<AnyFlag F>
bool comms::FlagSet::insert ( )
inline

Insert a flag by type.

Returns true if it was newly added, false if a flag with the same name was already present.

◆ of()

template<AnyFlag... Fs>
static FlagSet comms::FlagSet::of ( )
inlinestatic

Build a set from a flag type pack, inserting each in order.

Lets call sites stay terse: FlagSet::of<Flag1, Flag2>().


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