All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderMetadataHelpers.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_USD_SDR_SHADER_METADATA_HELPERS_H
26 #define PXR_USD_SDR_SHADER_METADATA_HELPERS_H
27 
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/sdr/api.h"
32 #include "pxr/base/tf/token.h"
33 #include "pxr/usd/sdr/declare.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
41 namespace ShaderMetadataHelpers
42 {
47  SDR_API
48  bool
49  IsTruthy(const TfToken& propName, const NdrTokenMap& metadata);
50 
53  SDR_API
54  std::string
55  StringVal(const TfToken& propName, const NdrTokenMap& metadata,
56  const std::string& defaultValue = std::string());
57 
60  SDR_API
61  TfToken
62  TokenVal(const TfToken& propName, const NdrTokenMap& metadata,
63  const TfToken& defaultValue = TfToken());
64 
66  SDR_API
67  NdrStringVec
68  StringVecVal(const TfToken& propName, const NdrTokenMap& metadata);
69 
72  SDR_API
73  NdrTokenVec
74  TokenVecVal(const TfToken& propName, const NdrTokenMap& metadata);
75 
77  SDR_API
78  NdrOptionVec
79  OptionVecVal(const std::string& optionStr);
80 
83  SDR_API
84  std::string
85  CreateStringFromStringVec(const NdrStringVec& stringVec);
86 
89  SDR_API
90  bool
91  IsPropertyAnAssetIdentifier(const NdrTokenMap& metadata);
92 
95  SDR_API
96  bool
97  IsPropertyATerminal(const NdrTokenMap& metadata);
98 
100  // if it's a valid role as defined by SdrPropertyRole tokens.
101  SDR_API
102  TfToken
103  GetRoleFromMetadata(const NdrTokenMap& metadata);
104 }
105 
106 PXR_NAMESPACE_CLOSE_SCOPE
107 
108 #endif // PXR_USD_SDR_SHADER_METADATA_HELPERS_H
SDR_API std::string StringVal(const TfToken &propName, const NdrTokenMap &metadata, const std::string &defaultValue=std::string())
Extracts the string value from the given property if it exists, otherwise returns defaultValue...
SDR_API NdrStringVec StringVecVal(const TfToken &propName, const NdrTokenMap &metadata)
Extracts a vector of strings from the given property.
SDR_API NdrTokenVec TokenVecVal(const TfToken &propName, const NdrTokenMap &metadata)
Extracts a vector of tokenized values from the given property.
SDR_API NdrOptionVec OptionVecVal(const std::string &optionStr)
Extracts an "options" vector from the given string.
SDR_API bool IsPropertyAnAssetIdentifier(const NdrTokenMap &metadata)
Determines if the specified property metadata has a widget that indicates the property is an asset id...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDR_API bool IsTruthy(const TfToken &propName, const NdrTokenMap &metadata)
Determines if the given property in the metadata dictionary has a truthy value.
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.
SDR_API TfToken TokenVal(const TfToken &propName, const NdrTokenMap &metadata, const TfToken &defaultValue=TfToken())
Extracts the tokenized value from the given property.
SDR_API bool IsPropertyATerminal(const NdrTokenMap &metadata)
Determines if the specified property metadata has a 'renderType' that indicates the property should b...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...