|
@@ -118,9 +118,9 @@ extern "C" {
|
|
|
|
|
|
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */
|
|
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
-static const size_t MAXLEN = 1024;
|
|
|
|
|
|
+static const size_t AI_MAXLEN = 1024;
|
|
#else
|
|
#else
|
|
-#define MAXLEN 1024
|
|
|
|
|
|
+#define AI_MAXLEN 1024
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------------
|
|
@@ -243,7 +243,8 @@ struct aiColor3D {
|
|
}; // !struct aiColor3D
|
|
}; // !struct aiColor3D
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------------
|
|
-/** Represents an UTF-8 string, zero byte terminated.
|
|
|
|
|
|
+/**
|
|
|
|
+ * @brief Represents an UTF-8 string, zero byte terminated.
|
|
*
|
|
*
|
|
* The character set of an aiString is explicitly defined to be UTF-8. This Unicode
|
|
* The character set of an aiString is explicitly defined to be UTF-8. This Unicode
|
|
* transformation was chosen in the belief that most strings in 3d files are limited
|
|
* transformation was chosen in the belief that most strings in 3d files are limited
|
|
@@ -260,42 +261,40 @@ struct aiColor3D {
|
|
* UTF-8 strings to their working character set (i.e. MBCS, WideChar).
|
|
* UTF-8 strings to their working character set (i.e. MBCS, WideChar).
|
|
*
|
|
*
|
|
* We use this representation instead of std::string to be C-compatible. The
|
|
* We use this representation instead of std::string to be C-compatible. The
|
|
- * (binary) length of such a string is limited to MAXLEN characters (including the
|
|
|
|
|
|
+ * (binary) length of such a string is limited to AI_MAXLEN characters (including the
|
|
* the terminating zero).
|
|
* the terminating zero).
|
|
-*/
|
|
|
|
|
|
+ */
|
|
struct aiString {
|
|
struct aiString {
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
/** Default constructor, the string is set to have zero length */
|
|
/** Default constructor, the string is set to have zero length */
|
|
- aiString() AI_NO_EXCEPT
|
|
|
|
- : length(0) {
|
|
|
|
- data[0] = '\0';
|
|
|
|
-
|
|
|
|
|
|
+ aiString() AI_NO_EXCEPT :
|
|
|
|
+ length(0), data{'\0'} {
|
|
#ifdef ASSIMP_BUILD_DEBUG
|
|
#ifdef ASSIMP_BUILD_DEBUG
|
|
// Debug build: overwrite the string on its full length with ESC (27)
|
|
// Debug build: overwrite the string on its full length with ESC (27)
|
|
- memset(data + 1, 27, MAXLEN - 1);
|
|
|
|
|
|
+ memset(data + 1, 27, AI_MAXLEN - 1);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
/** Copy constructor */
|
|
/** Copy constructor */
|
|
aiString(const aiString &rOther) :
|
|
aiString(const aiString &rOther) :
|
|
- length(rOther.length) {
|
|
|
|
|
|
+ length(rOther.length), data{'\0'} {
|
|
// Crop the string to the maximum length
|
|
// Crop the string to the maximum length
|
|
- length = length >= MAXLEN ? MAXLEN - 1 : length;
|
|
|
|
|
|
+ length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
|
|
memcpy(data, rOther.data, length);
|
|
memcpy(data, rOther.data, length);
|
|
data[length] = '\0';
|
|
data[length] = '\0';
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/** Constructor from std::string */
|
|
/** Constructor from std::string */
|
|
explicit aiString(const std::string &pString) :
|
|
explicit aiString(const std::string &pString) :
|
|
- length((ai_uint32)pString.length()) {
|
|
|
|
- length = length >= MAXLEN ? MAXLEN - 1 : length;
|
|
|
|
|
|
+ length((ai_uint32)pString.length()), data{'\0'} {
|
|
|
|
+ length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
|
|
memcpy(data, pString.c_str(), length);
|
|
memcpy(data, pString.c_str(), length);
|
|
data[length] = '\0';
|
|
data[length] = '\0';
|
|
}
|
|
}
|
|
|
|
|
|
/** Copy a std::string to the aiString */
|
|
/** Copy a std::string to the aiString */
|
|
void Set(const std::string &pString) {
|
|
void Set(const std::string &pString) {
|
|
- if (pString.length() > MAXLEN - 1) {
|
|
|
|
|
|
+ if (pString.length() > AI_MAXLEN - 1) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
length = (ai_uint32)pString.length();
|
|
length = (ai_uint32)pString.length();
|
|
@@ -306,8 +305,8 @@ struct aiString {
|
|
/** Copy a const char* to the aiString */
|
|
/** Copy a const char* to the aiString */
|
|
void Set(const char *sz) {
|
|
void Set(const char *sz) {
|
|
ai_int32 len = (ai_uint32)::strlen(sz);
|
|
ai_int32 len = (ai_uint32)::strlen(sz);
|
|
- if (len > (ai_int32)MAXLEN - 1) {
|
|
|
|
- len = (ai_int32) MAXLEN - 1;
|
|
|
|
|
|
+ if (len > static_cast<ai_int32>(AI_MAXLEN - 1)) {
|
|
|
|
+ len = static_cast<ai_int32>(AI_MAXLEN - 1);
|
|
}
|
|
}
|
|
length = len;
|
|
length = len;
|
|
memcpy(data, sz, len);
|
|
memcpy(data, sz, len);
|
|
@@ -321,8 +320,8 @@ struct aiString {
|
|
}
|
|
}
|
|
|
|
|
|
length = rOther.length;
|
|
length = rOther.length;
|
|
- if (length >(MAXLEN - 1)) {
|
|
|
|
- length = (ai_int32) MAXLEN - 1;
|
|
|
|
|
|
+ if (length > (AI_MAXLEN - 1)) {
|
|
|
|
+ length = static_cast<ai_int32>(AI_MAXLEN - 1);
|
|
}
|
|
}
|
|
|
|
|
|
memcpy(data, rOther.data, length);
|
|
memcpy(data, rOther.data, length);
|
|
@@ -344,21 +343,24 @@ struct aiString {
|
|
|
|
|
|
/** Comparison operator */
|
|
/** Comparison operator */
|
|
bool operator==(const aiString &other) const {
|
|
bool operator==(const aiString &other) const {
|
|
- return (length == other.length && 0 == memcmp(data, other.data, length));
|
|
|
|
|
|
+ if (length == other.length) {
|
|
|
|
+ return memcmp(data, other.data, length) == 0;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
/** Inverse comparison operator */
|
|
/** Inverse comparison operator */
|
|
bool operator!=(const aiString &other) const {
|
|
bool operator!=(const aiString &other) const {
|
|
- return (length != other.length || 0 != memcmp(data, other.data, length));
|
|
|
|
|
|
+ return !(*this == other);
|
|
}
|
|
}
|
|
|
|
|
|
/** Append a string to the string */
|
|
/** Append a string to the string */
|
|
void Append(const char *app) {
|
|
void Append(const char *app) {
|
|
- const ai_uint32 len = (ai_uint32)::strlen(app);
|
|
|
|
|
|
+ const ai_uint32 len = static_cast<ai_uint32>(::strlen(app));
|
|
if (!len) {
|
|
if (!len) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (length + len >= MAXLEN) {
|
|
|
|
|
|
+ if (length + len >= AI_MAXLEN) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -373,7 +375,7 @@ struct aiString {
|
|
|
|
|
|
#ifdef ASSIMP_BUILD_DEBUG
|
|
#ifdef ASSIMP_BUILD_DEBUG
|
|
// Debug build: overwrite the string on its full length with ESC (27)
|
|
// Debug build: overwrite the string on its full length with ESC (27)
|
|
- memset(data + 1, 27, MAXLEN - 1);
|
|
|
|
|
|
+ memset(data + 1, 27, AI_MAXLEN - 1);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -389,8 +391,8 @@ struct aiString {
|
|
* the number of bytes from the beginning of the string to its end.*/
|
|
* the number of bytes from the beginning of the string to its end.*/
|
|
ai_uint32 length;
|
|
ai_uint32 length;
|
|
|
|
|
|
- /** String buffer. Size limit is MAXLEN */
|
|
|
|
- char data[MAXLEN];
|
|
|
|
|
|
+ /** String buffer. Size limit is AI_MAXLEN */
|
|
|
|
+ char data[AI_MAXLEN];
|
|
}; // !struct aiString
|
|
}; // !struct aiString
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------------
|
|
@@ -528,7 +530,7 @@ struct aiMemoryInfo {
|
|
*/
|
|
*/
|
|
struct aiBuffer {
|
|
struct aiBuffer {
|
|
const char *data; ///< Begin poiner
|
|
const char *data; ///< Begin poiner
|
|
- const char *end; ///< End pointer
|
|
|
|
|
|
+ const char *end; ///< End pointer
|
|
|
|
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
/// @brief The class constructor.
|
|
/// @brief The class constructor.
|