Kinetic Visualization
 All Classes Functions Variables Pages
common.hpp
1 #pragma once
2 #include <windows.h>
3 #include <GL/glew.h>
4 
5 /* itoa example */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <iostream>
9 #include <string>
10 #include <io.h>
11 #include <sstream>
12 
13 using std::string;
14 using std::cerr;
15 using std::cout;
16 using std::endl;
17 
18 #include "utility.hpp"
19 
20 #define PI 3.1415926535897f
21 
22 // converts from string to Type
23 template <class Type>
24 inline const Type fromString(const std::string & strString)
25 {
26  Type tValue;
27  std::stringstream(std::string(strString)) >> tValue;
28  return tValue;
29 };
30 
31 // converts from string to Type, returns true if successful
32 template <class Type>
33 inline const bool fromString(Type & tValue, const std::string & strString)
34 {
35  Type tTemp;
36 
37  std::stringstream ss;
38  ss << strString;
39  ss >> std::ws;
40 
41  if (ss >> tTemp)
42  {
43  ss >> std::ws;
44 
45  if (ss.eof())
46  {
47  tValue = tTemp;
48  return true;
49  }
50  }
51 
52  return false;
53 };
54 
55 // converts from Type to string
56 template <class Type>
57 inline const std::string toString(const Type & tValue)
58 {
59  std::stringstream ss;
60  ss << tValue;
61  return ss.str();
62 };