layout: doc title: “Starboard Module Reference: string.h”

Defines functions for interacting with c-style strings.

Functions

SbStringAToI

Description

Parses a string into a base-10 integer. This is a shorthand replacement for atoi.

Declaration

static SB_C_INLINE int SbStringAToI(const char* value) {
  // NOLINTNEXTLINE(readability/casting)
  return (int)SbStringParseSignedInteger(value, NULL, 10);
}

Parameters

SbStringAToL

Description

Parses a string into a base-10, long integer. This is a shorthand replacement for atol.

Declaration

static SB_C_INLINE long SbStringAToL(const char* value) {
  // NOLINTNEXTLINE(readability/casting)
  return SbStringParseSignedInteger(value, NULL, 10);
}

Parameters

SbStringCompare

Description

Compares the first count characters of two 8-bit character strings. The return value is:

Declaration and definitions

#include "starboard/string.h"

int SbStringCompare(const char* /*string1*/,
                    const char* /*string2*/,
                    size_t /*count*/) {
  return 0;
}

Parameters

SbStringCompareAll

Description

Compares two entire 8-bit character strings. The return value is:

Declaration and definitions

#include "starboard/string.h"

int SbStringCompareAll(const char* /*string1*/, const char* /*string2*/) {
  return 0;
}

Parameters

SbStringCompareNoCase

Description

Compares two strings, ignoring differences in case. The return value is:

Declaration and definitions

#include "starboard/string.h"

int SbStringCompareNoCase(const char* /*string1*/, const char* /*string2*/) {
  return 0;
}

Parameters

SbStringCompareNoCaseN

Description

Compares the first count characters of two strings, ignoring differences in case. The return value is:

Declaration and definitions

#include "starboard/string.h"

int SbStringCompareNoCaseN(const char* /*string1*/,
                           const char* /*string2*/,
                           size_t /*count*/) {
  return 0;
}

Parameters

SbStringCompareWide

Description

Compares the first count characters of two 16-bit character strings. The return value is:

Declaration and definitions

#include "starboard/string.h"

int SbStringCompareWide(const wchar_t* /*string1*/,
                        const wchar_t* /*string2*/,
                        size_t /*count*/) {
  return 0;
}

Parameters

SbStringConcat

Description

Appends source to out_destination as long as out_destination has enough storage space to hold the concatenated string.
This function is meant to be a drop-in replacement for strlcat. Also note that this function's signature is NOT compatible with strncat.

Declaration and definitions

#include "starboard/string.h"

int SbStringConcat(char* /*out_destination*/,
                   const char* /*source*/,
                   int /*destination_size*/) {
  return 0;
}

Parameters

SbStringConcatUnsafe

Description

An inline wrapper for an unsafe SbStringConcat that assumes that the out_destination provides enough storage space for the concatenated string. Note that this function's signature is NOT compatible with strcat.

Declaration

static SB_C_INLINE int SbStringConcatUnsafe(char* out_destination,
                                            const char* source) {
  return SbStringConcat(out_destination, source, INT_MAX);
}

Parameters

SbStringConcatWide

Description

Identical to SbStringCat, but for wide characters.

Declaration and definitions

#include "starboard/string.h"

int SbStringConcatWide(wchar_t* /*out_destination*/,
                       const wchar_t* /*source*/,
                       int /*destination_size*/) {
  return 0;
}

Parameters

SbStringCopy

Description

Copies as much of a source string as possible and null-terminates it, given that destination_size characters of storage are available. This function is meant to be a drop-in replacement for strlcpy.
The return value specifies the length of source.

Declaration and definitions

#include "starboard/string.h"

int SbStringCopy(char* /*out_destination*/,
                 const char* /*source*/,
                 int /*destination_size*/) {
  return 0;
}

Parameters

SbStringCopyUnsafe

Description

An inline wrapper for an unsafe SbStringCopy that assumes that the destination provides enough storage space for the entire string. The return value is a pointer to the destination string. This function is meant to be a drop-in replacement for strcpy.

Declaration

static SB_C_INLINE char* SbStringCopyUnsafe(char* out_destination,
                                            const char* source) {
  SbStringCopy(out_destination, source, INT_MAX);
  return out_destination;
}

Parameters

SbStringCopyWide

Description

Identical to SbStringCopy, but for wide characters.

Declaration and definitions

#include "starboard/string.h"

int SbStringCopyWide(wchar_t* /*out_destination*/,
                     const wchar_t* /*source*/,
                     int /*destination_size*/) {
  return 0;
}

Parameters

SbStringDuplicate

Description

Copies source into a buffer that is allocated by this function and that can be freed with SbMemoryDeallocate. This function is meant to be a drop-in replacement for strdup.

Declaration and definitions

#include "starboard/string.h"

char* SbStringDuplicate(const char* /*source*/) {
  return NULL;
}

Parameters

SbStringFindCharacter

Description

Finds the first occurrence of a character in str. The return value is a pointer to the found character in the given string or NULL if the character is not found. Note that this function's signature does NOT match that of the strchr function.

Declaration and definitions

#include "starboard/string.h"

const char* SbStringFindCharacter(const char* /*str*/, char /*character*/) {
  return NULL;
}

Parameters

SbStringFindLastCharacter

Description

Finds the last occurrence of a specified character in a string. The return value is a pointer to the found character in the given string or NULL if the character is not found. Note that this function's signature does NOT match that of the strrchr function.

Declaration and definitions

#include "starboard/string.h"

const char* SbStringFindLastCharacter(const char* /*str*/, char /*character*/) {
  return NULL;
}

Parameters

SbStringFindString

