OgreImporter: Rename .hpp to .h. Shuffled parsing utils to a single file.
parent
6ea07f39e1
commit
fcb97bb595
|
@ -320,8 +320,8 @@ SET( Obj_SRCS
|
|||
SOURCE_GROUP( Obj FILES ${Obj_SRCS})
|
||||
|
||||
SET( Ogre_SRCS
|
||||
OgreImporter.hpp
|
||||
OgreXmlHelper.hpp
|
||||
OgreImporter.h
|
||||
OgreParsingUtils.h
|
||||
OgreImporter.cpp
|
||||
OgreMaterial.cpp
|
||||
OgreMesh.cpp
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "BaseImporter.h"
|
||||
#include "OgreXmlHelper.hpp"
|
||||
#include "irrXMLWrapper.h"
|
||||
#include "OgreParsingUtils.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
@ -49,12 +49,13 @@ to make it shorter easier to maintain.
|
|||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include "OgreImporter.hpp"
|
||||
#include "OgreImporter.h"
|
||||
#include "irrXMLWrapper.h"
|
||||
#include "TinyFormatter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
namespace Ogre
|
||||
|
@ -64,23 +65,6 @@ static const string partComment = "//";
|
|||
static const string partBlockStart = "{";
|
||||
static const string partBlockEnd = "}";
|
||||
|
||||
/// Skips a line from current @ss position until a newline. Returns the skipped part.
|
||||
std::string SkipLine(stringstream &ss)
|
||||
{
|
||||
string skipped;
|
||||
getline(ss, skipped);
|
||||
return skipped;
|
||||
}
|
||||
|
||||
/// Skips a line and reads next element from @c ss to @c nextElement.
|
||||
/** @return Skipped line content until newline. */
|
||||
std::string NextAfterNewLine(stringstream &ss, std::string &nextElement)
|
||||
{
|
||||
string skipped = SkipLine(ss);
|
||||
ss >> nextElement;
|
||||
return skipped;
|
||||
}
|
||||
|
||||
aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSystem *pIOHandler, const std::string materialName)
|
||||
{
|
||||
/// @todo Should we return null ptr here or a empty material?
|
||||
|
@ -216,7 +200,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste
|
|||
|
||||
if (linePart == partTechnique)
|
||||
{
|
||||
string techniqueName = trim(SkipLine(ss));
|
||||
string techniqueName = Trim(SkipLine(ss));
|
||||
ReadTechnique(techniqueName, ss, material);
|
||||
}
|
||||
|
||||
|
@ -336,7 +320,7 @@ bool OgreImporter::ReadTechnique(const std::string &techniqueName, stringstream
|
|||
/// @todo Techniques have other attributes than just passes.
|
||||
if (linePart == partPass)
|
||||
{
|
||||
string passName = trim(SkipLine(ss));
|
||||
string passName = Trim(SkipLine(ss));
|
||||
ReadPass(passName, ss, material);
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +379,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat
|
|||
}
|
||||
else if (linePart == partTextureUnit)
|
||||
{
|
||||
string textureUnitName = trim(SkipLine(ss));
|
||||
string textureUnitName = Trim(SkipLine(ss));
|
||||
ReadTextureUnit(textureUnitName, ss, material);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,23 @@ inline bool CurrentNodeNameEquals(const XmlReader* reader, const std::string &na
|
|||
return (ASSIMP_stricmp(std::string(reader->getNodeName()), name) == 0);
|
||||
}
|
||||
|
||||
/// Skips a line from current @ss position until a newline. Returns the skipped part.
|
||||
static inline std::string SkipLine(std::stringstream &ss)
|
||||
{
|
||||
std::string skipped;
|
||||
getline(ss, skipped);
|
||||
return skipped;
|
||||
}
|
||||
|
||||
/// Skips a line and reads next element from @c ss to @c nextElement.
|
||||
/** @return Skipped line content until newline. */
|
||||
static inline std::string NextAfterNewLine(std::stringstream &ss, std::string &nextElement)
|
||||
{
|
||||
std::string skipped = SkipLine(ss);
|
||||
ss >> nextElement;
|
||||
return skipped;
|
||||
}
|
||||
|
||||
/// Returns a lower cased copy of @s.
|
||||
static inline std::string ToLower(std::string s)
|
||||
{
|
||||
|
@ -100,7 +117,7 @@ static inline std::string ToLower(std::string s)
|
|||
// From http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
|
||||
|
||||
// trim from start
|
||||
static inline std::string <rim(std::string &s, bool newlines = true)
|
||||
static inline std::string &TrimLeft(std::string &s, bool newlines = true)
|
||||
{
|
||||
if (!newlines)
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(Assimp::IsSpace<char>))));
|
||||
|
@ -110,7 +127,7 @@ static inline std::string <rim(std::string &s, bool newlines = true)
|
|||
}
|
||||
|
||||
// trim from end
|
||||
static inline std::string &rtrim(std::string &s, bool newlines = true)
|
||||
static inline std::string &TrimRight(std::string &s, bool newlines = true)
|
||||
{
|
||||
if (!newlines)
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(Assimp::IsSpace<char>))).base(),s.end());
|
||||
|
@ -119,9 +136,9 @@ static inline std::string &rtrim(std::string &s, bool newlines = true)
|
|||
return s;
|
||||
}
|
||||
// trim from both ends
|
||||
static inline std::string &trim(std::string &s, bool newlines = true)
|
||||
static inline std::string &Trim(std::string &s, bool newlines = true)
|
||||
{
|
||||
return ltrim(rtrim(s, newlines), newlines);
|
||||
return TrimLeft(TrimRight(s, newlines), newlines);
|
||||
}
|
||||
|
||||
} // Ogre
|
Loading…
Reference in New Issue