Strings.h
/********************************************************************************
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef FAIR_MQ_TOOLS_STRINGS_H
#define FAIR_MQ_TOOLS_STRINGS_H
#include <initializer_list>
#include <sstream>
#include <string>
#include <vector>
namespace fair
{
namespace mq
{
namespace tools
{
template<typename ... T>
auto ToString(T&&... t) -> std::string
{
std::stringstream ss;
(void)std::initializer_list<int>{(ss << t, 0)...};
return ss.str();
}
inline auto ToStrVector(const int argc, char* const argv[], const bool dropProgramName = true) -> std::vector<std::string>
{
auto res = std::vector<std::string>{};
if (dropProgramName)
{
res.assign(argv + 1, argv + argc);
} else
{
res.assign(argv, argv + argc);
}
return res;
}
} /* namespace tools */
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_TOOLS_STRINGS_H */
fair
Definition: DeviceRunner.h:23