1 #ifndef _RIVE_FILE_HPP_
2 #define _RIVE_FILE_HPP_
4 #include "artboard.hpp"
5 #include "backboard.hpp"
6 #include "core/binary_reader.hpp"
7 #include "runtime_header.hpp"
11 /// Default namespace for Rive Cpp runtime code.
16 /// Tracks the success/failure result when importing a Rive file.
18 enum class ImportResult
20 /// Indicates that a file's been successfully imported.
22 /// Indicates that the Rive file is not supported by this runtime.
24 /// Indicates that the there is a formatting problem in the file itself.
34 /// Major version number supported by the runtime.
35 static const int majorVersion = 6;
36 /// Minor version number supported by the runtime.
37 static const int minorVersion = 3;
40 /// The file's backboard. All Rive files have a single backboard
41 /// where the artboards live.
42 Backboard* m_Backboard = nullptr;
44 /// List of artboards in the file. Each artboard encapsulates a set of
45 /// Rive components and animations.
46 std::vector<Artboard*> m_Artboards;
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
56 /// @returns whether the import was successful or an error occurred.
57 static ImportResult import(BinaryReader& reader, File** importedFile);
59 /// @returns the file's backboard. All files have exactly one backboard.
60 Backboard* backboard() const;
62 /// @returns the default artboard. This is typically the first artboard
63 /// found in the file's artboard list.
64 Artboard* artboard() const;
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;
71 ImportResult read(BinaryReader& reader, const RuntimeHeader& header);