WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
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
 Foonathan namespace.
 

Functions

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

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, initializes 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