Platform::StringReference Class

An optimization type that you can use to pass string data from Platform::String^ input parameters to other methods with a minimum of copy operations.

Syntax

class StringReference  

Remarks

Members

Public Constructors

Name Description
StringReference::StringReference Constructor Two constructors for creating instances of StringReference.

Public Methods

Name Description
StringReference::Data Method Returns the string data as an array of char16 values.
StringReference::Length Method Returns the number of characters in the string.
StringReference::GetHSTRING Method Returns the string data as an HSTRING.
StringReference::GetString Method Returns the string data as a Platform::String^.

Public Operators

Name Description
StringReference::operator= Assigns a StringReference to a new StringReference instance.
StringReference::operator() Converts a StringReference to a Platform::String^.

Requirements

Minimum supported client: Windows 8

Minimum supported server: Windows Server 2012

Namespace: Platform

Header: vccorlib.h

StringReference::Data Method

Returns the contents of this StringReference as an array of char16 values.

Syntax

const ::default::char16 * Data() const  

Return Value

An array of char16 UNICODE text characters.

StringReference::GetHSTRING Method

Returns the contents of the string as an __abi_HSTRING.

Syntax

__abi_HSTRING GetHSTRING() const  

Return Value

An __abi_HSTRING that contains the string data.

Remarks

StringReference::GetString Method

Returns the contents of the string as a Platform::String^.

Syntax

__declspec(no_release_return) __declspec(no_refcount)  
    ::Platform::String^ GetString() const  

Return Value

A Platform::String^ that contains the string data.

StringReference::Length Method

Returns the number of characters in the string.

Syntax

unsigned int Length() const  

Return Value

An unsigned integer that specifies the number of characters in the string.

Remarks

StringReference::operator= Operator

Assigns the specified object to the current StringReference object.

Syntax

StringReference& operator=(const StringReference& __fstrArg);  
StringReference& operator=(const ::default::char16* __strArg);    

Parameters

__fstrArg
The address of a StringReference object that is used to initialize the current StringReference object.

__strArg
Pointer to an array of char16 values that is used to initialize the current StringReference object.

Return Value

A reference to an object of type StringReference.

Remarks

Because StringReference is a standard C++ class and not a ref class, it does not appear in the Object Browser.

StringReference::operator() Operator

Converts a StringReference object to a Platform::String^ object.

Syntax


__declspec(no_release_return) __declspec(no_refcount)  
         operator ::Platform::String^() const  

Return Value

A handle to an object of type Platform::String.

StringReference::StringReference Constructor

Initializes a new instance of the StringReference class.

Syntax


    StringReference();  

   StringReference(const StringReference& __fstrArg)  

StringReference(const ::default::char16* __strArg)  

StringReference(const ::default::char16* __strArg, size_t __lenArg)  

Parameters

__fstrArg
The StringReference whose data is used to initialize the new instance.

__strArg
Pointer to an array of char16 values that is used to initialize the new instance.

__lenArg
The number of elements in __strArg.

Remarks

The first version of this constructor is the default constructor. The second version initializes a new StringReference instance class from the object that's specified by the __fstrArg parameter. The third and fourth overloads initialize a new StringReference instance from an array of char16 values. char16 represents a 16-bit UNICODE text character.

See Also

Platform::StringReference Class