Provide a public method to get StringRef's underlying pointer

This allows reducing the amount of friends needed for its interface
and some extra tricks later.

The bad part is that the pointer can become invalidated via
calls to other StringRef's public methods, but c'est la vie.
This commit is contained in:
Martin Hořeňovský
2018-02-28 22:05:01 +01:00
parent 950ccf4749
commit 05cd05743a
6 changed files with 21 additions and 26 deletions

View File

@@ -637,11 +637,11 @@ String.tests.cpp:<line number>: passed: std::strcmp( ss.c_str(), "hello" ) == 0
String.tests.cpp:<line number>: passed: ss == "hello" for: hello == "hello"
String.tests.cpp:<line number>: passed: isSubstring( ss ) for: true
String.tests.cpp:<line number>: passed: isOwned( ss ) == false for: false == false
String.tests.cpp:<line number>: passed: rawChars == data( s ) for: "hello world!" == "hello world!"
String.tests.cpp:<line number>: passed: rawChars == s.currentData() for: "hello world!" == "hello world!"
String.tests.cpp:<line number>: passed: ss.c_str() != rawChars for: "hello" != "hello world!"
String.tests.cpp:<line number>: passed: isSubstring( ss ) == false for: false == false
String.tests.cpp:<line number>: passed: isOwned( ss ) for: true
String.tests.cpp:<line number>: passed: data( ss ) != data( s ) for: "hello" != "hello world!"
String.tests.cpp:<line number>: passed: ss.currentData() != s.currentData() for: "hello" != "hello world!"
String.tests.cpp:<line number>: passed: ss.size() == 6 for: 6 == 6
String.tests.cpp:<line number>: passed: std::strcmp( ss.c_str(), "world!" ) == 0 for: 0 == 0
String.tests.cpp:<line number>: passed: s.c_str() == s2.c_str() for: "hello world!" == "hello world!"

View File

@@ -5076,7 +5076,7 @@ with expansion:
String.tests.cpp:<line number>:
PASSED:
REQUIRE( rawChars == data( s ) )
REQUIRE( rawChars == s.currentData() )
with expansion:
"hello world!" == "hello world!"
@@ -5100,7 +5100,7 @@ with expansion:
String.tests.cpp:<line number>:
PASSED:
REQUIRE( data( ss ) != data( s ) )
REQUIRE( ss.currentData() != s.currentData() )
with expansion:
"hello" != "hello world!"

View File

@@ -5808,7 +5808,7 @@ Message from section two
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
rawChars == data( s )
rawChars == s.currentData()
</Original>
<Expanded>
"hello world!" == "hello world!"
@@ -5840,7 +5840,7 @@ Message from section two
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
data( ss ) != data( s )
ss.currentData() != s.currentData()
</Original>
<Expanded>
"hello" != "hello world!"