Quick Links:

bal | bbl | bdl | bsl

Static Public Member Functions

bdls::FilesystemUtil_CStringUtil Struct Reference

#include <bdls_filesystemutil.h>

List of all members.

Static Public Member Functions

static const char * flatten (char *cString)
static const char * flatten (const char *cString)
static const char * flatten (const bsl::string &string)
static const char * flatten (const std::string &string)
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.

See Component bdls_filesystemutil


Member Function Documentation

static const char* bdls::FilesystemUtil_CStringUtil::flatten ( char *  cString  )  [static]
static const char* bdls::FilesystemUtil_CStringUtil::flatten ( const char *  cString  )  [static]

Return the specified cString.

static const char* bdls::FilesystemUtil_CStringUtil::flatten ( const bsl::string string  )  [static]
static const char* bdls::FilesystemUtil_CStringUtil::flatten ( const std::string &  string  )  [static]

Return the result of invoking c_str() on the specified string.

static bsl::string bdls::FilesystemUtil_CStringUtil::flatten ( const bslstl::StringRef stringRef  )  [static]

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

template<class TYPE >
static const char* bdls::FilesystemUtil_CStringUtil::flatten ( const TYPE &   )  [static]

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: