yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
graphics_scratch_storage.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_SCRATCH_STORAGE_H_
2#define YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_SCRATCH_STORAGE_H_
3
4#include <cstddef>
5#include <functional>
6#include <optional>
7#include <string>
8#include <vector>
9
10#include "absl/status/statusor.h"
12
14
17 // Missing is distinct from an unreadable or malformed existing library.
18 std::optional<std::string> bytes;
19};
20
21absl::StatusOr<LibrarySnapshot> LoadLibrary(const std::string& path);
22// Locks, compares the complete last-read bytes, and publishes atomically.
23// Returns the exact serialized bytes only after a successful disk write.
24absl::StatusOr<std::string> SaveLibrary(
25 const std::string& path, const GraphicsScratchLibrary& library,
26 const std::optional<std::string>& expected_bytes);
27
28absl::StatusOr<GraphicsScratchAsset> ImportBin(const std::string& path, int bpp,
29 size_t offset,
30 const std::string& name);
31
33 bool same_source = false;
34 std::vector<uint8_t> published_chunk;
35};
36
37// A same-source export validates and replaces the recorded chunk in its
38// container. Other destinations receive a standalone chunk. The publication
39// lock is released before returning, so callers may save their library next.
40absl::StatusOr<BinExportResult> ExportBin(
41 const GraphicsScratchAsset& asset, const std::string& path,
42 const std::string& library_path,
43 const std::function<absl::Status(const std::string&)>& validator = {});
44
45} // namespace yaze::editor::graphics_scratch_storage
46
47#endif // YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_SCRATCH_STORAGE_H_
absl::StatusOr< LibrarySnapshot > LoadLibrary(const std::string &path)
absl::StatusOr< BinExportResult > ExportBin(const GraphicsScratchAsset &asset, const std::string &path, const std::string &library_path, const std::function< absl::Status(const std::string &)> &validator)
absl::StatusOr< std::string > SaveLibrary(const std::string &path, const GraphicsScratchLibrary &library, const std::optional< std::string > &expected_bytes)
absl::StatusOr< GraphicsScratchAsset > ImportBin(const std::string &path, int bpp, size_t offset, const std::string &name)