feature: stages
stages: separate scanning and parsing, allowing `v`, `vn`, `vt` lines to be mapped to line numbers and store line data (once). first stage parsing: parse face data and validate vertices. TODO: * improve validation (detect partial normals/texcoords); * maybe improve storage of triangle line number instead of storing line number for each vertex;
This commit is contained in:
16
src/trim.cpp
Normal file
16
src/trim.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "trim.hpp"
|
||||
|
||||
namespace wavefront {
|
||||
std::string_view trim(const std::string_view &source) {
|
||||
auto start = source.data();
|
||||
// size is the size of buffer, data() + size() is the first available byte after the string.
|
||||
auto end = source.data() + source.size() - 1;
|
||||
while (start < end && std::isspace(*start)) {
|
||||
++start;
|
||||
}
|
||||
while (start < end && (std::isspace(*end) || *end == 0)) {
|
||||
--end;
|
||||
}
|
||||
return std::string_view(start, end - start + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user