70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "foundation/result.h"
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <span>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace pp::assets {
|
|
|
|
constexpr std::size_t ppbr_header_size = 8;
|
|
constexpr std::uint16_t ppbr_legacy_major_version = 0;
|
|
constexpr std::uint16_t ppbr_legacy_minor_version = 1;
|
|
|
|
enum class PpbrDataDirectoryPolicy {
|
|
next_to_package,
|
|
override_directory,
|
|
};
|
|
|
|
enum class BrushPackageImageKind {
|
|
brush_tip,
|
|
pattern,
|
|
};
|
|
|
|
struct PpbrHeader {
|
|
std::uint16_t major = 0;
|
|
std::uint16_t minor = 0;
|
|
};
|
|
|
|
struct BrushPackageImageTargetPaths {
|
|
std::string image_path;
|
|
std::string thumbnail_path;
|
|
};
|
|
|
|
struct PpbrExportPaths {
|
|
std::string package_path;
|
|
std::string directory;
|
|
std::string stem;
|
|
std::string extension;
|
|
std::string data_directory;
|
|
bool data_directory_enabled = false;
|
|
};
|
|
|
|
[[nodiscard]] pp::foundation::Status validate_ppbr_header(
|
|
std::string_view magic,
|
|
std::uint16_t major,
|
|
std::uint16_t minor) noexcept;
|
|
|
|
[[nodiscard]] pp::foundation::Result<PpbrHeader> parse_ppbr_header(
|
|
std::span<const std::byte> bytes) noexcept;
|
|
|
|
[[nodiscard]] pp::foundation::Result<std::string> normalize_ppbr_export_path(
|
|
std::string_view requested_path);
|
|
|
|
[[nodiscard]] pp::foundation::Result<PpbrExportPaths> plan_ppbr_export_paths(
|
|
std::string_view requested_path,
|
|
std::string_view override_data_directory,
|
|
bool export_data,
|
|
PpbrDataDirectoryPolicy data_directory_policy);
|
|
|
|
[[nodiscard]] pp::foundation::Result<BrushPackageImageTargetPaths> plan_brush_package_image_target_paths(
|
|
std::string_view data_path,
|
|
BrushPackageImageKind kind,
|
|
std::string_view image_name,
|
|
std::string_view image_extension);
|
|
|
|
} // namespace pp::assets
|