Skip to content

Commit

Permalink
Initial attempt at PtexMetaData find_key/get_key
Browse files Browse the repository at this point in the history
Signed-off-by: matt rice <[email protected]>
  • Loading branch information
ratmice committed Apr 13, 2024
1 parent b5d25c4 commit e44f395
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ptex-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,18 @@ pub mod ffi {
#[namespace = "Ptex::sys"]
unsafe fn ptexmetadata_num_keys(metadata: *const PtexMetaData) -> i32;

/// Get the key, and meta data type for a given `index` from a PtexMetaData pointer.
/// # Safety
/// Must only be called on valid PtexMetaData pointers.
#[namespace = "Ptex::sys"]
unsafe fn ptexmetadata_get_key(metadata: *const PtexMetaData, index: i32, key: *mut *const c_char, typ: *mut MetaDataType);

/// Find the index, and meta data type for a given `key` from a PtexMetaData pointer.
/// Returning `true` if the key is found and `false` otherwise.
/// # Safety
/// Must only be called on valid PtexMetaData pointers.
#[namespace = "Ptex::sys"]
unsafe fn ptexmetadata_find_key(metadata: *const PtexMetaData, key: *const c_char, index: *mut i32, typ: *mut MetaDataType) -> bool;
/// Release a PtexMetaData
/// # Safety
/// This function must be called with a valid PtexMetaData pointer.
Expand Down
14 changes: 14 additions & 0 deletions ptex-sys/src/ptex-sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,20 @@ inline int32_t ptexmetadata_num_keys(PtexMetaData *metadata) {
return (int32_t) metadata->numKeys();
}

inline void ptexmetadata_get_key(PtexMetaData *metadata, int index, const char *& key, MetaDataType& typ) {
if (metadata) {
metadata->getKey(index, key, typ);
}
}

inline bool ptexmetadata_find_key(PtexMetaData *metadata, const char *key, int &index, MetaDataType& typ) {
if (metadata) {
return metadata->findKey(key, index, typ);
} else {
return false;
}
}

inline void ptexmetadata_release(PtexMetaData *metadata) {
if (metadata) {
metadata->release();
Expand Down

0 comments on commit e44f395

Please sign in to comment.