Description

Finds the first occurrence of str2 in str1. The return value is a pointer to the beginning of the found string or NULL if the string is not found. This function is meant to be a drop-in replacement for strstr.

Declaration and definitions

#include "starboard/string.h"

const char* SbStringFindString(const char* /*str1*/, const char* /*str2*/) {
  return NULL;
}

Parameters

SbStringFormat

Description

Produces a string formatted with format and arguments, placing as much of the result that will fit into out_buffer. The return value specifies the number of characters that the format would produce if buffer_size were infinite.
This function is meant to be a drop-in replacement for vsnprintf.

Declaration and definitions

#include "starboard/string.h"

int SbStringFormat(char* /*out_buffer*/,
                   size_t /*buffer_size*/,
                   const char* /*format*/,
                   va_list /*arguments*/) {
  return 0;
}

Parameters

SbStringFormatF

Declaration

static SB_C_INLINE int SbStringFormatF(char* out_buffer,
                                       size_t buffer_size,
                                       const char* format,
                                       ...) {
  va_list arguments;
  va_start(arguments, format);
  int result = SbStringFormat(out_buffer, buffer_size, format, arguments);
  va_end(arguments);
  return result;
}

Parameters

SbStringFormatUnsafeF

Declaration

static SB_C_INLINE int SbStringFormatUnsafeF(char* out_buffer,
                                             const char* format,
                                             ...) {
  va_list arguments;
  va_start(arguments, format);
  int result = SbStringFormat(out_buffer, UINT_MAX, format, arguments);
  va_end(arguments);
  return result;
}

Parameters

SbStringFormatWide

Description

This function is identical to SbStringFormat, but is for wide characters. It is meant to be a drop-in replacement for vswprintf.

Declaration and definitions

#include "starboard/string.h"

int SbStringFormatWide(wchar_t* /*out_buffer*/,
                       size_t /*buffer_size*/,
                       const wchar_t* /*format*/,
                       va_list /*arguments*/) {
  return 0;
}

Parameters

SbStringFormatWideF

Description

An inline wrapper of SbStringFormatWide that converts from ellipsis to va_args.

Declaration

static SB_C_INLINE int SbStringFormatWideF(wchar_t* out_buffer,
                                           size_t buffer_size,
                                           const wchar_t* format,
                                           ...) {
  va_list arguments;
  va_start(arguments, format);
  int result = SbStringFormatWide(out_buffer, buffer_size, format, arguments);
  va_end(arguments);
  return result;
}

Parameters

SbStringGetLength

Description

Returns the length, in characters, of str.

Declaration and definitions

#include "starboard/string.h"

size_t SbStringGetLength(const char* /*str*/) {
  return static_cast<size_t>(0);
}

Parameters

SbStringGetLengthWide

Description

Returns the length of a wide character string. (This function is the same as SbStringGetLength, but for a string comprised of wide characters.) This function assumes that there are no multi-element characters.

Declaration and definitions

#include "starboard/string.h"

size_t SbStringGetLengthWide(const wchar_t* /*str*/) {
  return static_cast<size_t>(0);
}

Parameters

SbStringParseDouble

Description

Extracts a string that represents an integer from the beginning of start into a double.
This function is meant to be a drop-in replacement for strtod, except that it is explicitly declared to return a double.

Declaration and definitions

#include "starboard/string.h"

double SbStringParseDouble(const char* start, char** out_end) {
  if (out_end != NULL)
    *out_end = NULL;
  return 0.0;
}

Parameters

SbStringParseSignedInteger

Description

Extracts a string that represents an integer from the beginning of start into a signed integer in the given base. This function is meant to be a drop-in replacement for strtol.

Declaration and definitions

#include "starboard/string.h"

// NOLINTNEXTLINE(runtime/int)
long SbStringParseSignedInteger(const char* /*start*/,
                                char** /*out_end*/,
                                int /*base*/) {
  return 0L;
}

Parameters

SbStringParseUInt64

Description

Extracts a string that represents an integer from the beginning of start into an unsigned 64-bit integer in the given base.
This function is meant to be a drop-in replacement for strtoull, except that it is explicitly declared to return uint64_t.

Declaration

SB_EXPORT uint64_t SbStringParseUInt64(const char* start,
                                       char** out_end,
                                       int base);

Parameters

SbStringParseUnsignedInteger

Description

Extracts a string that represents an integer from the beginning of start into an unsigned integer in the given base. This function is meant to be a drop-in replacement for strtoul.

Declaration and definitions

#include "starboard/string.h"

// NOLINTNEXTLINE(runtime/int)
unsigned long SbStringParseUnsignedInteger(const char* /*start*/,
                                           char** /*out_end*/,
                                           int /*base*/) {
  return 0UL;
}

Parameters

SbStringScan

Description

Scans buffer for pattern, placing the extracted values in arguments. The return value specifies the number of successfully matched items, which may be 0.
This function is meant to be a drop-in replacement for vsscanf.

Declaration and definitions

#include "starboard/string.h"

int SbStringScan(const char* /*buffer*/,
                 const char* /*pattern*/,
                 va_list /*arguments*/) {
  return 0;
}

Parameters

SbStringScanF

Description

An inline wrapper of SbStringScan that converts from ellipsis to va_args. This function is meant to be a drop-in replacement for sscanf.

Declaration

static SB_C_INLINE int SbStringScanF(const char* buffer,
                                     const char* pattern,
                                     ...) {
  va_list arguments;
  va_start(arguments, pattern);
  int result = SbStringScan(buffer, pattern, arguments);
  va_end(arguments);
  return result;
}

Parameters