2012-06-25 14:10:35 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2024-02-23 21:30:05 +00:00
|
|
|
Copyright (c) 2006-2024, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2012-06-25 14:10:35 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2012-06-25 14:10:35 +00:00
|
|
|
following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2012-06-25 14:10:35 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 03:52:10 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2012-06-25 14:10:35 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 03:52:10 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2012-06-25 14:10:35 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 03:52:10 +00:00
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2012-06-25 14:10:35 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file FBXUtil.h
|
|
|
|
* @brief FBX utility functions for internal use
|
|
|
|
*/
|
|
|
|
#ifndef INCLUDED_AI_FBX_UTIL_H
|
|
|
|
#define INCLUDED_AI_FBX_UTIL_H
|
|
|
|
|
|
|
|
#include "FBXCompileConfig.h"
|
2012-07-07 18:46:29 +00:00
|
|
|
#include "FBXTokenizer.h"
|
2019-04-06 22:02:22 +00:00
|
|
|
#include <stdint.h>
|
2012-06-25 14:10:35 +00:00
|
|
|
|
|
|
|
namespace Assimp {
|
|
|
|
namespace FBX {
|
2012-06-25 21:03:06 +00:00
|
|
|
|
|
|
|
|
2012-06-25 14:10:35 +00:00
|
|
|
namespace Util {
|
|
|
|
|
2012-06-25 21:03:06 +00:00
|
|
|
|
|
|
|
/** helper for std::for_each to delete all heap-allocated items in a container */
|
|
|
|
template<typename T>
|
|
|
|
struct delete_fun
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
void operator()(const volatile T* del) {
|
|
|
|
delete del;
|
|
|
|
}
|
2012-06-25 21:03:06 +00:00
|
|
|
};
|
|
|
|
|
2022-04-20 14:11:09 +00:00
|
|
|
/** helper for std::for_each to call the destructor on all items in a container without freeing their heap*/
|
|
|
|
template <typename T>
|
|
|
|
struct destructor_fun {
|
|
|
|
void operator()(const volatile T* del) {
|
|
|
|
if (del) {
|
|
|
|
del->~T();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-06-25 21:03:06 +00:00
|
|
|
/** Get a string representation for a #TokenType. */
|
|
|
|
const char* TokenTypeString(TokenType t);
|
|
|
|
|
|
|
|
|
2012-08-09 00:08:12 +00:00
|
|
|
|
|
|
|
/** Format log/error messages using a given offset in the source binary file
|
|
|
|
*
|
2020-08-19 16:20:57 +00:00
|
|
|
* @param offset offset within the file
|
|
|
|
* @return A string of the following format: " (offset 0x{offset}) "*/
|
|
|
|
std::string GetOffsetText(size_t offset);
|
2012-08-09 00:08:12 +00:00
|
|
|
|
|
|
|
|
2012-06-25 14:10:35 +00:00
|
|
|
/** Format log/error messages using a given line location in the source file.
|
|
|
|
*
|
|
|
|
* @param line Line index, 1-based
|
2016-04-03 00:38:00 +00:00
|
|
|
* @param column Column index, 1-based
|
2020-08-19 16:20:57 +00:00
|
|
|
* @return A string of the following format: " (line {line}, col {column}) "*/
|
|
|
|
std::string GetLineAndColumnText(unsigned int line, unsigned int column);
|
2015-05-19 03:52:10 +00:00
|
|
|
|
2012-06-25 21:03:06 +00:00
|
|
|
|
|
|
|
/** Format log/error messages using a given cursor token.
|
|
|
|
*
|
|
|
|
* @param tok Token where parsing/processing stopped
|
2020-08-19 16:20:57 +00:00
|
|
|
* @return A string of the following format: " ({token-type}, line {line}, col {column}) "*/
|
|
|
|
std::string GetTokenText(const Token* tok);
|
2012-06-25 21:03:06 +00:00
|
|
|
|
2019-04-06 17:31:56 +00:00
|
|
|
/** Decode a single Base64-encoded character.
|
|
|
|
*
|
|
|
|
* @param ch Character to decode (from base64 to binary).
|
|
|
|
* @return decoded byte value*/
|
|
|
|
uint8_t DecodeBase64(char ch);
|
|
|
|
|
2019-05-14 13:43:16 +00:00
|
|
|
/** Compute decoded size of a Base64-encoded string
|
|
|
|
*
|
|
|
|
* @param in Characters to decode.
|
|
|
|
* @param inLength Number of characters to decode.
|
|
|
|
* @return size of the decoded data (number of bytes)*/
|
|
|
|
size_t ComputeDecodedSizeBase64(const char* in, size_t inLength);
|
|
|
|
|
2019-04-06 17:31:56 +00:00
|
|
|
/** Decode a Base64-encoded string
|
|
|
|
*
|
|
|
|
* @param in Characters to decode.
|
|
|
|
* @param inLength Number of characters to decode.
|
2019-05-14 13:43:16 +00:00
|
|
|
* @param out Pointer where we will store the decoded data.
|
|
|
|
* @param maxOutLength Size of output buffer.
|
2019-04-06 17:31:56 +00:00
|
|
|
* @return size of the decoded data (number of bytes)*/
|
2019-05-14 13:43:16 +00:00
|
|
|
size_t DecodeBase64(const char* in, size_t inLength, uint8_t* out, size_t maxOutLength);
|
2019-04-06 17:31:56 +00:00
|
|
|
|
2019-05-09 12:50:22 +00:00
|
|
|
char EncodeBase64(char byte);
|
|
|
|
|
|
|
|
/** Encode bytes in base64-encoding
|
|
|
|
*
|
|
|
|
* @param data Binary data to encode.
|
|
|
|
* @param inLength Number of bytes to encode.
|
|
|
|
* @return base64-encoded string*/
|
|
|
|
std::string EncodeBase64(const char* data, size_t length);
|
|
|
|
|
2012-06-25 14:10:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ! INCLUDED_AI_FBX_UTIL_H
|