up-to-date submodule(rive-cpp)
[platform/core/uifw/rive-tizen.git] / submodule / include / file.hpp
1 #ifndef _RIVE_FILE_HPP_
2 #define _RIVE_FILE_HPP_
3
4 #include "artboard.hpp"
5 #include "backboard.hpp"
6 #include "core/binary_reader.hpp"
7 #include "runtime_header.hpp"
8 #include <vector>
9
10 ///
11 /// Default namespace for Rive Cpp runtime code.
12 ///
13 namespace rive
14 {
15         ///
16         /// Tracks the success/failure result when importing a Rive file.
17         ///
18         enum class ImportResult
19         {
20                 /// Indicates that a file's been successfully imported.
21                 success,
22                 /// Indicates that the Rive file is not supported by this runtime.
23                 unsupportedVersion,
24                 /// Indicates that the there is a formatting problem in the file itself.
25                 malformed
26         };
27
28         ///
29         /// A Rive file.
30         ///
31         class File
32         {
33         public:
34                 /// Major version number supported by the runtime.
35                 static const int majorVersion = 7;
36                 /// Minor version number supported by the runtime.
37                 static const int minorVersion = 0;
38
39         private:
40                 /// The file's backboard. All Rive files have a single backboard
41                 /// where the artboards live.
42                 Backboard* m_Backboard = nullptr;
43
44                 /// List of artboards in the file. Each artboard encapsulates a set of
45                 /// Rive components and animations.
46                 std::vector<Artboard*> m_Artboards;
47
48         public:
49                 ~File();
50
51                 ///
52                 /// Imports a Rive file from a binary buffer.
53                 /// @param reader a pointer to a binary reader attached to the file.
54                 /// @param importedFile a handle to a file that will contain the
55                 /// imported data.
56                 /// @returns whether the import was successful or an error occurred.
57                 static ImportResult import(BinaryReader& reader, File** importedFile);
58
59                 /// @returns the file's backboard. All files have exactly one backboard.
60                 Backboard* backboard() const;
61
62                 /// @returns the default artboard. This is typically the first artboard
63                 /// found in the file's artboard list.
64                 Artboard* artboard() const;
65
66                 /// @returns the named artboard. If no artboard is found with that name,
67                 /// the null pointer is returned
68                 Artboard* artboard(std::string name) const;
69
70         private:
71                 ImportResult read(BinaryReader& reader, const RuntimeHeader& header);
72         };
73 } // namespace rive
74 #endif