MCPcopy Create free account
hub / github.com/apache/impala / string_as_array

Function string_as_array

be/src/gutil/stl_util.h:350–353  ·  view source on GitHub ↗

Return a mutable char* pointing to a string's internal buffer, which may not be null-terminated. Writing through this pointer will modify the string. string_as_array(&str)[i] is valid for 0 <= i < str.size() until the next call to a string method that invalidates iterators. Prior to C++11, there was no standard-blessed way of getting a mutable reference to a string's internal buffer. The require

Source from the content-addressed store, hash-verified

348// According to Matt Austern, this should already work on all current C++98
349// implementations.
350inline char* string_as_array(string* str) {
351 // DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
352 return str->empty() ? NULL : &*str->begin();
353}
354
355// These are methods that test two hash maps/sets for equality. These exist
356// because the == operator in the STL can return false when the maps/sets

Callers 8

InitializeMethod · 0.85
SubstituteAndAppendFunction · 0.85
EncodePODFunction · 0.85
EncodeVectorPODFunction · 0.85
Base64UnescapeInternalFunction · 0.85
Base64EscapeInternalFunction · 0.85
Base32UnescapeFunction · 0.85
CleanStringLineEndingsFunction · 0.85

Calls 2

emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected