From 729e98fef0458f5dc545f83dd9a7cb150059541e Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Fri, 10 Aug 2012 21:39:47 +0200 Subject: [PATCH] + fbx: Parser::IsBinary(), Document::IsBinary() --- code/FBXDocument.h | 15 ++++++++++++--- code/FBXImporter.cpp | 4 +++- code/FBXParser.cpp | 3 ++- code/FBXParser.h | 11 ++++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/code/FBXDocument.h b/code/FBXDocument.h index 37c1469fc..71c1e6837 100644 --- a/code/FBXDocument.h +++ b/code/FBXDocument.h @@ -886,6 +886,9 @@ public: LazyObject* GetObject(uint64_t id) const; + bool IsBinary() const { + return parser.IsBinary(); + } unsigned int FBXVersion() const { return fbxVersion; @@ -932,15 +935,21 @@ public: std::vector GetConnectionsBySourceSequenced(uint64_t source, const char* classname) const; std::vector GetConnectionsByDestinationSequenced(uint64_t dest, const char* classname) const; - std::vector GetConnectionsBySourceSequenced(uint64_t source, const char* const* classnames, size_t count) const; - std::vector GetConnectionsByDestinationSequenced(uint64_t dest, const char* const* classnames, size_t count) const; + std::vector GetConnectionsBySourceSequenced(uint64_t source, + const char* const* classnames, size_t count) const; + std::vector GetConnectionsByDestinationSequenced(uint64_t dest, + const char* const* classnames, + size_t count) const; const std::vector& AnimationStacks() const; private: std::vector GetConnectionsSequenced(uint64_t id, const ConnectionMap&) const; - std::vector GetConnectionsSequenced(uint64_t id, bool is_src, const ConnectionMap&, const char* const* classnames, size_t count) const; + std::vector GetConnectionsSequenced(uint64_t id, bool is_src, + const ConnectionMap&, + const char* const* classnames, + size_t count) const; private: diff --git a/code/FBXImporter.cpp b/code/FBXImporter.cpp index a31f93605..52677d99b 100644 --- a/code/FBXImporter.cpp +++ b/code/FBXImporter.cpp @@ -153,7 +153,9 @@ void FBXImporter::InternReadFile( const std::string& pFile, TokenList tokens; try { + bool is_binary = false; if (!strncmp(begin,"Kaydara FBX Binary",18)) { + is_binary = true; TokenizeBinary(tokens,begin,contents.size()); } else { @@ -162,7 +164,7 @@ void FBXImporter::InternReadFile( const std::string& pFile, // use this information to construct a very rudimentary // parse-tree representing the FBX scope structure - Parser parser(tokens); + Parser parser(tokens, is_binary); // take the raw parse-tree and convert it to a FBX DOM Document doc(parser,settings); diff --git a/code/FBXParser.cpp b/code/FBXParser.cpp index a60b99bc8..c6324c733 100644 --- a/code/FBXParser.cpp +++ b/code/FBXParser.cpp @@ -163,11 +163,12 @@ Scope::~Scope() // ------------------------------------------------------------------------------------------------ -Parser::Parser (const TokenList& tokens) +Parser::Parser (const TokenList& tokens, bool is_binary) : tokens(tokens) , last() , current() , cursor(tokens.begin()) +, is_binary(is_binary) { root.reset(new Scope(*this,true)); } diff --git a/code/FBXParser.h b/code/FBXParser.h index 9a708cabe..5801eb98a 100644 --- a/code/FBXParser.h +++ b/code/FBXParser.h @@ -162,7 +162,7 @@ public: /** Parse given a token list. Does not take ownership of the tokens - * the objects must persist during the entire parser lifetime */ - Parser (const TokenList& tokens); + Parser (const TokenList& tokens,bool is_binary); ~Parser(); public: @@ -171,6 +171,11 @@ public: return *root.get(); } + + bool IsBinary() const { + return is_binary; + } + private: friend class Scope; @@ -181,6 +186,8 @@ private: TokenPtr LastToken() const; TokenPtr CurrentToken() const; + + private: const TokenList& tokens; @@ -188,6 +195,8 @@ private: TokenPtr last, current; TokenList::const_iterator cursor; boost::scoped_ptr root; + + const bool is_binary; };