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 SDR_SHADERMETADATAHELPERS_H
26 #define SDR_SHADERMETADATAHELPERS_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 
52  SDR_API
53  const std::string&
54  StringVal(const TfToken& propName, const NdrTokenMap& metadata);
55 
58  SDR_API
59  const std::string&
60  StringVal(const TfToken& propName, const NdrTokenMap& metadata,
61  const std::string& defaultValue);
62 
65  SDR_API
66  TfToken
67  TokenVal(const TfToken& propName, const NdrTokenMap& metadata,
68  const TfToken& defaultValue = TfToken());
69 
71  SDR_API
72  NdrStringVec
73  StringVecVal(const TfToken& propName, const NdrTokenMap& metadata);
74 
77  SDR_API
78  NdrTokenVec
79  TokenVecVal(const TfToken& propName, const NdrTokenMap& metadata);
80 
82  SDR_API
83  NdrOptionVec
84  OptionVecVal(const std::string& optionStr);
85 
88  SDR_API
89  std::string
90  CreateStringFromStringVec(const NdrStringVec& stringVec);
91 
94  SDR_API
95  bool
96  IsPropertyAnAssetIdentifier(const NdrTokenMap& metadata);
97 
100  SDR_API
101  bool
102  IsPropertyATerminal(const NdrTokenMap& metadata);
103 
105  // if it's a valid role as defined by SdrPropertyRole tokens.
106  SDR_API
107  TfToken
108  GetRoleFromMetadata(const NdrTokenMap& metadata);
109 }
110 
111 PXR_NAMESPACE_CLOSE_SCOPE
112 
113 #endif // SDR_SHADERMETADATAHELPERS_H
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 const std::string & StringVal(const TfToken &propName, const NdrTokenMap &metadata)
Extracts the string value from the given property.
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:89
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...