-
-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathdebug_parse.cc
More file actions
48 lines (38 loc) · 1.46 KB
/
Copy pathdebug_parse.cc
File metadata and controls
48 lines (38 loc) · 1.46 KB
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
#include "../tinyobj_v3.hh"
#include <cstdio>
int main() {
const char* mtl_content =
"newmtl test\n"
"Pr 0.5\n"
"Pm 0.3\n";
tinyobj::v3::StreamReader reader(mtl_content, strlen(mtl_content));
std::string line;
while (reader.readLine(line, 1024)) {
printf("Line: '%s'\n", line.c_str());
tinyobj::v3::StreamReader line_reader(line.data(), line.size());
std::string cmd;
tinyobj::v3::detail::skipSpaces(line_reader);
if (tinyobj::v3::detail::readWord(line_reader, cmd)) {
printf(" Command: '%s'\n", cmd.c_str());
if (cmd == "Pr") {
float val;
tinyobj::v3::detail::skipSpaces(line_reader);
// Try manual parse
char ch;
if (line_reader.peekChar(ch)) {
printf(" Next char: '%c' (0x%02x)\n", ch, (unsigned char)ch);
}
// Create a minimal parsing context
tinyobj::v3::ParserConfig config;
tinyobj::v3::ObjParser parser(config);
// We can't easily call parseFloat from here without ParseState
// Let's just check what readWord gives us
std::string value_str;
if (tinyobj::v3::detail::readWord(line_reader, value_str)) {
printf(" Value string: '%s'\n", value_str.c_str());
}
}
}
}
return 0;
}