Manages a set of names. More...
#include <NameSelector.h>
Classes | |
struct | NameResponse_t |
A data structure containing how to react to a name. More... | |
Public Types | |
enum | Response_t { rsRejected, rsAccepted, rsThrow, rsDefault = rsAccepted, rsRejected, rsAccepted, rsThrow, rsDefault = rsAccepted } |
Possible responses. More... | |
enum | Response_t { rsRejected, rsAccepted, rsThrow, rsDefault = rsAccepted, rsRejected, rsAccepted, rsThrow, rsDefault = rsAccepted } |
Possible responses. More... | |
using | Name_t = std::string |
type representing a name More... | |
using | Names_t = std::set< Name_t > |
list of names More... | |
using | NameList = std::initializer_list< Name_t > |
using | Name_t = std::string |
type representing a name More... | |
using | Names_t = std::set< Name_t > |
list of names More... | |
using | NameList = std::initializer_list< Name_t > |
Public Member Functions | |
NameSelector (Response_t default_answer=rsDefault) | |
Constructor: an empty selector with a default answer for unknown names. More... | |
template<typename LIST > | |
NameSelector (LIST const &items, Response_t default_answer=rsDefault) | |
Constructor: Parse()s the specified items. More... | |
void | SetDefaultResponse (Response_t default_answer) |
Sets the default answer for names that are not registered. More... | |
template<typename LIST > | |
void | Parse (LIST const &items) |
Parses the names in the list and adds them to the selector. More... | |
void | ParseName (Name_t name) |
Parses a name and adds it to the selector. More... | |
template<typename... NAMES> | |
void | ParseNames (NAMES...names) |
Parses a list of names and adds them to the selector. More... | |
void | Clear () |
Erases all the names in the selector (default answer is unchanged) More... | |
template<typename LIST > | |
void | Define (std::string set_name, LIST const &items) |
Defines a set. More... | |
template<typename... NAMES> | |
void | AddToDefinition (std::string set_name, NAMES...names) |
Parses a list of names and add them to the specified definition. More... | |
Response_t | Query (Name_t name) const |
Returns the response for the specified name (does not throw) More... | |
bool | Accepted (Name_t name) const |
Returns whether the name is accepted as good. More... | |
bool | Rejected (Name_t name) const |
Returns whether the name is rejected as bad. More... | |
Response_t | DefaultResponse () const |
Returns the default answer for names that are not registered. More... | |
bool | operator() (Name_t name) const |
Returns whether the name is accepted as good (alias for accept()) More... | |
void | PrintConfiguration (std::ostream &) const |
Prints the configuration into a stream. More... | |
Names_t | AcceptedNames () const |
Returns a list of names that were accepted. More... | |
Names_t | RejectedNames () const |
Returns a list of names that were rejected. More... | |
void | ClearQueryRegistry () |
Reests the query registry. More... | |
NameSelector (Response_t default_answer=rsDefault) | |
Constructor: an empty selector with a default answer for unknown names. More... | |
template<typename LIST > | |
NameSelector (LIST const &items, Response_t default_answer=rsDefault) | |
Constructor: Parse()s the specified items. More... | |
void | SetDefaultResponse (Response_t default_answer) |
Sets the default answer for names that are not registered. More... | |
template<typename LIST > | |
void | Parse (LIST const &items) |
Parses the names in the list and adds them to the selector. More... | |
void | ParseName (Name_t name) |
Parses a name and adds it to the selector. More... | |
template<typename... NAMES> | |
void | ParseNames (NAMES...names) |
Parses a list of names and adds them to the selector. More... | |
void | Clear () |
Erases all the names in the selector (default answer is unchanged) More... | |
template<typename LIST > | |
void | Define (std::string set_name, LIST const &items) |
Defines a set. More... | |
template<typename... NAMES> | |
void | AddToDefinition (std::string set_name, NAMES...names) |
Parses a list of names and add them to the specified definition. More... | |
Response_t | Query (Name_t name) const |
Returns the response for the specified name (does not throw) More... | |
bool | Accepted (Name_t name) const |
Returns whether the name is accepted as good. More... | |
bool | Rejected (Name_t name) const |
Returns whether the name is rejected as bad. More... | |
Response_t | DefaultResponse () const |
Returns the default answer for names that are not registered. More... | |
bool | operator() (Name_t name) const |
Returns whether the name is accepted as good (alias for accept()) More... | |
void | PrintConfiguration (std::ostream &) const |
Prints the configuration into a stream. More... | |
Names_t | AcceptedNames () const |
Returns a list of names that were accepted. More... | |
Names_t | RejectedNames () const |
Returns a list of names that were rejected. More... | |
void | ClearQueryRegistry () |
Reests the query registry. More... | |
template<> | |
void | AddFirstName (KnownNames_t &name_set, Name_t name) |
bool | CheckQueryRegistry () const |
Checks that no known element with valid response was left unqueried. More... | |
bool | CheckQueryRegistry (std::ostream &out) const |
bool | CheckQueryRegistry () const |
Checks that no known element with valid response was left unqueried. More... | |
bool | CheckQueryRegistry (std::ostream &out) const |
Static Public Attributes | |
static Name_t const | DefaultName = "*" |
name representing the default More... | |
static Name_t const | ClearAllName = "!" |
name instructing to delete all names More... | |
Protected Types | |
using | KnownNames_t = std::map< Name_t, NameResponse_t > |
Information about known names. More... | |
using | Definitions_t = std::map< Name_t, KnownNames_t > |
Type of list of definitions. More... | |
using | QueryRegistry_t = std::map< Name_t, size_t > |
Type of query counters. More... | |
using | KnownNames_t = std::map< Name_t, NameResponse_t > |
Information about known names. More... | |
using | Definitions_t = std::map< Name_t, KnownNames_t > |
Type of list of definitions. More... | |
using | QueryRegistry_t = std::map< Name_t, size_t > |
Type of query counters. More... | |
Protected Member Functions | |
Response_t | LookupResponse (Name_t name) const |
Returns the response for the specified name (does not register query) More... | |
template<typename LIST > | |
void | BuildNameSet (KnownNames_t &name_set, LIST const &items) const |
Fills name_set with a list of items. More... | |
template<typename... NAMES> | |
void | AddFirstName (KnownNames_t &name_set, Name_t name, NAMES...other_names) |
Parses the first of the provided names, and recurs. More... | |
void | InsertItem (KnownNames_t &name_set, Name_t item, Response_t response) const |
Adds an item to the name set, working in specified mode. More... | |
void | InsertItem (KnownNames_t &name_set, KnownNames_t::value_type item, Response_t response) const |
Adds an item with response to the name set, working in specified mode. More... | |
void | ProcessItem (KnownNames_t &name_set, Name_t item) const |
Fills name_set with an item. More... | |
Definitions_t::const_iterator | FindDefinition (Name_t &item) const |
Strips set specifier and returns iterator to the definition, or end() More... | |
void | ClearNameSet (KnownNames_t &name_set) const |
Erases all the names in the selector (default answer is unchanged) More... | |
Names_t | QueriedWithStatus (Response_t answer) const |
Returns the list of queried names whose response is answer. More... | |
bool | DoCheckQueryRegistry (std::ostream *out=nullptr) const |
Response_t | LookupResponse (Name_t name) const |
Returns the response for the specified name (does not register query) More... | |
template<typename LIST > | |
void | BuildNameSet (KnownNames_t &name_set, LIST const &items) const |
Fills name_set with a list of items. More... | |
template<typename... NAMES> | |
void | AddFirstName (KnownNames_t &name_set, Name_t name, NAMES...other_names) |
Parses the first of the provided names, and recurs. More... | |
void | InsertItem (KnownNames_t &name_set, Name_t item, Response_t response) const |
Adds an item to the name set, working in specified mode. More... | |
void | InsertItem (KnownNames_t &name_set, KnownNames_t::value_type item, Response_t response) const |
Adds an item with response to the name set, working in specified mode. More... | |
void | ProcessItem (KnownNames_t &name_set, Name_t item) const |
Fills name_set with an item. More... | |
Definitions_t::const_iterator | FindDefinition (Name_t &item) const |
Strips set specifier and returns iterator to the definition, or end() More... | |
void | ClearNameSet (KnownNames_t &name_set) const |
Erases all the names in the selector (default answer is unchanged) More... | |
Names_t | QueriedWithStatus (Response_t answer) const |
Returns the list of queried names whose response is answer. More... | |
bool | DoCheckQueryRegistry (std::ostream *out=nullptr) const |
Static Protected Member Functions | |
static Response_t | ParseMode (Name_t &item, Response_t default_answer=rsAccepted) |
Strips the mode specifier from item and returns the insertion mode. More... | |
static Response_t | ParseMode (Name_t &item, Response_t default_answer=rsAccepted) |
Strips the mode specifier from item and returns the insertion mode. More... | |
Protected Attributes | |
KnownNames_t | known_names |
list of known names, with category More... | |
Definitions_t | definitions |
a set of definitions More... | |
QueryRegistry_t | query_registry |
record of all the queries More... | |
Manages a set of names.
This class contains a set of names to be "accepted" and a set of names to be "rejected". Queries on unknown names will generate a default answer that can be acceptance, rejection or an exception.
The class is initialized by a list of strings following the convention detailed in ProcessItem(). The default answer is set on construction, but it can be overridden to a "reject by default" using a specific identifier.
Definition at line 36 of file NameSelector.h.
|
protected |
Type of list of definitions.
Definition at line 180 of file NameSelector.h.
|
protected |
Type of list of definitions.
Definition at line 181 of file NameSelector.h.
|
protected |
Information about known names.
Definition at line 177 of file NameSelector.h.
|
protected |
Information about known names.
Definition at line 178 of file NameSelector.h.
using testing::NameSelector::Name_t = std::string |
type representing a name
Definition at line 39 of file NameSelector.h.
using testing::NameSelector::Name_t = std::string |
type representing a name
Definition at line 40 of file NameSelector.h.
using testing::NameSelector::NameList = std::initializer_list<Name_t> |
Definition at line 51 of file NameSelector.h.
using testing::NameSelector::NameList = std::initializer_list<Name_t> |
Definition at line 52 of file NameSelector.h.
using testing::NameSelector::Names_t = std::set<Name_t> |
list of names
Definition at line 40 of file NameSelector.h.
using testing::NameSelector::Names_t = std::set<Name_t> |
list of names
Definition at line 41 of file NameSelector.h.
|
protected |
Type of query counters.
Definition at line 183 of file NameSelector.h.
|
protected |
Type of query counters.
Definition at line 184 of file NameSelector.h.
enum testing::NameSelector::Response_t |
Possible responses.
Enumerator | |
---|---|
rsRejected |
rejected |
rsAccepted |
accepted |
rsThrow | |
rsDefault | |
rsRejected |
rejected |
rsAccepted |
accepted |
rsThrow | |
rsDefault |
Definition at line 43 of file NameSelector.h.
enum testing::NameSelector::Response_t |
Possible responses.
Enumerator | |
---|---|
rsRejected |
rejected |
rsAccepted |
accepted |
rsThrow | |
rsDefault | |
rsRejected |
rejected |
rsAccepted |
accepted |
rsThrow | |
rsDefault |
Definition at line 44 of file NameSelector.h.
|
inline |
Constructor: an empty selector with a default answer for unknown names.
Definition at line 55 of file NameSelector.h.
|
inline |
Constructor: Parse()s the specified items.
Definition at line 60 of file NameSelector.h.
|
inline |
Constructor: an empty selector with a default answer for unknown names.
Definition at line 56 of file NameSelector.h.
|
inline |
Constructor: Parse()s the specified items.
Definition at line 61 of file NameSelector.h.
Returns whether the name is accepted as good.
Definition at line 38 of file NameSelector.cxx.
Returns whether the name is accepted as good.
|
inline |
Returns a list of names that were accepted.
Definition at line 150 of file NameSelector.h.
|
inline |
Returns a list of names that were accepted.
Definition at line 151 of file NameSelector.h.
void testing::NameSelector::AddFirstName | ( | KnownNames_t & | name_set, |
Name_t | name | ||
) |
Definition at line 108 of file NameSelector.cxx.
|
protected |
Parses the first of the provided names, and recurs.
Definition at line 306 of file NameSelector.h.
|
protected |
Parses the first of the provided names, and recurs.
|
inline |
Parses a list of names and add them to the specified definition.
NAMES | Name_t-compatible types |
set_name | name of the set to be defined |
names | the definitions to be used |
Specified items are processed with ProcessItem(); the result is added to the set with the specified name. If a set with that name does not exist, it's created empty.
Definition at line 127 of file NameSelector.h.
|
inline |
Parses a list of names and add them to the specified definition.
NAMES | Name_t-compatible types |
set_name | name of the set to be defined |
names | the definitions to be used |
Specified items are processed with ProcessItem(); the result is added to the set with the specified name. If a set with that name does not exist, it's created empty.
Definition at line 128 of file NameSelector.h.
|
protected |
Fills name_set with a list of items.
LIST | type of container of name directives |
name_set | set to be modified |
items | name directives |
A name set is modified according to the instructions in each of the items. The items are parsed sequentially, and their order matters for the final result. Each item is processed through ProcessItem().
Definition at line 291 of file NameSelector.h.
|
protected |
Fills name_set with a list of items.
LIST | type of container of name directives |
name_set | set to be modified |
items | name directives |
A name set is modified according to the instructions in each of the items. The items are parsed sequentially, and their order matters for the final result. Each item is processed through ProcessItem().
|
inline |
Checks that no known element with valid response was left unqueried.
Definition at line 160 of file NameSelector.h.
|
inline |
Definition at line 161 of file NameSelector.h.
|
inline |
Checks that no known element with valid response was left unqueried.
Definition at line 161 of file NameSelector.h.
|
inline |
Definition at line 162 of file NameSelector.h.
|
inline |
Erases all the names in the selector (default answer is unchanged)
Definition at line 100 of file NameSelector.h.
|
inline |
Erases all the names in the selector (default answer is unchanged)
Definition at line 101 of file NameSelector.h.
|
protected |
Erases all the names in the selector (default answer is unchanged)
Definition at line 188 of file NameSelector.cxx.
|
protected |
Erases all the names in the selector (default answer is unchanged)
|
inline |
Reests the query registry.
Definition at line 156 of file NameSelector.h.
|
inline |
Reests the query registry.
Definition at line 157 of file NameSelector.h.
|
inline |
Returns the default answer for names that are not registered.
Definition at line 140 of file NameSelector.h.
|
inline |
Returns the default answer for names that are not registered.
Definition at line 141 of file NameSelector.h.
void testing::NameSelector::Define | ( | std::string | set_name, |
LIST const & | items | ||
) |
Defines a set.
LIST | type of list of strings |
set_name | name of the set to be defined |
items | the definitions to be used |
Specified items are processed with BuildSet(); the result is stored as a set with the specified name. If a set with that name already exists, it's replaced and the old one is lost.
Definition at line 281 of file NameSelector.h.
void testing::NameSelector::Define | ( | std::string | set_name, |
LIST const & | items | ||
) |
Defines a set.
LIST | type of list of strings |
set_name | name of the set to be defined |
items | the definitions to be used |
Specified items are processed with BuildSet(); the result is stored as a set with the specified name. If a set with that name already exists, it's replaced and the old one is lost.
|
protected |
Definition at line 213 of file NameSelector.cxx.
|
protected |
|
protected |
Strips set specifier and returns iterator to the definition, or end()
Definition at line 169 of file NameSelector.cxx.
|
protected |
Strips set specifier and returns iterator to the definition, or end()
|
protected |
Adds an item to the name set, working in specified mode.
Definition at line 115 of file NameSelector.cxx.
|
protected |
Adds an item to the name set, working in specified mode.
|
protected |
Adds an item with response to the name set, working in specified mode.
Definition at line 122 of file NameSelector.cxx.
|
protected |
Adds an item with response to the name set, working in specified mode.
|
protected |
Returns the response for the specified name (does not register query)
Definition at line 99 of file NameSelector.cxx.
|
protected |
Returns the response for the specified name (does not register query)
Returns whether the name is accepted as good (alias for accept())
Definition at line 144 of file NameSelector.h.
Returns whether the name is accepted as good (alias for accept())
Definition at line 145 of file NameSelector.h.
|
inline |
Parses the names in the list and adds them to the selector.
LIST | type of list of strings |
items | the definitions to be used |
Specified items are processed with ProcessItem() and the current set is modified.
Definition at line 77 of file NameSelector.h.
|
inline |
Parses the names in the list and adds them to the selector.
LIST | type of list of strings |
items | the definitions to be used |
Specified items are processed with ProcessItem() and the current set is modified.
Definition at line 78 of file NameSelector.h.
|
staticprotected |
Strips the mode specifier from item and returns the insertion mode.
Definition at line 232 of file NameSelector.cxx.
|
staticprotected |
Strips the mode specifier from item and returns the insertion mode.
void testing::NameSelector::ParseName | ( | Name_t | name | ) |
Parses a name and adds it to the selector.
name | name specification to be parsed |
The name is processed with ProcessItem() and the current set is modified.
Definition at line 25 of file NameSelector.cxx.
void testing::NameSelector::ParseName | ( | Name_t | name | ) |
Parses a name and adds it to the selector.
name | name specification to be parsed |
The name is processed with ProcessItem() and the current set is modified.
|
inline |
Parses a list of names and adds them to the selector.
NAMES | Name_t-compatible types |
names | the definitions to be used |
Specified items are processed with ProcessItem() and modify the current set.
Definition at line 97 of file NameSelector.h.
|
inline |
Parses a list of names and adds them to the selector.
NAMES | Name_t-compatible types |
names | the definitions to be used |
Specified items are processed with ProcessItem() and modify the current set.
Definition at line 98 of file NameSelector.h.
void testing::NameSelector::PrintConfiguration | ( | std::ostream & | out | ) | const |
Prints the configuration into a stream.
Definition at line 49 of file NameSelector.cxx.
void testing::NameSelector::PrintConfiguration | ( | std::ostream & | ) | const |
Prints the configuration into a stream.
|
protected |
Fills name_set with an item.
name_set | set to be modified |
item | name directive |
A name set is modified according to the instruction in the items. An identifier may represent either a single literal item or a set name; it can appear in two forms:
The directives in items are:
Definition at line 152 of file NameSelector.cxx.
|
protected |
Fills name_set with an item.
name_set | set to be modified |
item | name directive |
A name set is modified according to the instruction in the items. An identifier may represent either a single literal item or a set name; it can appear in two forms:
The directives in items are:
|
protected |
Returns the list of queried names whose response is answer.
Definition at line 199 of file NameSelector.cxx.
|
protected |
Returns the list of queried names whose response is answer.
NameSelector::Response_t testing::NameSelector::Query | ( | Name_t | name | ) | const |
Returns the response for the specified name (does not throw)
Definition at line 31 of file NameSelector.cxx.
Response_t testing::NameSelector::Query | ( | Name_t | name | ) | const |
Returns the response for the specified name (does not throw)
Returns whether the name is rejected as bad.
Definition at line 137 of file NameSelector.h.
Returns whether the name is rejected as bad.
Definition at line 138 of file NameSelector.h.
|
inline |
Returns a list of names that were rejected.
Definition at line 153 of file NameSelector.h.
|
inline |
Returns a list of names that were rejected.
Definition at line 154 of file NameSelector.h.
|
inline |
Sets the default answer for names that are not registered.
Definition at line 65 of file NameSelector.h.
|
inline |
Sets the default answer for names that are not registered.
Definition at line 66 of file NameSelector.h.
|
static |
name instructing to delete all names
Definition at line 167 of file NameSelector.h.
|
static |
name representing the default
Definition at line 166 of file NameSelector.h.
|
protected |
a set of definitions
Definition at line 187 of file NameSelector.h.
|
protected |
list of known names, with category
Definition at line 185 of file NameSelector.h.
|
mutableprotected |
record of all the queries
Definition at line 189 of file NameSelector.h.