Skip to content

Engine → Assets → asset_importer.h

import_context

Syntax

class CONJURE_API import_context

Constructors

AccessSignatureDescription
publicimport_context( core::vfs::file_system &fileSystem, std::string assetPath, std::string filePath, std::span<const std::byte> sourceBytes, core::json::value settings, std::string platform, const asset_id &primaryId, sub_asset_table &subAssets, asset_path_resolver resolver);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~import_context();

Variables

AccessNameTypeDefaultDescription
privatemAssetPathstd::string{}
privatemFilePathstd::string{}
privatemFileSystemcore::vfs::file_system *nullptr
privatemPlatformstd::string{}
privatemPrimaryIdasset_id{}
privatemResolverasset_path_resolver{}
privatemSettingscore::json::value{}
privatemSideFilesstd::vector<std::string>{}
privatemSourceBytesstd::span<const std::byte>{}
privatemSubAssetssub_asset_table *nullptr
privatemWarningsstd::vector<std::string>{}

Functions

Public

add_warning

void add_warning(
    std::string message);

Records a non-fatal message that ends up in the import report and the import log.

find_asset_by_path

[[nodiscard]] std::optional<asset_id> find_asset_by_path(
    std::string_view path) const;

Uuid of another source of the project by asset path ("assets://textures/a.png") or by a path relative to this source's directory ("textures/a.png").

platform

[[nodiscard]] std::string_view platform() const noexcept;

Target platform: "windows", "linux" or "macos".

primary_id

[[nodiscard]] const asset_id &primary_id() const noexcept;

Uuid of the primary asset (the source file itself).

read_side_file

[[nodiscard]] core::result<std::vector<std::byte>> read_side_file(
    std::string_view relativePath);

Reads a file next to the source (relative to the source's directory) and records it as a side file (even when the read fails, so a missing side file is watched): hashed into the source hash and watched for changes.

settings

[[nodiscard]] const core::json::value &settings() const noexcept;

The importer settings from the .meta (an object; invalid when the meta had none).

side_files

[[nodiscard]] std::span<const std::string> side_files() const noexcept;

Asset paths of every side file asked for so far, including ones that could not be read.

source_bytes

[[nodiscard]] std::span<const std::byte> source_bytes() const noexcept;

The whole source file.

source_path

[[nodiscard]] std::string_view source_path() const noexcept;

The source's asset path, "assets://models/robot.gltf".

sub_asset_id

[[nodiscard]] asset_id sub_asset_id(
    std::string_view subPath);

Stable uuid for a named sub-asset; allocated on first use, persisted to the meta.

warnings

[[nodiscard]] std::span<const std::string> warnings() const noexcept;