44 std::ios_base::fmtflags f;
47 f = stream.setf(std::ios::dec, std::ios::basefield);
50 f = stream.setf(std::ios::hex, std::ios::basefield);
53 f = stream.setf(std::ios::oct, std::ios::basefield);
60 stream.setf(std::ios::showbase | std::ios::boolalpha);
81 const std::string& string_quote=
"") {
82 std::stringstream out;
84 typename std::vector<T>::const_iterator itr = v.begin();
86 std::ios_base::fmtflags old =
setIOSFlags(out, base);
89 for(; itr != v.end(); ++itr){
110 template <
class T,
class U>
112 const std::string& string_quote=
"") {
113 std::stringstream out;
114 std::ios_base::fmtflags old =
setIOSFlags(out, base);
130 template <
class... Ts>
132 const std::string& string_quote=
"") {
133 std::stringstream out;
134 std::ios_base::fmtflags old =
setIOSFlags(out, base);
135 stringize_tuple(out, t, base, string_quote, std::index_sequence_for<Ts...>{});
150 const std::string& string_quote=
"") {
152 std::stringstream out;
153 std::ios_base::fmtflags old =
setIOSFlags(out, base);
161 inline std::string stringize_value<std::string>(
const std::string& o,
DisplayBase base,
162 const std::string& string_quote) {
164 std::stringstream out;
165 out << string_quote << o << string_quote;
170 inline std::vector<std::string>& operator<< (std::vector<std::string>& v,
const char * e){
176 template <
class T,
class U>
177 inline std::vector<T>& operator<< (std::vector<T>& v, U& e){
178 const T& val = (
const T&)e;
184 template <
class T,
class U>
185 inline std::vector<T>& operator<< (std::vector<T>& v,
const U& e){
186 const T& val = (
const T&)e;
192 template <
class T, std::size_t... Is>
193 inline void stringize_tuple(std::stringstream& ss,
194 const T& t, DisplayBase base,
195 const std::string& string_quote,
196 std::index_sequence<Is...>) {
197 ((ss << (Is == 0 ?
"" :
":") << stringize_value(std::get<Is>(t), base, string_quote)), ...);
206 template<
class Ch,
class T,
class Tr>
207 inline std::basic_ostream<Ch,Tr>&
208 operator<< (std::basic_ostream<Ch,Tr>& out, std::vector<T>
const & v){
214 template<
class Ch,
class T,
class U,
class Tr>
215 inline std::basic_ostream<Ch,Tr>&
216 operator<< (std::basic_ostream<Ch,Tr>& out, std::pair<T,U>
const & p){
222 template<
class Ch,
class... Ts,
class Tr>
223 inline std::basic_ostream<Ch,Tr>&
224 operator<< (std::basic_ostream<Ch,Tr>& out, std::tuple<Ts...>
const & t){
231inline std::vector<std::string>&
operator<< (std::vector<std::string>& v,
const char * e){
237template <
class T,
class U>
238inline std::vector<T>&
operator<< (std::vector<T>& v, U& e){
239 const T& val = (
const T&)e;
245template <
class T,
class U>
246inline std::vector<T>&
operator<< (std::vector<T>& v,
const U& e){
247 const T& val = (
const T&)e;
void stringize_tuple(std::stringstream &ss, const T &t, DisplayBase base, const std::string &string_quote, std::index_sequence< Is... >)
Helper for printing STL tuple.
std::vector< std::string > & operator<<(std::vector< std::string > &v, const char *e)
Specialization for populating STL vector of string with char*s.
std::string stringize_value(const std::vector< T > &v, DisplayBase base=BASE_DEC, const std::string &string_quote="")
Converting a vector of intrinsic types (and std::string) to a string.
DisplayBase
Numeric display options used by Parameter printing routines.
@ BASE_HEX
Decimal display.
std::ios_base::fmtflags setIOSFlags(std::ios_base &stream, DisplayBase base)
Configure an ios stream to use given numeric base from sparta::DisplayBase.
Exception class for all of Sparta.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Macros for handling exponential backoff.