Commit 0fbd4f80 authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

vector cli

parent f073b73a
......@@ -95,6 +95,9 @@
*/
namespace paramGenerate
{
/// Operator >>
struct nbParticles : inria::tcli::required_tag
{
inria::tcli::str_vec flags = {"--n", "--N", "--number_particles"};
......@@ -233,34 +236,10 @@ namespace paramGenerate
};
struct centre
{
std::vector<std::string> flags = {"--centre", "-c"}; /*!< The flags */
inria::tcli::str_vec flags = {"--centre", "-c"}; /*!< The flags */
std::string description = "the center of the final distribution"; /*!< The description */
std::string input_hint = "value,value,value"; /*!< The description */
/**\brief Type definition
*
* We define directly the type into the parameter and it inherits of
* std::vector for simplicity.
*/
struct type : std::vector<double>
{
/// Operator >>
friend std::istream& operator>>(std::istream& is, type& t)
{
bool first = true;
double val;
char delimiter;
while(!is.eof())
{
// The first object is not delimited
first ? (first = false) : ((is >> delimiter), true);
// Get the value
is >> val;
t.emplace_back(val);
}
return is;
}
};
using type = std::vector<double>;
};
} // namespace paramGenerate
......
......@@ -21,7 +21,23 @@
namespace inria {
namespace tcli {
namespace detail {
// this is only require to handle vector of parameters.
template<typename ValueType>
std::istream& operator>>(std::istream& is, std::vector<ValueType>& t)
{
bool first = true;
double val;
char delimiter;
while(!is.eof())
{
// The first object is not delimited
first ? (first = false) : ((is >> delimiter), true);
// Get the value
is >> val;
t.emplace_back(val);
}
return is;
}
/**
* \brief Get container size
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment