SyDEVS  v0.6.5
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
string_builder.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYDEVS_STRING_BUILDER_H_
3 #define SYDEVS_STRING_BUILDER_H_
4 
6 #include <sstream>
7 
8 namespace sydevs {
9 
10 
28 {
29 public:
34 
35  string_builder(const string_builder&) = delete;
36  string_builder& operator=(const string_builder&) = delete;
37  string_builder(string_builder&&) = delete;
39  ~string_builder() = default;
40 
44  std::string str() const;
45 
59  template<class T>
60  string_builder& operator<<(T const& value);
61 
62 private:
63  std::stringstream stream_;
64 };
65 
66 
68  : stream_()
69 {
70 }
71 
72 
73 inline std::string string_builder::str() const
74 {
75  return stream_.str();
76 }
77 
78 
79 template<class T>
81 {
82  stream_ << value;
83  return *this;
84 }
85 
86 
87 } // namespace
88 
89 #endif
std::string str() const
Obtains the data stored in the string_builder object as a std::string.
Definition: string_builder.h:73
A class for converting stream objects to string values.
Definition: string_builder.h:27
string_builder()
Constructs a string_builder object.
Definition: string_builder.h:67
string_builder & operator<<(T const &value)
Inserts data into the stream.
Definition: string_builder.h:80
string_builder & operator=(const string_builder &)=delete
No copy assignment.
~string_builder()=default
Destructor.