BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdls::FilesystemUtil_CStringUtil Struct Reference

#include <bdls_filesystemutil.h>

Static Public Member Functions

static const char * flatten (char *cString)
 Return the specified cString.
 
static const char * flatten (const char *cString)
 
static const char * flatten (const bsl::string &string)
 Return the result of invoking c_str() on the specified string.
 
static const char * flatten (const std::string &string)
 
static bsl::string flatten (const bsl::string_view &stringView)
 
static bsl::string flatten (const bslstl::StringRef &stringRef)
 
template<class TYPE >
static const char * flatten (const TYPE &)
 

Detailed Description

This component-private utility struct provides a namespace for the flatten overload set intended to be used in concert with an overload set consisting of a function template with a deduced argument and an non-template overload accepting a const char *. The actual implementation of the functionality would be in the const char * overload whereas the purpose of the function template is to invoke the const char * overload with a null-terminated string.

The function template achieves null-termination by recursively calling the function and supplying it with the result of flatten invoked on the deduced argument. This flatten invocation will call c_str() on various supported string types, will produce a temporary bsl::string for possibly non-null-terminated bslstl::StringRef, and will result in a BSLMF_ASSERT for any unsupported type. Calling the function with the temporary bsl::string produced from bslstl::StringRef will result in a second invocation of flatten, this time producing const char *, and finally calling the function with a null-terminated string.

Note that the bslstl::StringRef overload for flatten is provided for backwards compatibility. Without it, the bsl::string and std::string overloads would be ambiguous. In new code, it is preferable to not provide bslstl::StringRef overload in a similar facility and require the clients to explicitly state the string type in their code, making a potential allocation obvious. The bsl::string_view overload is not provided for the same reason.

Member Function Documentation

◆ flatten() [1/7]

const char * bdls::FilesystemUtil_CStringUtil::flatten ( char *  cString)
inlinestatic

◆ flatten() [2/7]

const char * bdls::FilesystemUtil_CStringUtil::flatten ( const bsl::string string)
inlinestatic

◆ flatten() [3/7]

bsl::string bdls::FilesystemUtil_CStringUtil::flatten ( const bsl::string_view stringView)
inlinestatic

Return a temporary bsl::string constructed from the specified stringView.

◆ flatten() [4/7]

bsl::string bdls::FilesystemUtil_CStringUtil::flatten ( const bslstl::StringRef stringRef)
inlinestatic

Return a temporary bsl::string constructed from the specified stringRef.

◆ flatten() [5/7]

const char * bdls::FilesystemUtil_CStringUtil::flatten ( const char *  cString)
inlinestatic

◆ flatten() [6/7]

const char * bdls::FilesystemUtil_CStringUtil::flatten ( const std::string &  string)
inlinestatic

◆ flatten() [7/7]

template<class TYPE >
const char * bdls::FilesystemUtil_CStringUtil::flatten ( const TYPE &  )
inlinestatic

Produce a compile-time error informing the caller that the parameterized TYPE is not supported as the parameter for the call.


The documentation for this struct was generated from the following file: