HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_HprUri.h
Go to the documentation of this file.
1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_HprURI.h ( UT Library, C++)
7  *
8  * COMMENTS: Class representing HPR paths and methods to extract info
9  * and resolve to filesystem locations. Also handles versioning
10  * and some utility methods for looking up versions, etc.
11  */
12 
13 #ifndef __UT_HPRURI_H__
14 #define __UT_HPRURI_H__
15 
16 #include "FS_API.h"
17 #include "UT_ShotBuilderConfig.h"
18 #include <UT/UT_StringMap.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_StringArray.h>
21 
22 #define HPR_SIGNATURE "hpr:"
23 #define HPR_SIGNATURE_LEN 4
24 #define HPR_SIGNATURE_NO_COLON "hpr"
25 #define HPR_SIGNATURE_NO_COLON_LEN 3
26 #define HPR_PLACEHOLDER_VERSION 0
27 #define HPR_PLACEHOLDER_VERSION_STR "0"
28 
30 {
31 public:
32  UT_HprUri(const UT_StringHolder&);
33 
34  UT_StringHolder uri() const;
36  { return myUri; }
37  bool isValid() const
38  { return myIsValid; }
40  { return myName; }
42  { return myExtension; }
44  { return myDirectory; }
45  bool isVersionSet() const
46  { return myArgs.find("v") != myArgs.end(); }
48  { return myArgs.get("v", getPlaceHolderVersion()); }
49 
50  void setVersion(const UT_StringHolder &version);
51  void setVersion(int version)
52  { setVersion((std::to_string(version).c_str())); }
53 
54  int latestVersion() const;
55  int nextVersion() const;
56  UT_IntArray versions() const;
57 
58  // newAsset will only be considered if there is no version specified
59  // in the uri.
60  UT_StringHolder resolvedPath(bool newAsset=false);
61 
62  static const UT_StringHolder &getPlaceHolderVersion();
63 
64 private:
65  // Return the full on-disk directory path based on this Uri. If this Uri
66  // represents a versioned file, this will include the name.ext suffix
67  // (because that's part of the on-disk directory).
68  UT_StringHolder _directory() const;
69  UT_StringHolder _versionFormat() const;
70  UT_StringHolder _fileOrDirName(bool newAsset=false) const;
71  int _resolveVersion(bool newAsset=false) const;
72 
73  UT_StringHolder myUri;
74  UT_StringHolder myDirectory;
75  UT_StringHolder myName;
76  UT_StringHolder myExtension;
78  UT_StringHolder myResolvedPath;
79  bool myIsValid = false;
80  bool myIsAbsolute = false;
81  bool myIsVersioned = false;
82  bool myLastResolvedForNewAsset = false;
83 
84  // TODO: do we need a way to set the project path on the config?
85  UT_ShotBuilderConfig myConfig;
86 };
87 
88 #endif
UT_StringHolder name() const
Definition: UT_HprUri.h:39
auto to_string(const T &value) -> std::string
Definition: format.h:4527
UT_StringHolder path() const
Definition: UT_HprUri.h:43
bool isVersionSet() const
Definition: UT_HprUri.h:45
OPENVDB_API void setVersion(std::ios_base &, const VersionId &libraryVersion, uint32_t fileVersion)
Associate specific file format and library version numbers with the given stream. ...
UT_StringHolder extension() const
Definition: UT_HprUri.h:41
bool isValid() const
Definition: UT_HprUri.h:37
GT_API const UT_StringHolder version
UT_StringHolder version() const
Definition: UT_HprUri.h:47
void setVersion(int version)
Definition: UT_HprUri.h:51
OIIO_UTIL_API const char * c_str(string_view str)
UT_StringHolder baseUri() const
Definition: UT_HprUri.h:35
#define FS_API
Definition: FS_API.h:10