Files
test/source/blender/imbuf/IMB_metadata.hh
Brecht Van Lommel 920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00

63 lines
2.1 KiB
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup imbuf
*/
#pragma once
#include <cstddef>
struct IDProperty;
struct ImBuf;
/**
* The metadata is a list of key/value pairs (both char *) that can me
* saved in the header of several image formats.
* Apart from some common keys like
* 'Software' and 'Description' (PNG standard) we'll use keys within the
* Blender namespace, so should be called 'Blender::StampInfo' or 'Blender::FrameNum'
* etc...
*
* The keys & values are stored in ID properties, in the group "metadata".
*/
/**
* Ensure that the metadata property is a valid #IDProperty object.
* This is a no-op when *metadata != NULL.
*/
void IMB_metadata_ensure(IDProperty **metadata);
void IMB_metadata_free(IDProperty *metadata);
/**
* Read the field from the image info into the field.
* \param metadata: the #IDProperty that contains the metadata
* \param key: the key of the field
* \param value: the data in the field, first one found with key is returned,
* memory has to be allocated by user.
* \param len: length of value buffer allocated by user.
* \return 1 (true) if metadata is present and value for the key found, 0 (false) otherwise.
*/
bool IMB_metadata_get_field(const IDProperty *metadata,
const char *key,
char *value,
size_t value_maxncpy);
/**
* Set user data in the metadata.
* If the field already exists its value is overwritten, otherwise the field
* will be added with the given value.
* \param metadata: the #IDProperty that contains the metadata
* \param key: the key of the field
* \param value: the data to be written to the field. zero terminated string
*/
void IMB_metadata_set_field(IDProperty *metadata, const char *key, const char *value);
void IMB_metadata_copy(ImBuf *ibuf_dst, const ImBuf *ibuf_src);
/* Invoke callback for every value stored in the metadata. */
using IMBMetadataForeachCb = void (*)(const char *field, const char *value, void *userdata);
void IMB_metadata_foreach(ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata);