HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packageUtils.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 #ifndef PXR_USD_AR_PACKAGE_UTILS_H
25 #define PXR_USD_AR_PACKAGE_UTILS_H
26 
27 /// \file ar/packageUtils.h
28 /// Utility functions for working with package assets
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/ar/api.h"
32 
33 #include <string>
34 #include <vector>
35 
37 
38 // --------------------------------------------------------------------- //
39 /// \anchor Ar_packagePaths
40 /// \name Package Relative Paths
41 ///
42 /// Assets within package assets can be addressed via "package-relative"
43 /// paths. For example, given a hypothetical package <tt>"Model.package"</tt>,
44 /// the asset <tt>"Geom.file"</tt>, can be referred to using the path
45 /// <tt>"Model.package[Geom.file]"</tt>.
46 ///
47 /// A package-relative path consists of two parts:
48 ///
49 /// - The outer "package" path is the path to the containing package asset.
50 /// This path can be whatever is appropriate to the client's asset system.
51 ///
52 /// - The inner "packaged" path is the path to an asset contained within the
53 /// package asset. This path must be a relative path delimited by forward
54 /// slashes '/', with no leading slashes or drive or device letters. Note
55 /// that packaged paths may themselves be package-relative paths, since
56 /// package assets may be nested.
57 ///
58 /// Examples:
59 /// - <tt>/path/to/Model.package[a/b/Geom.file]</tt>
60 /// - <tt>/path/to/Model.package[a/b/Sub.package[c/d/Geom.file]]</tt>
61 ///
62 /// @{
63 // --------------------------------------------------------------------- //
64 
65 /// Return true if \p path is a package-relative path, false otherwise.
66 AR_API
67 bool
69 
70 /// Combines the given \p paths into a single package-relative path, nesting
71 /// paths as necessary.
72 ///
73 /// \code
74 /// ArJoinPackageRelativePath(["a.pack", "b.pack"])
75 /// => "a.pack[b.pack]"
76 ///
77 /// ArJoinPackageRelativePath(["a.pack", "b.pack", "c.pack"])
78 /// => "a.pack[b.pack[c.pack]]"
79 ///
80 /// ArJoinPackageRelativePath(["a.pack[b.pack]", "c.pack"])
81 /// => "a.pack[b.pack[c.pack]]"
82 /// \endcode
83 AR_API
85 ArJoinPackageRelativePath(const std::vector<std::string>& paths);
86 
87 /// \overload
88 AR_API
90 ArJoinPackageRelativePath(const std::pair<std::string, std::string>& paths);
91 
92 /// \overload
93 AR_API
96  const std::string& packagePath, const std::string& packagedPath);
97 
98 /// Split package-relative path \p path into a (package path, packaged path)
99 /// pair. If \p packageRelativePath contains nested package-relative paths
100 /// the package path will be the outermost package path, and the packaged path
101 /// will be the inner package-relative path.
102 ///
103 /// \code
104 /// ArSplitPackageRelativePathOuter("a.pack[b.pack]")
105 /// => ("a.pack", "b.pack")
106 ///
107 /// ArSplitPackageRelativePathOuter("a.pack[b.pack[c.pack]]")
108 /// => ("a.pack", "b.pack[c.pack]")
109 /// \endcode
110 AR_API
111 std::pair<std::string, std::string>
113 
114 /// Split package-relative path \p path into a (package path, packaged path)
115 /// pair. If \p packageRelativePath contains nested package-relative paths
116 /// the package path will be the outermost package-relative path, and the
117 /// packaged path will be the innermost packaged path.
118 ///
119 /// \code
120 /// ArSplitPackageRelativePathInner("a.pack[b.pack]")
121 /// => ("a.pack", "b.pack")
122 ///
123 /// ArSplitPackageRelativePathInner("a.pack[b.pack[c.pack]]")
124 /// => ("a.pack[b.pack]", "c.pack")
125 /// \endcode
126 AR_API
127 std::pair<std::string, std::string>
129 
130 /// @}
131 
133 
134 #endif // PXR_USD_AR_PACKAGE_UTILS_H
AR_API std::pair< std::string, std::string > ArSplitPackageRelativePathOuter(const std::string &path)
AR_API std::pair< std::string, std::string > ArSplitPackageRelativePathInner(const std::string &path)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
AR_API std::string ArJoinPackageRelativePath(const std::vector< std::string > &paths)
#define AR_API
Definition: api.h:40
AR_API bool ArIsPackageRelativePath(const std::string &path)
Return true if path is a package-relative path, false otherwise.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91