27 |
|
|
28 |
int getToken(string tok); |
int getToken(string tok); |
29 |
double getTokenf(string tok); |
double getTokenf(string tok); |
30 |
|
|
31 |
|
|
32 |
|
/* Understands whitespaces: ' ' and '\t' (tabulator) |
33 |
|
* |
34 |
|
* string foo = "abcd efg"; |
35 |
|
* string bar = separate(foo); |
36 |
|
* -> foo = "efg" |
37 |
|
* -> bar = "abcd" |
38 |
|
* |
39 |
|
* bar = separate(foo); |
40 |
|
* -> foo = "" |
41 |
|
* -> bar = "efg" |
42 |
|
*/ |
43 |
|
string separate(string & str) { |
44 |
|
string::size_type position_space = str.find(' '); |
45 |
|
string::size_type position_tab = str.find('\t'); |
46 |
|
string first_part; |
47 |
|
|
48 |
|
if (position_space != string::npos || |
49 |
|
position_tab != string::npos ) |
50 |
|
{ |
51 |
|
if (position_space < position_tab) { |
52 |
|
first_part = str.substr(0, position_space); |
53 |
|
str = str.substr(position_space + 1, str.length() ); |
54 |
|
} else { |
55 |
|
first_part = str.substr(0, position_tab); |
56 |
|
str = str.substr(position_tab + 1, str.length() ); |
57 |
|
} |
58 |
|
} else { |
59 |
|
first_part = str; |
60 |
|
str = ""; |
61 |
|
} |
62 |
|
return first_part; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
/* vector<string> v = split(" asdf # asdffoo fasdf # fadasfd "); |
68 |
|
* 0: asdf |
69 |
|
* 1: # |
70 |
|
* 2: asdffoo |
71 |
|
* 3: fasdf |
72 |
|
* 4: # |
73 |
|
* 5: fadasfd |
74 |
|
*/ |
75 |
vector<string> split(string str) { |
vector<string> split(string str) { |
76 |
vector<string> v; |
string tmp; |
77 |
const char *p = str.c_str(); |
vector<string> v; |
78 |
char buf[1000]; |
|
79 |
int n; |
while (str != "") { |
80 |
|
tmp = separate(str); |
81 |
while (sscanf(p, " %999s %n", buf, &n) == 1) { |
if (tmp != "") v.push_back(tmp); |
82 |
v.insert(v.end(), string(buf)); |
} |
83 |
p += n; |
return v; |
|
} |
|
|
return v; |
|
84 |
} |
} |
85 |
|
|
86 |
vector<GLfloat> getfv(vector<string> v, unsigned i, int reserve = 0) { |
vector<GLfloat> getfv(vector<string> v, unsigned i, int reserve = 0) { |
124 |
|
|
125 |
bool callGLop(string s) { |
bool callGLop(string s) { |
126 |
DBG(dbg) << "callGLop(\"" << s << "\")\n"; |
DBG(dbg) << "callGLop(\"" << s << "\")\n"; |
127 |
|
|
128 |
|
string::size_type position = s.find('#'); |
129 |
|
if (position != string::npos) s = s.substr(0, position); |
130 |
|
|
131 |
vector<string> v = split(s); |
vector<string> v = split(s); |
132 |
|
|
133 |
if (v.size() < 1) return true; |
if (v.size() < 1) return true; |
134 |
|
|
135 |
// Ignore lines where the first splitted "word" starts with a '#' |
// Ignore lines where the first splitted "word" starts with a '#' |
136 |
if (v[0][0] == '#') return true; |
//if (v[0][0] == '#') return true; |
137 |
|
|
138 |
if (checkfunc(v, "Enable", 1)) { |
if (checkfunc(v, "Enable", 1)) { |
139 |
glEnable(getToken(v[1])); |
glEnable(getToken(v[1])); |