21#ifndef OCCTL_HPP_DE_HPP
22#define OCCTL_HPP_DE_HPP
43 std::vector<std::string> extensions;
44 bool can_read_file =
false;
45 bool can_write_file =
false;
46 bool can_read_memory =
false;
47 bool can_write_memory =
false;
52inline std::pair<Graph, NodeId>
read(
const std::string& thePath)
62inline std::pair<Graph, NodeId>
read_memory(
const std::string& theFormatId,
63 const uint8_t*
const theData,
64 const std::size_t theSize)
74inline std::pair<Graph, NodeId>
read_memory(
const std::string& theFormatId,
75 const std::vector<uint8_t>& theData)
77 return read_memory(theFormatId, theData.empty() ?
nullptr : theData.data(), theData.size());
81inline void write(
const Graph& theGraph,
const NodeId theRoot,
const std::string& thePath)
90 const std::string& theFormatId)
92 std::size_t aSize = 0;
100 std::vector<uint8_t> aData(aSize);
104 aData.empty() ?
nullptr : aData.data(),
115 std::vector<const char*> aIds(aCount);
118 std::vector<std::string> aOut;
120 for (
size_t i = 0; i < aGot; ++i)
122 aOut.emplace_back(aIds[i]);
133 std::vector<FormatInfo> aOut;
134 aOut.reserve(aCount);
135 for (
size_t anIndex = 0; anIndex < aCount; ++anIndex)
140 size_t anExtCount = 0;
142 std::vector<const char*> aExts(anExtCount);
147 anInfo.id = aRaw.
id !=
nullptr ? aRaw.
id :
"";
148 anInfo.label = aRaw.
label !=
nullptr ? aRaw.
label :
"";
153 anInfo.extensions.reserve(anExtGot);
154 for (
size_t anExtIndex = 0; anExtIndex < anExtGot; ++anExtIndex)
156 anInfo.extensions.emplace_back(aExts[anExtIndex]);
158 aOut.emplace_back(std::move(anInfo));
169 size_t anExtCount = 0;
171 std::vector<const char*> aExts(anExtCount);
176 anInfo.id = aRaw.
id !=
nullptr ? aRaw.
id :
"";
177 anInfo.label = aRaw.
label !=
nullptr ? aRaw.
label :
"";
182 anInfo.extensions.reserve(anExtGot);
183 for (
size_t anExtIndex = 0; anExtIndex < anExtGot; ++anExtIndex)
185 anInfo.extensions.emplace_back(aExts[anExtIndex]);
193 const char* aId =
nullptr;
199 return std::string(aId);
RAII handle for a topology graph. Mirrors occtl_graph_t.
Definition topo.hpp:1444
::occtl_graph_t * get() const noexcept
Borrows-it pointer to the underlying C handle, for direct ABI calls.
Definition topo.hpp:1494
Session-local identity of a graph node. Mirrors occtl_node_id_t.
Definition topo.hpp:52
::occtl_node_id_t get() const noexcept
Borrows-it view of the underlying C value type, for direct ABI calls.
Definition topo.hpp:64
C++ veneer for the core module.
void check(const ::occtl_status_t theStatus)
Throw on non-OK; otherwise a no-op.
Definition core.hpp:85
std::pair< Graph, NodeId > read_memory(const std::string &theFormatId, const uint8_t *const theData, const std::size_t theSize)
Reads a memory payload using an explicit format id and returns (graph, root).
Definition de.hpp:62
FormatInfo format_info(const std::string &theFormatId)
Returns a descriptor for one supported data-exchange format.
Definition de.hpp:164
std::vector< uint8_t > write_memory(const Graph &theGraph, const NodeId theRoot, const std::string &theFormatId)
Writes a graph root into a memory payload using an explicit format id.
Definition de.hpp:88
void write(const Graph &theGraph, const NodeId theRoot, const std::string &thePath)
Writes a graph root to a file dispatched by extension.
Definition de.hpp:81
std::vector< FormatInfo > format_infos()
Returns rich descriptors for every supported data-exchange format.
Definition de.hpp:128
std::pair< Graph, NodeId > read(const std::string &thePath)
Reads a file dispatched by extension and returns (graph, root).
Definition de.hpp:52
std::optional< std::string > format_id_for_path(const std::string &thePath)
Returns the format id for thePath, or std::nullopt if no extension matches.
Definition de.hpp:191
std::vector< std::string > supported_formats()
Returns the stable lowercase format ids the build supports.
Definition de.hpp:111
OCCT-Light: unified data-exchange dispatch.
occtl_status_t occtl_de_format_ids(const char **out_format_ids, size_t cap, size_t *out_count)
occtl_status_t occtl_de_format_extensions(const char *format_id, const char **out_extensions, size_t cap, size_t *out_count)
occtl_status_t occtl_de_read(const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root)
occtl_status_t occtl_de_format_info_at(size_t index, occtl_de_format_info_t *out_info)
occtl_status_t occtl_de_format_id_from_path(const char *path, const char **out_format_id)
occtl_status_t occtl_de_format_info_by_id(const char *format_id, occtl_de_format_info_t *out_info)
occtl_status_t occtl_de_write_memory(const occtl_graph_t *graph, occtl_node_id_t root, const char *format_id, uint8_t *out_data, size_t capacity, size_t *out_size)
occtl_status_t occtl_de_read_memory(const char *format_id, const uint8_t *data, size_t size, occtl_graph_t **out_graph, occtl_node_id_t *out_root)
occtl_status_t occtl_de_write(const occtl_graph_t *graph, occtl_node_id_t root, const char *path)
#define OCCTL_DE_FORMAT_INFO_INIT
Definition occtl_de.h:73
occtl_status_t occtl_de_format_count(size_t *out_count)
struct occtl_graph occtl_graph_t
Definition occtl_topo_types.h:152
Definition occtl_topo_types.h:50
C++ veneer for the topo module.