OBJParser
OBJ File Parser Powered by Boost Spirit
 All Classes Functions Variables Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OBJParser Class Reference

#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)
 
OBJStategetOBJState ()
 
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.
 

Detailed Description

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.

Member Enumeration Documentation

enum OBJParser::Result
strong
Enumerator
Success 

No errors encountered during parsing.

FailedOBJFileRead 

Failed to open and/or read OBJ file.

FailedOBJParseError 

Error encountered during OBJ parsing, see getLastError.

FailedMTLFileRead 

Failed to open and/or read MTL file.

FailedMTLParseError 

Error encountered during MTL parsing, see getLastError.

Member Function Documentation

std::string const & OBJParser::getLastError ( ) const
Returns
Human-readable string description of last error encountered.
OBJState * OBJParser::getOBJState ( )

Returns a pointer to the internal OBJState object.

Note
This state is cleared during each parse call (pointer remains valid).
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.

Parameters
[in]pathRelative path to the OBJ file.
Returns

The documentation for this class was generated from the following files: