Browse Source

Added a constructor to StringRef that takes a std::string

tags/2021-05-28
jules 7 years ago
parent
commit
b3390dabc9
2 changed files with 9 additions and 1 deletions
  1. +2
    -1
      modules/juce_core/text/juce_String.cpp
  2. +7
    -0
      modules/juce_core/text/juce_StringRef.h

+ 2
- 1
modules/juce_core/text/juce_String.cpp View File

@@ -2207,7 +2207,8 @@ StringRef::StringRef (String::CharPointerType stringLiteral) noexcept : text (s
jassert (stringLiteral.getAddress() != nullptr); // This must be a valid string literal, not a null pointer!!
}
StringRef::StringRef (const String& string) noexcept : text (string.getCharPointer()) {}
StringRef::StringRef (const String& string) noexcept : text (string.getCharPointer()) {}
StringRef::StringRef (const std::string& string) : StringRef (string.c_str()) {}
//==============================================================================


+ 7
- 0
modules/juce_core/text/juce_StringRef.h View File

@@ -81,6 +81,13 @@ public:
*/
StringRef (const String& string) noexcept;
/** Creates a StringRef from a String.
The StringRef object does NOT take ownership or copy the data from the std::string,
so you must ensure that the source string object is not modified or deleted during
the lifetime of the StringRef.
*/
StringRef (const std::string& string);
/** Creates a StringRef pointer to an empty string. */
StringRef() noexcept;


Loading…
Cancel
Save