Browse Source

Added string_getBufferUseCount.

David Piuva 5 years ago
parent
commit
54da50b82c
2 changed files with 6 additions and 0 deletions
  1. 3 0
      Source/DFPSR/base/text.cpp
  2. 3 0
      Source/DFPSR/base/text.h

+ 3 - 0
Source/DFPSR/base/text.cpp

@@ -1088,3 +1088,6 @@ bool dsr::string_isDouble(const ReadableString& source, bool allowWhiteSpace) {
 	}
 }
 
+int64_t dsr::string_getBufferUseCount(const String& text) {
+	return text.buffer.use_count();
+}

+ 3 - 0
Source/DFPSR/base/text.h

@@ -363,6 +363,9 @@ String string_mangleQuote(const ReadableString &rawText);
 // Post-condition: Returns mangledText with quotes removed and excape tokens interpreted.
 String string_unmangleQuote(const ReadableString& mangledText);
 
+// Post-condition: Returns the number of strings using the same buffer, including itself.
+int64_t string_getBufferUseCount(const String& text);
+
 // Ensures safely that at least minimumLength characters can he held in the buffer
 inline void string_reserve(String& target, int64_t minimumLength) {
 	target.reserve(minimumLength);