Phoxonics
1.0
Object Oriented FDTD Software
Home
Installation
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
src
common
include
utils
Formatter.hpp
Go to the documentation of this file.
1
/*
2
* Formatter.hpp
3
*
4
* Created on: Oct 25, 2014
5
* Author: nano
6
*/
7
8
#ifndef FORMATTER_HPP_
9
#define FORMATTER_HPP_
10
11
#include <string>
// std::string
12
#include <iostream>
// std::cout
13
#include <sstream>
// std::stringstream, std::stringbuf
14
15
namespace
phoxonics
{
16
namespace
common {
17
18
class
Formatter
{
19
public
:
20
Formatter
() {
21
}
22
;
23
~Formatter
() {
24
}
25
;
26
27
template
<
typename
T>
28
Formatter
&
operator <<
(
const
T & value) {
29
stream_ << value;
30
return
*
this
;
31
}
32
33
std::string
str
()
const
{
34
return
stream_.str();
35
}
36
;
37
38
operator
std::string()
const
{
39
return
stream_.str();
40
}
41
;
42
43
enum
ConvertToString
{
44
to_str
45
};
46
47
std::string
operator >>
(
ConvertToString
) {
48
return
stream_.str();
49
}
50
51
private
:
52
std::stringstream stream_;
53
54
Formatter
(
const
Formatter
&);
55
Formatter
& operator =(
Formatter
&);
56
};
57
58
}
/* namespace common */
59
}
/* namespace phoxonics */
60
61
// usage
62
//throw std::runtime_error(Formatter() << foo << 13 << ", bar" << myData);
63
64
#endif
/* FORMATTER_HPP_ */
phoxonics::common::Formatter::~Formatter
~Formatter()
Definition:
Formatter.hpp:23
phoxonics::common::Formatter::operator<<
Formatter & operator<<(const T &value)
Definition:
Formatter.hpp:28
phoxonics
Definition:
CommonBase.hpp:14
phoxonics::common::Formatter::Formatter
Formatter()
Definition:
Formatter.hpp:20
phoxonics::common::Formatter::operator>>
std::string operator>>(ConvertToString)
Definition:
Formatter.hpp:47
phoxonics::common::Formatter::ConvertToString
ConvertToString
Definition:
Formatter.hpp:43
phoxonics::common::Formatter::to_str
Definition:
Formatter.hpp:44
phoxonics::common::Formatter::str
std::string str() const
Definition:
Formatter.hpp:33
phoxonics::common::Formatter
Definition:
Formatter.hpp:18
Generated on Sat Mar 4 2017 23:33:39 for Phoxonics by
1.8.8