HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_str.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <sstream>
4#include <string>
5
6namespace hart {
7
8/// @brief Helper class for building strings with string stream syntax
9/// @private
10class Str
11{
12public:
13 /// @brief Appends value to a string stream
14 /// @param value Any printable value
15 template<typename ValueType>
16 Str& operator<< (const ValueType& value)
17 {
18 m_stringStream << value;
19 return *this;
20 }
21
22 /// @brief Returns a std::string constructed from a stream
23 std::string toStdString() const
24 {
25 return m_stringStream.str();
26 }
27
28private:
29 std::ostringstream m_stringStream;
30};
31
32/// @brief A helper to construct strings using the "<<" syntax
33/// @details Usage: `HART_STR ("Some text: " << someValue << "...")`
34/// @ingroup Utilities
35#define HART_STR(...) (hart::Str() << __VA_ARGS__).toStdString()
36
37} // namespace hart