WPILibC++ 2025.0.0-alpha-1-10-g1ccd8d1
string.h File Reference
#include <string_view>

Go to the source code of this file.

Classes

struct  WPI_String
 A const UTF8 string. More...
 

Namespaces

namespace  wpi
 

Functions

constexpr std::string_view wpi::to_string_view (const struct WPI_String *str)
 Converts a WPI_String to a string_view. More...
 
constexpr WPI_String wpi::make_string (std::string_view view)
 Converts a string_view to a WPI_String. More...
 
void WPI_InitString (struct WPI_String *wpiString, const char *utf8String)
 Initializes a WPI_String from a null terminated UTF-8 string. More...
 
void WPI_InitStringWithLength (struct WPI_String *wpiString, const char *utf8String, size_t length)
 Initializes a WPI_String from a UTF-8 string and length. More...
 
char * WPI_AllocateString (struct WPI_String *wpiString, size_t length)
 Allocates a WPI_String for the specified length. More...
 
void WPI_FreeString (const struct WPI_String *wpiString)
 Frees a WPI_String that was allocated with WPI_AllocateString() More...
 
struct WPI_StringWPI_AllocateStringArray (size_t length)
 Allocates an array of WPI_Strings. More...
 
void WPI_FreeStringArray (const struct WPI_String *wpiStringArray, size_t length)
 Frees a WPI_String array returned by WPI_AllocateStringArray(). More...
 

Function Documentation

◆ WPI_AllocateString()

char * WPI_AllocateString ( struct WPI_String wpiString,
size_t  length 
)

Allocates a WPI_String for the specified length.

The resultant string must be freed with WPI_FreeString().

Parameters
wpiStringoutput string
lengthstring length in chars to allocate
Returns
mutable pointer to allocated buffer

◆ WPI_AllocateStringArray()

struct WPI_String * WPI_AllocateStringArray ( size_t  length)

Allocates an array of WPI_Strings.

Parameters
lengtharray length
Returns
string array

◆ WPI_FreeString()

void WPI_FreeString ( const struct WPI_String wpiString)

Frees a WPI_String that was allocated with WPI_AllocateString()

Parameters
wpiStringstring to free

◆ WPI_FreeStringArray()

void WPI_FreeStringArray ( const struct WPI_String wpiStringArray,
size_t  length 
)

Frees a WPI_String array returned by WPI_AllocateStringArray().

Parameters
wpiStringArraystring array to free
lengthlength of array

◆ WPI_InitString()

void WPI_InitString ( struct WPI_String wpiString,
const char *  utf8String 
)

Initializes a WPI_String from a null terminated UTF-8 string.

If input string is null, initializes output to 0 length. The output length does not include the null terminator.

The lifetime of the output string is the lifetime of the input string. Do not call WPI_FreeString() with the output of this call.

Parameters
wpiStringoutput string
utf8Stringinput string (null terminated)

◆ WPI_InitStringWithLength()

void WPI_InitStringWithLength ( struct WPI_String wpiString,
const char *  utf8String,
size_t  length 
)

Initializes a WPI_String from a UTF-8 string and length.

If input string is null or 0 length, initilizes output to 0 length. The input string does not need to be null terminated.

The lifetime of the output string is the lifetime of the input string. Do not call WPI_FreeString() with the output of this call.

Parameters
wpiStringoutput string
utf8Stringinput string
lengthinput string length in chars