OBJParser
OBJ File Parser Powered by Boost Spirit
|
#include <OBJParser.hpp>
Public Types | |
enum | Result { Result::Success = 0, Result::FailedOBJFileRead, Result::FailedOBJParseError, Result::FailedMTLFileRead, Result::FailedMTLParseError } |
Public Member Functions | |
Result | parseOBJFile (std::string const &path) |
OBJState * | getOBJState () |
std::string const & | getLastError () const |
Protected Member Functions | |
Result | parseOBJFilefstream (std::string const &path) |
Result | parseOBJFileMemMap (std::string const &path) |
Result | parseMTLFilefstream (std::string const &path) |
Result | parseMTLFileMemMap (std::string const &path) |
std::string | buildRelativeMTLPath (std::string const &objPath, std::string const &mtlPath) |
std::string | extractLastLine (const char *str) |
std::string | extractLastLine (std::ifstream &stream) |
Protected Attributes | |
OBJState | m_OBJState |
Internal OBJ state. | |
std::string | m_LastError |
String representation of last error. | |
Parser for OBJ and MTL format files.
If OBJ_PARSER_USE_MEM_MAP is defined, then files will be read in using memory-mapped files.
Otherwise, files will be read in using the standard filestream.
Upon parsing, the resulting OBJ and MTL data is stored within the internal OBJState object. This state is automatically cleared prior to any parsing actions.
|
strong |
std::string const & OBJParser::getLastError | ( | ) | const |
OBJState * OBJParser::getOBJState | ( | ) |
Returns a pointer to the internal OBJState object.
OBJParser::Result OBJParser::parseOBJFile | ( | std::string const & | path | ) |
Attempts to parse an OBJ formatted file.
If successful, resulting OBJ data will be stored in the member OBJState object which may be accessed via getOBJState().
If failed getLastError() may be used to for additional information.
[in] | path | Relative path to the OBJ file. |