HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
crateInfo.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_CRATE_INFO_H
8 #define PXR_USD_USD_CRATE_INFO_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/usd/api.h"
12 #include "pxr/base/tf/token.h"
13 
14 #include <cstddef>
15 #include <cstdint>
16 #include <memory>
17 #include <string>
18 #include <vector>
19 
21 
22 
23 /// \class UsdCrateInfo
24 ///
25 /// A class for introspecting the underlying qualities of .usdc 'crate' files,
26 /// for diagnostic purposes.
27 ///
29 {
30 public:
31  struct Section {
32  Section() = default;
33  Section(std::string const &name, int64_t start, int64_t size)
34  : name(name), start(start), size(size) {}
35  std::string name;
36  int64_t start = -1, size = -1;
37  };
38 
39  struct SummaryStats {
40  size_t numSpecs = 0;
41  size_t numUniquePaths = 0;
42  size_t numUniqueTokens = 0;
43  size_t numUniqueStrings = 0;
44  size_t numUniqueFields = 0;
45  size_t numUniqueFieldSets = 0;
46  };
47 
48  /// Attempt to open and read \p fileName.
49  USD_API
50  static UsdCrateInfo Open(std::string const &fileName);
51 
52  /// Return summary statistics structure for this file.
53  USD_API
55 
56  /// Return the named file sections, their location and sizes in the file.
57  USD_API
58  std::vector<Section> GetSections() const;
59 
60  /// Return the file version.
61  USD_API
62  TfToken GetFileVersion() const;
63 
64  /// Return the software version.
65  USD_API
67 
68  /// Return true if this object refers to a valid file.
69  explicit operator bool() const { return (bool)_impl; }
70 
71 private:
72 
73  struct _Impl;
74  std::shared_ptr<_Impl> _impl;
75 };
76 
77 
79 
80 #endif // PXR_USD_USD_CRATE_INFO_H
static USD_API UsdCrateInfo Open(std::string const &fileName)
Attempt to open and read fileName.
#define USD_API
Definition: api.h:23
GLuint start
Definition: glcorearb.h:475
std::string name
Definition: crateInfo.h:35
OutGridT const XformOp bool bool
Section(std::string const &name, int64_t start, int64_t size)
Definition: crateInfo.h:33
Definition: token.h:70
USD_API SummaryStats GetSummaryStats() const
Return summary statistics structure for this file.
GLuint const GLchar * name
Definition: glcorearb.h:786
USD_API TfToken GetSoftwareVersion() const
Return the software version.
GLsizeiptr size
Definition: glcorearb.h:664
USD_API std::vector< Section > GetSections() const
Return the named file sections, their location and sizes in the file.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USD_API TfToken GetFileVersion() const
Return the file version.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74