A helper class for combining named vectors of strings into vectors of unique strings.
More...
#include <NamedVectorCombinator.h>
|
| NamedVectorCombinator ()=default |
| Constructor. More...
|
|
void | add (const std::string &name, const std::string &input) |
| Adds a vector of strings to the mapped vectors with a specific name. More...
|
|
void | add (const std::string &name, const std::vector< std::string > &strings) |
| Adds a vector of strings to the mapped vectors with a specific name. More...
|
|
void | from_file (const std::string &name, const std::string &filename) |
| Reads a file containing strings separated by newlines into a named vector. More...
|
|
void | merge (const std::vector< std::string > &named_vectors, std::vector< std::string > &result, bool throw_on_missing=true, bool make_unique=true, bool clear_first=true) |
| Merges named vectors into a result vector. More...
|
|
|
std::map< std::string, std::vector< std::string > > | named_vectors_ |
| the mapping of named lists to their contents More...
|
|
A helper class for combining named vectors of strings into vectors of unique strings.
Definition at line 24 of file NamedVectorCombinator.h.
◆ NamedVectorCombinator()
madara::utility::NamedVectorCombinator::NamedVectorCombinator |
( |
| ) |
|
|
default |
◆ add() [1/2]
void madara::utility::NamedVectorCombinator::add |
( |
const std::string & |
name, |
|
|
const std::string & |
input |
|
) |
| |
|
inline |
Adds a vector of strings to the mapped vectors with a specific name.
- Parameters
-
name | the name of the mapped vector to import into |
input | a string containing newline-delimited strings to import |
Definition at line 48 of file NamedVectorCombinator.h.
◆ add() [2/2]
void madara::utility::NamedVectorCombinator::add |
( |
const std::string & |
name, |
|
|
const std::vector< std::string > & |
strings |
|
) |
| |
|
inline |
Adds a vector of strings to the mapped vectors with a specific name.
- Parameters
-
name | the name of the mapped vector to import into |
strings | a vector of strings to associate with the name |
Definition at line 59 of file NamedVectorCombinator.h.
◆ from_file()
void madara::utility::NamedVectorCombinator::from_file |
( |
const std::string & |
name, |
|
|
const std::string & |
filename |
|
) |
| |
|
inline |
Reads a file containing strings separated by newlines into a named vector.
- Parameters
-
name | the name of the mapped vector to import into |
filename | the name of the file to read in the newline-delimited strings |
Definition at line 38 of file NamedVectorCombinator.h.
◆ merge()
void madara::utility::NamedVectorCombinator::merge |
( |
const std::vector< std::string > & |
named_vectors, |
|
|
std::vector< std::string > & |
result, |
|
|
bool |
throw_on_missing = true , |
|
|
bool |
make_unique = true , |
|
|
bool |
clear_first = true |
|
) |
| |
|
inline |
Merges named vectors into a result vector.
This is a useful function for building prefix lists for CheckpointSettings and other classes that have vectors of strings.
- Parameters
-
named_vectors | a vector of named entities that you want to merge. Each string should exist in the known map by first calling from_file to create the lists |
result | the result of the merge |
throw_on_missing | if true, throw an exception if the named entity does not exist |
make_unique | if true, make sure the resulting merge is unique |
clear_first | if true, clear the result before inserting |
- Exceptions
-
Definition at line 80 of file NamedVectorCombinator.h.
◆ named_vectors_
std::map<std::string, std::vector<std::string> > madara::utility::NamedVectorCombinator::named_vectors_ |
|
private |
The documentation for this class was generated from the following file: