Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-17 13:38:15 +0300
committerJacques Lucke <jacques@blender.org>2020-07-17 13:38:15 +0300
commit0e3d34e48f5d5ed3845b1858a66008ab87c55af8 (patch)
treef52b983a632e11233662bacb7b469d9b6e4663c2 /source/blender/blenlib
parent0fcd23a3880f0caf4a683203b486d451991edb2d (diff)
BLI: add StringRefNull.c_str() method
This should be used whenever you rely on the fact, that the returned pointer points to the beginning of a null-terminated array.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_string_ref.hh12
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh
index bcf2d20338e..5b555b8cd1d 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -187,7 +187,7 @@ class StringRefNull : public StringRefBase {
* Reference a std::string. Remember that when the std::string is destructed, the StringRefNull
* will point to uninitialized memory.
*/
- StringRefNull(const std::string &str) : StringRefNull(str.data())
+ StringRefNull(const std::string &str) : StringRefNull(str.c_str())
{
}
@@ -200,6 +200,16 @@ class StringRefNull : public StringRefBase {
BLI_assert(index <= size_);
return data_[index];
}
+
+ /**
+ * Returns the beginning of a null-terminated char array.
+ *
+ * This is like ->data(), but can only be called on a StringRefNull.
+ */
+ const char *c_str() const
+ {
+ return data_;
+ }
};
/**