1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2025, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42/** @file FBXUtil.h
43 * @brief FBX utility functions for internal use
44 */
45#ifndef INCLUDED_AI_FBX_UTIL_H
46#define INCLUDED_AI_FBX_UTIL_H
47
48#include "FBXCompileConfig.h"
49#include "FBXTokenizer.h"
50#include <stdint.h>
51
52namespace Assimp {
53namespace FBX {
54
55namespace Util {
56
57/** helper for std::for_each to delete all heap-allocated items in a container */
58template<typename T>
59struct delete_fun
60{
61 void operator()(const volatile T* del) {
62 delete del;
63 }
64};
65
66/** helper for std::for_each to call the destructor on all items in a container without freeing their heap*/
67template <typename T>
68struct destructor_fun {
69 void operator()(const volatile T* del) {
70 if (del) {
71 del->~T();
72 }
73 }
74};
75
76
77/** Get a string representation for a #TokenType. */
78const char* TokenTypeString(TokenType t);
79
80
81
82/** Format log/error messages using a given offset in the source binary file
83 *
84 * @param offset offset within the file
85 * @return A string of the following format: " (offset 0x{offset}) "*/
86std::string GetOffsetText(size_t offset);
87
88/** Format log/error messages using a given line location in the source file.
89 *
90 * @param line Line index, 1-based
91 * @param column Column index, 1-based
92 * @return A string of the following format: " (line {line}, col {column}) "*/
93std::string GetLineAndColumnText(unsigned int line, unsigned int column);
94
95/** Format log/error messages using a given cursor token.
96 *
97 * @param tok Token where parsing/processing stopped
98 * @return A string of the following format: " ({token-type}, line {line}, col {column}) "*/
99std::string GetTokenText(const Token* tok);
100
101/** Decode a single Base64-encoded character.
102*
103* @param ch Character to decode (from base64 to binary).
104* @return decoded byte value*/
105uint8_t DecodeBase64(char ch);
106
107/** Compute decoded size of a Base64-encoded string
108*
109* @param in Characters to decode.
110* @param inLength Number of characters to decode.
111* @return size of the decoded data (number of bytes)*/
112size_t ComputeDecodedSizeBase64(const char* in, size_t inLength);
113
114/** Decode a Base64-encoded string
115*
116* @param in Characters to decode.
117* @param inLength Number of characters to decode.
118* @param out Pointer where we will store the decoded data.
119* @param maxOutLength Size of output buffer.
120* @return size of the decoded data (number of bytes)*/
121size_t DecodeBase64(const char* in, size_t inLength, uint8_t* out, size_t maxOutLength);
122
123char EncodeBase64(char byte);
124
125/** Encode bytes in base64-encoding
126*
127* @param data Binary data to encode.
128* @param inLength Number of bytes to encode.
129* @return base64-encoded string*/
130std::string EncodeBase64(const char* data, size_t length);
131
132}
133}
134}
135
136#endif // ! INCLUDED_AI_FBX_UTIL_H
137

source code of qtquick3d/src/3rdparty/assimp/src/code/AssetLib/FBX/FBXUtil.h