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_EXPORTER_H
17 #define CORE__GLTF__GLTF2_EXPORTER_H
18 
19 #include <3d/namespace.h>
20 #include <base/containers/string.h>
21 #include <base/containers/type_traits.h>
22 #include <base/containers/unique_ptr.h>
23 #include <core/namespace.h>
24 
25 CORE_BEGIN_NAMESPACE()
26 class IEcs;
27 class IEngine;
28 class IFile;
29 CORE_END_NAMESPACE()
30 
CORE3D_BEGIN_NAMESPACE()31 CORE3D_BEGIN_NAMESPACE()
32 namespace GLTF2 {
33 class Data;
34 
35 /** Describes result of the export operation. */
36 struct ExportResult final {
37     ExportResult() = default;
38     ~ExportResult();
39     ExportResult(ExportResult&&) = default;
40     ExportResult& operator=(ExportResult&&) = default;
41     explicit ExportResult(BASE_NS::string&& error) : success(false), error(error) {}
42     explicit ExportResult(BASE_NS::unique_ptr<Data>&& data) : data(BASE_NS::move(data)) {}
43 
44     /** Indicates, whether the export operation is successful. */
45     bool success { true };
46 
47     /** The description of the error. */
48     BASE_NS::string error;
49 
50     /* Loaded data. */
51     BASE_NS::unique_ptr<Data> data;
52 };
53 
54 void SaveGLB(Data const& data, CORE_NS::IFile& file, BASE_NS::string_view versionString);
55 void SaveGLTF(Data const& data, CORE_NS::IFile& file, BASE_NS::string_view versionString);
56 ExportResult ExportGLTF(CORE_NS::IEngine& engine, const CORE_NS::IEcs& ecs);
57 } // namespace GLTF2
58 CORE3D_END_NAMESPACE()
59 
60 #endif // CORE__GLTF__GLTF2_EXPORTER_H
61