fix review findings.
This commit is contained in:
@@ -115,8 +115,8 @@ bool IsSpaceOrNewLine( char_t in) {
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpaces( const char_t* in, const char_t** out)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpaces( const char_t* in, const char_t** out) {
|
||||
while( *in == ( char_t )' ' || *in == ( char_t )'\t' ) {
|
||||
++in;
|
||||
}
|
||||
@@ -126,15 +126,15 @@ AI_FORCE_INLINE bool SkipSpaces( const char_t* in, const char_t** out)
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpaces( const char_t** inout)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpaces( const char_t** inout) {
|
||||
return SkipSpaces<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipLine( const char_t* in, const char_t** out)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipLine( const char_t* in, const char_t** out) {
|
||||
while( *in != ( char_t )'\r' && *in != ( char_t )'\n' && *in != ( char_t )'\0' ) {
|
||||
++in;
|
||||
}
|
||||
@@ -149,15 +149,15 @@ AI_FORCE_INLINE bool SkipLine( const char_t* in, const char_t** out)
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipLine( const char_t** inout)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipLine( const char_t** inout) {
|
||||
return SkipLine<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpacesAndLineEnd( const char_t* in, const char_t** out)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpacesAndLineEnd( const char_t* in, const char_t** out) {
|
||||
while( *in == ( char_t )' ' || *in == ( char_t )'\t' || *in == ( char_t )'\r' || *in == ( char_t )'\n' ) {
|
||||
++in;
|
||||
}
|
||||
@@ -167,15 +167,15 @@ AI_FORCE_INLINE bool SkipSpacesAndLineEnd( const char_t* in, const char_t** out)
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpacesAndLineEnd( const char_t** inout)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpacesAndLineEnd( const char_t** inout) {
|
||||
return SkipSpacesAndLineEnd<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool GetNextLine( const char_t*& buffer, char_t out[ BufferSize ] )
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool GetNextLine( const char_t*& buffer, char_t out[ BufferSize ] ) {
|
||||
if( ( char_t )'\0' == *buffer ) {
|
||||
return false;
|
||||
}
|
||||
@@ -203,7 +203,8 @@ AI_FORCE_INLINE bool IsNumeric( char_t in)
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool TokenMatch(char_t*& in, const char* token, unsigned int len)
|
||||
AI_FORCE_INLINE
|
||||
bool TokenMatch(char_t*& in, const char* token, unsigned int len)
|
||||
{
|
||||
if (!::strncmp(token,in,len) && IsSpaceOrNewLine(in[len])) {
|
||||
if (in[len] != '\0') {
|
||||
@@ -223,26 +224,32 @@ AI_FORCE_INLINE bool TokenMatch(char_t*& in, const char* token, unsigned int len
|
||||
* @param token Token to check for
|
||||
* @param len Number of characters to check
|
||||
*/
|
||||
AI_FORCE_INLINE bool TokenMatchI(const char*& in, const char* token, unsigned int len)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
bool TokenMatchI(const char*& in, const char* token, unsigned int len) {
|
||||
if (!ASSIMP_strincmp(token,in,len) && IsSpaceOrNewLine(in[len])) {
|
||||
in += len+1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE void SkipToken(const char*& in)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
void SkipToken(const char*& in) {
|
||||
SkipSpaces(&in);
|
||||
while (!IsSpaceOrNewLine(*in))++in;
|
||||
while ( !IsSpaceOrNewLine( *in ) ) {
|
||||
++in;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE std::string GetNextToken(const char*& in)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
std::string GetNextToken(const char*& in) {
|
||||
SkipSpacesAndLineEnd(&in);
|
||||
const char* cur = in;
|
||||
while (!IsSpaceOrNewLine(*in))++in;
|
||||
while ( !IsSpaceOrNewLine( *in ) ) {
|
||||
++in;
|
||||
}
|
||||
return std::string(cur,(size_t)(in-cur));
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define INCLUDED_AI_STRING_WORKERS_H
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/defs.h>
|
||||
#include "StringComparison.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -72,8 +73,8 @@ namespace Assimp {
|
||||
* @param number Number to be written
|
||||
* @return Length of the output string, excluding the '\0'
|
||||
*/
|
||||
inline unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
ai_assert(NULL != out);
|
||||
|
||||
// write the unary minus to indicate we have a negative number
|
||||
@@ -91,7 +92,7 @@ inline unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number)
|
||||
|
||||
const unsigned int digit = number / cur;
|
||||
if (mustPrint || digit > 0 || 1 == cur) {
|
||||
// print all future zeroes from now
|
||||
// print all future zeroe's from now
|
||||
mustPrint = true;
|
||||
|
||||
*out++ = '0'+static_cast<char>(digit);
|
||||
@@ -116,8 +117,8 @@ inline unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number)
|
||||
* size of the array automatically.
|
||||
*/
|
||||
template <size_t length>
|
||||
inline unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) {
|
||||
return ASSIMP_itoa10(out,length,number);
|
||||
}
|
||||
|
||||
@@ -132,9 +133,10 @@ inline unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number)
|
||||
* @param s2 Second input string
|
||||
* @return 0 if the given strings are identical
|
||||
*/
|
||||
inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
ai_assert(NULL != s1 && NULL != s2);
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const char *s1, const char *s2) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
@@ -161,8 +163,8 @@ inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
||||
* @param b Second string
|
||||
* @return 0 if a == b
|
||||
*/
|
||||
inline int ASSIMP_stricmp(const std::string& a, const std::string& b)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const std::string& a, const std::string& b) {
|
||||
int i = (int)b.length()-(int)a.length();
|
||||
return (i ? i : ASSIMP_stricmp(a.c_str(),b.c_str()));
|
||||
}
|
||||
@@ -179,10 +181,13 @@ inline int ASSIMP_stricmp(const std::string& a, const std::string& b)
|
||||
* @param n Macimum number of characters to compare
|
||||
* @return 0 if the given strings are identical
|
||||
*/
|
||||
inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
||||
{
|
||||
ai_assert(NULL != s1 && NULL != s2);
|
||||
if (!n)return 0;
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
if ( !n ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
@@ -213,14 +218,16 @@ inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
||||
*
|
||||
* todo: move somewhere where it fits better in than here
|
||||
*/
|
||||
inline unsigned int integer_pow (unsigned int base, unsigned int power)
|
||||
{
|
||||
AI_FORCE_INLINE
|
||||
unsigned int integer_pow( unsigned int base, unsigned int power ) {
|
||||
unsigned int res = 1;
|
||||
for (unsigned int i = 0; i < power;++i)
|
||||
for ( unsigned int i = 0; i < power; ++i ) {
|
||||
res *= base;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif // ! AI_STRINGCOMPARISON_H_INC
|
||||
|
||||
@@ -42,6 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef INCLUDED_AI_STRINGUTILS_H
|
||||
#define INCLUDED_AI_STRINGUTILS_H
|
||||
|
||||
#include <assimp/defs.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include <cstdlib>
|
||||
@@ -55,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/// @return The number of written characters if the buffer size was big enough. If an encoding error occurs, a negative number is returned.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
inline
|
||||
AI_FORCE_INLINE
|
||||
int c99_ai_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
|
||||
int count(-1);
|
||||
if (0 != size) {
|
||||
@@ -68,7 +70,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
return count;
|
||||
}
|
||||
|
||||
inline
|
||||
AI_FORCE_INLINE
|
||||
int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
|
||||
int count;
|
||||
va_list ap;
|
||||
@@ -89,7 +91,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/// @param value The value to write into the std::string.
|
||||
/// @return The value as a std::string
|
||||
template <typename T>
|
||||
inline
|
||||
AI_FORCE_INLINE
|
||||
std::string to_string( T value ) {
|
||||
std::ostringstream os;
|
||||
os << value;
|
||||
@@ -102,7 +104,7 @@ std::string to_string( T value ) {
|
||||
/// @param begin The first character of the string.
|
||||
/// @param end The last character
|
||||
/// @return The float value, 0.0f in cas of an error.
|
||||
inline
|
||||
AI_FORCE_INLINE
|
||||
float ai_strtof( const char *begin, const char *end ) {
|
||||
if ( nullptr == begin ) {
|
||||
return 0.0f;
|
||||
@@ -124,7 +126,7 @@ float ai_strtof( const char *begin, const char *end ) {
|
||||
/// @param toConvert Value to convert
|
||||
/// @return The hexadecimal string, is empty in case of an error.
|
||||
template<class T>
|
||||
inline
|
||||
AI_FORCE_INLINE
|
||||
std::string DecimalToHexa( T toConvert ) {
|
||||
std::string result;
|
||||
std::stringstream ss;
|
||||
|
||||
Reference in New Issue
Block a user