LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MultipleChoiceSelection.h File Reference

Helper to select an string option among a set of allowed choices. More...

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstddef>
#include <exception>
#include <limits>
#include <map>
#include <optional>
#include <ostream>
#include <string>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Classes

struct  util::details::CaseInsensitiveComparer
 
struct  util::details::SorterFrom< Comparer >
 
struct  util::details::ValueToString< Value, typename >
 
class  util::details::MultipleChoiceSelectionOption_t< Choices >
 Class representing one of the available options to be selected. More...
 
class  util::MultipleChoiceSelectionBase
 Base class of util::MultipleChoiceSelection with basics independent of the option type. More...
 
struct  util::MultipleChoiceSelectionBase::Exception
 
struct  util::MultipleChoiceSelectionBase::UnknownOptionError
 Request for unknown option. More...
 
struct  util::MultipleChoiceSelectionBase::OptionAlreadyExistsError
 Adding an option that already exists. More...
 
class  util::MultipleChoiceSelection< Choices >
 Helper to select one among multiple choices via strings. More...
 
class  util::MultipleChoiceSelection< Choices >
 Helper to select one among multiple choices via strings. More...
 
struct  util::details::ValueToString< Value, typename >
 
struct  util::details::ValueToString< Value, std::enable_if_t< std::is_enum_v< Value > > >
 
struct  util::details::ValueToString< Value, std::enable_if_t< std::is_convertible_v< Value, std::string >|| std::is_constructible_v< std::string, Value > > >
 
struct  util::details::void_t< decltype(std::to_string(std::declval< Value >()))>
 

Namespaces

 util::details
 
 util
 Namespace for general, non-LArSoft-specific utilities.
 

Functions

template<typename Choices >
std::ostream & util::details::operator<< (std::ostream &out, MultipleChoiceSelectionOption_t< Choices > const &option)
 Prints an option into a stream. More...
 
template<typename B1 , typename E1 , typename B2 , typename E2 , typename Comp >
bool my_lexicographical_compare (B1 b1, E1 e1, B2 b2, E2 e2, Comp less)
 
Option comparison operators

— BEGIN – Comparison operators -------------------------------------—

template<typename Choices >
bool util::details::operator== (MultipleChoiceSelectionOption_t< Choices > const &option, Choices const value)
 Returns whether option has the specified value. More...
 
template<typename Choices >
bool util::details::operator== (Choices const value, MultipleChoiceSelectionOption_t< Choices > const &option)
 Returns whether option has the specified value. More...
 
template<typename Choices >
bool util::details::operator!= (MultipleChoiceSelectionOption_t< Choices > const &option, Choices const value)
 Returns whether option does not have the specified value. More...
 
template<typename Choices >
bool util::details::operator!= (Choices const value, MultipleChoiceSelectionOption_t< Choices > const &option)
 Returns whether option does not have the specified value. More...
 
template<typename Choices >
bool util::details::operator== (MultipleChoiceSelectionOption_t< Choices > const &option, std::string const &label)
 Returns whether option has the specified name or alias. More...
 
template<typename Choices >
bool util::details::operator== (std::string const &label, MultipleChoiceSelectionOption_t< Choices > const &option)
 Returns whether option has the specified name or alias. More...
 
template<typename Choices >
bool util::details::operator!= (MultipleChoiceSelectionOption_t< Choices > const &option, std::string const &label)
 Returns whether option does not have the specified name or alias. More...
 
template<typename Choices >
bool util::details::operator!= (std::string const &label, MultipleChoiceSelectionOption_t< Choices > const &option)
 Returns whether option does not have the specified name or alias. More...
 

Variables

template<typename... Strings>
constexpr auto util::details::AllConvertibleToStrings_v
 

Detailed Description

Helper to select an string option among a set of allowed choices.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
December 13, 2019

Definition in file MultipleChoiceSelection.h.

Function Documentation

template<typename B1 , typename E1 , typename B2 , typename E2 , typename Comp >
bool my_lexicographical_compare ( B1  b1,
E1  e1,
B2  b2,
E2  e2,
Comp  less 
)

Definition at line 476 of file MultipleChoiceSelection.h.

References util::details::CaseInsensitiveComparer::less().

477 {
478 
479  while (b1 != e1) {
480  if (b2 == e2) return false; // shorter is less
481 
482  if (less(*b1, *b2)) return true;
483  if (less(*b2, *b1)) return false;
484  // equal so far...
485  ++b1;
486  ++b2;
487  } // while
488  return true; // 1 is shorter
489 } // my_lexicographical_compare()