1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef CORE__GLTF__GLTF2_LOADER_H
17 #define CORE__GLTF__GLTF2_LOADER_H
18
19 #include <3d/namespace.h>
20 #include <base/containers/array_view.h>
21 #include <base/containers/string.h>
22 #include <base/containers/string_view.h>
23 #include <base/containers/unique_ptr.h>
24 #include <core/namespace.h>
25
26 CORE_BEGIN_NAMESPACE()
27 class IFileManager;
28 CORE_END_NAMESPACE()
29
CORE3D_BEGIN_NAMESPACE()30 CORE3D_BEGIN_NAMESPACE()
31 namespace GLTF2 {
32 class Data;
33 /** Describes result of the parsing operation. */
34 struct LoadResult {
35 LoadResult() = default;
36 explicit LoadResult(BASE_NS::string&& error) : success(false), error(error) {}
37
38 /** Indicates, whether the loading operation is successful. */
39 bool success { true };
40
41 /** In case of parsing error, contains the description of the error. */
42 BASE_NS::string error;
43
44 /* Loaded data. */
45 BASE_NS::unique_ptr<Data> data;
46 };
47 LoadResult LoadGLTF(CORE_NS::IFileManager& fileManager, BASE_NS::string_view uri);
48 LoadResult LoadGLTF(CORE_NS::IFileManager& fileManager, const BASE_NS::array_view<uint8_t const> data);
49 } // namespace GLTF2
50 CORE3D_END_NAMESPACE()
51
52 #endif // CORE__GLTF__GLTF2_LOADER_H
53