Loading...
Searching...
No Matches
shaderMetadataHelpers.h
Go to the documentation of this file.
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_SDR_SHADER_METADATA_HELPERS_H
9#define PXR_USD_SDR_SHADER_METADATA_HELPERS_H
10
12
13#include "pxr/pxr.h"
14#include "pxr/usd/sdr/api.h"
15#include "pxr/base/tf/token.h"
16#include "pxr/usd/sdr/declare.h"
17
18#include <limits>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
27{
32 SDR_API
33 bool
34 IsTruthy(const TfToken& key, const NdrTokenMap& metadata);
35
38 SDR_API
39 std::string
40 StringVal(const TfToken& key, const NdrTokenMap& metadata,
41 const std::string& defaultValue = std::string());
42
45 SDR_API
47 TokenVal(const TfToken& key, const NdrTokenMap& metadata,
48 const TfToken& defaultValue = TfToken());
49
52 SDR_API
53 int
54 IntVal(const TfToken& key, const NdrTokenMap& metadata,
55 int defaultValue = std::numeric_limits<int>::max());
56
59 SDR_API
60 NdrStringVec
61 StringVecVal(const TfToken& key, const NdrTokenMap& metadata);
62
65 SDR_API
66 NdrTokenVec
67 TokenVecVal(const TfToken& key, const NdrTokenMap& metadata);
68
70 SDR_API
71 NdrOptionVec
72 OptionVecVal(const std::string& optionStr);
73
76 SDR_API
77 std::string
78 CreateStringFromStringVec(const NdrStringVec& stringVec);
79
82 SDR_API
83 bool
84 IsPropertyAnAssetIdentifier(const NdrTokenMap& metadata);
85
88 SDR_API
89 bool
90 IsPropertyATerminal(const NdrTokenMap& metadata);
91
93 // if it's a valid role as defined by SdrPropertyRole tokens.
94 SDR_API
96 GetRoleFromMetadata(const NdrTokenMap& metadata);
97}
98
99PXR_NAMESPACE_CLOSE_SCOPE
100
101#endif // PXR_USD_SDR_SHADER_METADATA_HELPERS_H
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Various utilities for parsing metadata contained within shaders.
SDR_API int IntVal(const TfToken &key, const NdrTokenMap &metadata, int defaultValue=std::numeric_limits< int >::max())
Extracts the int value from the given metadatum if it exists and is a valid integer value,...
SDR_API std::string StringVal(const TfToken &key, const NdrTokenMap &metadata, const std::string &defaultValue=std::string())
Extracts the string value from the given metadatum if it exists, otherwise returns defaultValue.
SDR_API bool IsPropertyAnAssetIdentifier(const NdrTokenMap &metadata)
Determines if the specified property metadata has a widget that indicates the property is an asset id...
SDR_API TfToken TokenVal(const TfToken &key, const NdrTokenMap &metadata, const TfToken &defaultValue=TfToken())
Extracts the tokenized value from the given metadatum if it exists, otherwise returns defaultValue.
SDR_API NdrOptionVec OptionVecVal(const std::string &optionStr)
Extracts an "options" vector from the given string.
SDR_API bool IsTruthy(const TfToken &key, const NdrTokenMap &metadata)
Determines if the given metadatum in the metadata dictionary has a truthy value.
SDR_API NdrStringVec StringVecVal(const TfToken &key, const NdrTokenMap &metadata)
Extracts a vector of strings from the given metadatum.
SDR_API bool IsPropertyATerminal(const NdrTokenMap &metadata)
Determines if the specified property metadata has a 'renderType' that indicates the property should b...
SDR_API NdrTokenVec TokenVecVal(const TfToken &key, const NdrTokenMap &metadata)
Extracts a vector of tokenized values from the given metadatum.
SDR_API TfToken GetRoleFromMetadata(const NdrTokenMap &metadata)
Gets the "role" from metadata if one is provided. Only returns a value.
SDR_API std::string CreateStringFromStringVec(const NdrStringVec &stringVec)
Serializes a vector of strings into a string using the pipe character as the delimiter.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...