HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_DeepString.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_DeepString.h
7  *
8  * COMMENTS:
9  * A UT_DeepString is a UT_String that always stores a deep copy its
10  * data. This way you can return strings by value and you can have string
11  * member variables without having to define your own copy constructor and
12  * assignment operator.
13  *
14  * Note that a UT_DeepString is just a UT_String that always stores
15  * a deep copy. It's just a convenience class that avoids you having
16  * to pass UT_String::ALWAYS_DEEP to the constructor of the UT_String.
17  *
18  * You should use UT_String with the UT_String::ALWAYS_DEEP parameter
19  * instead of this class whenever possible. However, in templated
20  * code, it might not always be possible.
21  */
22 
23 #ifndef __UT_DeepString_h__
24 #define __UT_DeepString_h__
25 
26 #include "UT_API.h"
27 #include "UT_String.h"
28 #include <SYS/SYS_Deprecated.h>
29 
31 {
32 public:
34  UT_DeepString(const char *str = 0)
35  : UT_String(UT_String::ALWAYS_DEEP, str)
36  {}
37 
39  UT_DeepString(const std::string &str)
40  : UT_String(UT_String::ALWAYS_DEEP, str.c_str())
41  {}
42 
45  : UT_String(UT_String::ALWAYS_DEEP, (const char *)str)
46  {}
47 
48  // When we copy construct a UT_String from a UT_DeepString, the UT_String
49  // will always make a deep copy.
52  : UT_String(str)
53  {}
54 
56  {}
57 
59  {
61  return *this;
62  }
63 
65  {
67  return *this;
68  }
69 
70  UT_DeepString &operator=(const char *str)
71  {
73  return *this;
74  }
75 };
76 
77 inline size_t hash_value(const UT_DeepString &str)
78 {
79  return (size_t)str.hash();
80 }
81 
82 
83 #endif
#define UT_API
Definition: UT_API.h:14
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
SYS_FORCE_INLINE uint32 hash() const
Definition: UT_String.h:925
size_t hash_value(const UT_DeepString &str)
Definition: UT_DeepString.h:77
UT_DeepString & operator=(const UT_String &str)
Definition: UT_DeepString.h:64
UT_DeepString & operator=(const char *str)
Definition: UT_DeepString.h:70
OIIO_UTIL_API const char * c_str(string_view str)
UT_DeepString & operator=(const UT_DeepString &str)
Definition: UT_DeepString.h:58
UT_String & operator=(UT_String &&str) noexcept
Definition: UT_String.h:187