summaryrefslogtreecommitdiffstats
path: root/Master/Modellbildung_und_Simulation/Aufgabenblatt1/SineGenerator/src/Util.h
blob: 6c98299b0121112228e8b30b106eeddbab7a34b0 (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
/*
 * Util.h
 *
 *  Created on: 31.03.2011
 *      Author: sven
 */

#ifndef UTIL_H_
#define UTIL_H_

#ifndef _GLIBCXX_SSTREAM
	#include <sstream>
#endif
#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(double 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 unsigned short ToUShort(Glib::ustring& val)
	{
		std::istringstream buffer(val.raw());
		unsigned short 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_ */