language-extensions/R/src/Utilities.cpp
//--------------------------------------------------------------------------------------------------
// Name: Utilities::GenerateUniquePtr
//
// Description:
//  Given a constant string input, generates a unique pointer
//  pointing to a char array containing the same contents as that of the input
//
:GenerateUniquePtr
Description:
Given a constant string input, generates a unique pointer
pointing to a char array containing the same contents as that of the input
: GenerateUniquePtr Description : Given a constant string input generates a unique pointer pointing to a char array containing the same contents as that of the input
unique_ptr<char[]> Utilities::GenerateUniquePtr(const string &inputStr)
{
	int inputStrLen = inputStr.length();
	unique_ptr<char[]> outPtr = make_unique<char[]>(inputStrLen + 1);
	memcpy(outPtr.get(), inputStr.c_str(), inputStrLen);
	*(outPtr.get() + inputStrLen) = '\0';
	return outPtr;
}
unique_ptr < char [ ] > Utilities :: GenerateUniquePtr ( const string & inputStr ) { int inputStrLen = inputStr . length ( ) ; unique_ptr < char [ ] > outPtr = make_unique < char [ ] > ( inputStrLen + 1 ) ; memcpy ( outPtr . get ( ) , inputStr . c_str ( ) , inputStrLen ) ; * ( outPtr . get ( ) + inputStrLen ) = ' \0 ' ; return outPtr ; }
Name: Utilities::GenerateUniquePtr
Description:
Given a constant string input, generates a unique pointer
pointing to a char array containing the same contents as that of the input
Name : Utilities :: GenerateUniquePtr Description : Given a constant string input generates a unique pointer pointing to a char array containing the same contents as that of the input
// Reserve additional space for null terminating character. //