-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout.hpp
52 lines (42 loc) · 856 Bytes
/
about.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef ABOUT_HPP
#define ABOUT_HPP
#define REVISION_FILE "REVISION"
//no namespace for now
//namespace code_commons {
class About {
public:
About () : s("C++ Code Commons") {}
std::string str() { return " .";}
private:
std::string s;
std::string get_revision();
friend std::ostream& operator<<(std::ostream &os, const About &about);
};
std::string getRevision()
{
std::ostringstream out;
std::ifstream in(REVISION_FILE, std::ios::in | std::ios::binary);
if (in)
{
out << in.rdbuf();
in.close();
}
else return "UNKREV";
return "rev" + out.str();
}
std::ostream& operator<<(std::ostream &os, const About &about)
{
return os << "[" << about.s << "] v0.1 " + getRevision();
}
/*
namespace std {
std::string to_string(About &about)
{
std::ostringstream o;
o << about;
return o.str();
}
}
*/
//}
#endif