Changeset 68123 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jul 26, 2017 2:31:35 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/ministring.cpp
r68094 r68123 50 50 51 51 52 RTCString &RTCString::assign(const RTCString &a_rSrc) 53 { 54 size_t const cchSrc = a_rSrc.length(); 55 if (cchSrc > 0) 56 { 57 reserve(cchSrc + 1); 58 memcpy(m_psz, a_rSrc.c_str(), cchSrc); 59 m_psz[cchSrc] = '\0'; 60 m_cch = cchSrc; 61 return *this; 62 } 63 setNull(); 64 return *this; 65 66 } 67 68 RTCString &RTCString::assign(const char *a_pszSrc) 69 { 70 if (a_pszSrc) 71 { 72 size_t cchSrc = strlen(a_pszSrc); 73 if (cchSrc) 74 { 75 reserve(cchSrc + 1); 76 memcpy(m_psz, a_pszSrc, cchSrc); 77 m_psz[cchSrc] = '\0'; 78 m_cch = cchSrc; 79 return *this; 80 } 81 } 82 setNull(); 83 return *this; 84 } 85 86 RTCString &RTCString::assign(const RTCString &a_rSrc, size_t a_offSrc, size_t a_cchSrc /*= npos*/) 87 { 88 AssertReturn(&a_rSrc != this, *this); 89 if (a_offSrc < a_rSrc.length()) 90 { 91 size_t cchMax = a_rSrc.length() - a_offSrc; 92 if (a_cchSrc > cchMax) 93 a_cchSrc = cchMax; 94 reserve(a_cchSrc + 1); 95 memcpy(m_psz, a_rSrc.c_str(), a_cchSrc); 96 m_psz[a_cchSrc] = '\0'; 97 m_cch = a_cchSrc; 98 } 99 else 100 setNull(); 101 return *this; 102 } 103 104 RTCString &RTCString::assign(const char *a_pszSrc, size_t a_cchSrc) 105 { 106 if (a_cchSrc) 107 { 108 a_cchSrc = RTStrNLen(a_pszSrc, a_cchSrc); 109 reserve(a_cchSrc + 1); 110 memcpy(m_psz, a_pszSrc, a_cchSrc); 111 m_psz[a_cchSrc] = '\0'; 112 m_cch = a_cchSrc; 113 } 114 else 115 setNull(); 116 return *this; 117 } 118 119 RTCString &RTCString::assign(size_t a_cTimes, char a_ch) 120 { 121 reserve(a_cTimes + 1); 122 memset(m_psz, a_ch, a_cTimes); 123 return *this; 124 } 125 126 52 127 RTCString &RTCString::printf(const char *pszFormat, ...) 53 128 {
Note:
See TracChangeset
for help on using the changeset viewer.