Classes | Namespaces | Functions | Variables
MultipleChoiceSelection.h File Reference

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

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

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)
 
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)
 
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)
 
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)
 

Variables

template<typename... Strings>
constexpr auto util::details::AllConvertibleToStrings_v = std::conjunction_v<std::is_convertible<Strings, std::string>...>
 

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 531 of file MultipleChoiceSelection.h.

531  {
532 
533  while (b1 != e1) {
534  if (b2 == e2) return false; // shorter is less
535 
536  if (less(*b1, *b2)) return true;
537  if (less(*b2, *b1)) return false;
538  // equal so far...
539  ++b1;
540  ++b2;
541  } // while
542  return true; // 1 is shorter
543 } // my_lexicographical_compare()