All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flag.h
1 //
2 // Copyright 2019 Google LLC
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 USDDRACO_FLAG_H
26 #define USDDRACO_FLAG_H
27 
28 
29 PXR_NAMESPACE_OPEN_SCOPE
30 
31 
37 template <class T>
38 class UsdDracoFlag {
39 public:
40  UsdDracoFlag() : _specified(false), _value() {}
41  UsdDracoFlag(const T &value) : _specified(true), _value(value) {}
42  bool HasValue() const { return _specified; }
43  const T &GetValue() const { return _value; }
44  static UsdDracoFlag<bool> MakeBooleanFlag(int value) {
45  // The value can be 0 (false), 1 (true), and -1 (unspecified).
46  if (value == 0 || value == 1)
47  return UsdDracoFlag<bool>(value);
48  return UsdDracoFlag<bool>();
49  }
50 
51 private:
52  const bool _specified;
53  const T _value;
54 };
55 
56 
57 PXR_NAMESPACE_CLOSE_SCOPE
58 
59 #endif // USDDRACO_FLAG_H
Stores command-line flag value and whether it has been explicitly specified by the user...
Definition: flag.h:38