summaryrefslogtreecommitdiffstats
path: root/Master/Modellbildung_und_Simulation/Aufgabenblatt1/DFTApp/src/Util.h
blob: c1f7130bb7786149bfc199b6d2541ce53d49d925 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Util.h
 *
 *  Created on: 31.03.2011
 *      Author: sven
 */

#ifndef UTIL_H_
#define UTIL_H_

#ifndef _GLIBCXX_SSTREAM
	#include <sstream>
#endif

#include <iomanip>

#ifndef _GLIBMM_USTRING_H
	#include <glibmm/ustring.h>
#endif

class Util
{
public:
	static Glib::ustring ToUString(unsigned short val)
	{
		std::ostringstream ssIn;
		ssIn << val;
		Glib::ustring res = ssIn.str();
		return res;
	}

	static Glib::ustring ToUString(short val)
	{
		std::ostringstream ssIn;
		ssIn << val;
		Glib::ustring res = ssIn.str();
		return res;
	}

	static Glib::ustring ToUString(unsigned val)
	{
		std::ostringstream ssIn;
		ssIn << val;
		Glib::ustring res = ssIn.str();
		return res;
	}

	static Glib::ustring ToUString(int val)
	{
		std::ostringstream ssIn;
		ssIn << val;
		Glib::ustring res = ssIn.str();
		return res;
	}

	static Glib::ustring ToUString(double val)
	{
		std::ostringstream ssIn;
		ssIn << std::setprecision(12) << std::fixed << val;
		Glib::ustring res = ssIn.str();
		return res;
	}

	static unsigned short ToUShort(Glib::ustring& val)
	{
		std::istringstream buffer(val.raw());
		unsigned short res;
		buffer >> res;
		return res;
	}

	static unsigned ToUint(Glib::ustring& val)
	{
		std::istringstream buffer(val.raw());
		unsigned res;
		buffer >> res;
		return res;
	}

	static short ToShort(Glib::ustring& val)
	{
		std::istringstream buffer(val.raw());
		short res;
		buffer >> res;
		return res;
	}
};

#endif /* UTIL_H_ */