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;
35  bool isValid() const
36  { return myIsValid; }
38  { return myName; }
40  { return myExtension; }
42  { return myDirectory; }
43  bool isVersionSet() const
44  { return myArgs.find("v") != myArgs.end(); }
46  { return myArgs.get("v", getPlaceHolderVersion()); }
47 
48  void setVersion(const UT_StringHolder &version);
49  void setVersion(int version)
50  { setVersion((std::to_string(version).c_str())); }
51 
52  int latestVersion() const;
53  int nextVersion() const;
54  UT_IntArray versions() const;
55 
56  // newAsset will only be considered if there is no version specified
57  // in the uri.
58  UT_StringHolder resolvedPath(bool newAsset=false);
59 
60  static const UT_StringHolder &getPlaceHolderVersion();
61 
62 private:
63  // Return the full on-disk directory path based on this Uri. If this Uri
64  // represents a versioned file, this will include the name.ext suffix
65  // (because that's part of the on-disk directory).
66  UT_StringHolder _directory() const;
67  UT_StringHolder _versionFormat() const;
68  UT_StringHolder _fileOrDirName(bool newAsset=false) const;
69  int _resolveVersion(bool newAsset=false) const;
70 
71  UT_StringHolder myUri;
72  UT_StringHolder myDirectory;
73  UT_StringHolder myName;
74  UT_StringHolder myExtension;
76  UT_StringHolder myResolvedPath;
77  bool myIsValid = false;
78  bool myIsAbsolute = false;
79  bool myIsVersioned = false;
80  bool myLastResolvedForNewAsset = false;
81 
82  // TODO: do we need a way to set the project path on the config?
83  UT_ShotBuilderConfig myConfig;
84 };
85 
86 #endif
UT_StringHolder name() const
Definition: UT_HprUri.h:37
auto to_string(const T &value) -> std::string
Definition: format.h:4527
UT_StringHolder path() const
Definition: UT_HprUri.h:41
bool isVersionSet() const
Definition: UT_HprUri.h:43
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:39
bool isValid() const
Definition: UT_HprUri.h:35
GT_API const UT_StringHolder version
UT_StringHolder version() const
Definition: UT_HprUri.h:45
void setVersion(int version)
Definition: UT_HprUri.h:49
OIIO_UTIL_API const char * c_str(string_view str)
#define FS_API
Definition: FS_API.h:10