1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Add explicit string literal overload to try to help Coverity (and

avoid a strlen call to boot).
This commit is contained in:
2014-07-25 18:15:10 -07:00
parent a82c110a9a
commit fa1bb779e5

View File

@ -254,6 +254,13 @@ public:
*/
plString(const char *cstr, size_t size = STRLEN_AUTO) { IConvertFromUtf8(cstr, size); }
/** Construct a plString from a string literal.
* \note This constructor expects the input to be UTF-8 encoded. For
* conversion from ISO-8859-1 8-bit data, use FromIso8859_1().
*/
template <size_t _Sz>
plString(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz); }
/** Copy constructor. */
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
@ -269,6 +276,10 @@ public:
/** Assignment operator. Same as plString(const char *). */
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, STRLEN_AUTO); return *this; }
/** Assignment operator. Same as plString(const char (&)[_Sz]). */
template <size_t _Sz>
plString &operator=(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz); return *this; }
/** Assignment operator. Same as plString(const plString &). */
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }