Skia
2D Graphics Library
SkString.h File Reference
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTo.h"
#include "include/private/base/SkTypeTraits.h"
#include <atomic>
#include <cstdarg>
#include <cstdint>
#include <cstring>
#include <string>
#include <string_view>
#include <type_traits>
Include dependency graph for SkString.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SkString
 Light weight class for managing strings. More...
 

Functions

static bool SkStrStartsWith (const char string[], const char prefixStr[])
 
static bool SkStrStartsWith (const char string[], const char prefixChar)
 
bool SkStrEndsWith (const char string[], const char suffixStr[])
 
bool SkStrEndsWith (const char string[], const char suffixChar)
 
int SkStrStartsWithOneOf (const char string[], const char prefixes[])
 
static int SkStrFind (const char string[], const char substring[])
 
static int SkStrFindLastOf (const char string[], const char subchar)
 
static bool SkStrContains (const char string[], const char substring[])
 
static bool SkStrContains (const char string[], const char subchar)
 
char * SkStrAppendU32 (char buffer[], uint32_t)
 
char * SkStrAppendU64 (char buffer[], uint64_t, int minDigits)
 
char * SkStrAppendS32 (char buffer[], int32_t)
 
char * SkStrAppendS64 (char buffer[], int64_t, int minDigits)
 
char * SkStrAppendScalar (char buffer[], SkScalar)
 Write the scalar in decimal format into buffer, and return a pointer to the next char after the last one written. More...
 
SkString SkStringPrintf (const char *format,...) SK_PRINTF_LIKE(1
 Creates a new string and writes into it using a printf()-style format. More...
 
SkString static SkString SkStringPrintf ()
 This makes it easier to write a caller as a VAR_ARGS function where the format string is optional. More...
 
static void swap (SkString &a, SkString &b)
 

Variables

static constexpr int kSkStrAppendU32_MaxSize = 10
 
static constexpr int kSkStrAppendU64_MaxSize = 20
 
static constexpr int kSkStrAppendS32_MaxSize = kSkStrAppendU32_MaxSize + 1
 
static constexpr int kSkStrAppendS64_MaxSize = kSkStrAppendU64_MaxSize + 1
 
static constexpr int kSkStrAppendScalar_MaxSize = 15
 Floats have at most 8 significant digits, so we limit our g to that. More...
 

Function Documentation

◆ SkStrAppendS32()

char* SkStrAppendS32 ( char  buffer[],
int32_t   
)

◆ SkStrAppendS64()

char* SkStrAppendS64 ( char  buffer[],
int64_t  ,
int  minDigits 
)

◆ SkStrAppendScalar()

char* SkStrAppendScalar ( char  buffer[],
SkScalar   
)

Write the scalar in decimal format into buffer, and return a pointer to the next char after the last one written.

Note: a terminating 0 is not written into buffer, which must be at least kSkStrAppendScalar_MaxSize. Thus if the caller wants to add a 0 at the end, buffer must be at least kSkStrAppendScalar_MaxSize + 1 bytes large.

◆ SkStrAppendU32()

char* SkStrAppendU32 ( char  buffer[],
uint32_t   
)

◆ SkStrAppendU64()

char* SkStrAppendU64 ( char  buffer[],
uint64_t  ,
int  minDigits 
)

◆ SkStrContains() [1/2]

static bool SkStrContains ( const char  string[],
const char  subchar 
)
inlinestatic

◆ SkStrContains() [2/2]

static bool SkStrContains ( const char  string[],
const char  substring[] 
)
inlinestatic

◆ SkStrEndsWith() [1/2]

bool SkStrEndsWith ( const char  string[],
const char  suffixChar 
)

◆ SkStrEndsWith() [2/2]

bool SkStrEndsWith ( const char  string[],
const char  suffixStr[] 
)

◆ SkStrFind()

static int SkStrFind ( const char  string[],
const char  substring[] 
)
inlinestatic

◆ SkStrFindLastOf()

static int SkStrFindLastOf ( const char  string[],
const char  subchar 
)
inlinestatic

◆ SkStringPrintf() [1/2]

SkString static SkString SkStringPrintf ( )
inlinestatic

This makes it easier to write a caller as a VAR_ARGS function where the format string is optional.

◆ SkStringPrintf() [2/2]

SkString SkStringPrintf ( const char *  format,
  ... 
)

Creates a new string and writes into it using a printf()-style format.

◆ SkStrStartsWith() [1/2]

static bool SkStrStartsWith ( const char  string[],
const char  prefixChar 
)
inlinestatic

◆ SkStrStartsWith() [2/2]

static bool SkStrStartsWith ( const char  string[],
const char  prefixStr[] 
)
inlinestatic

◆ SkStrStartsWithOneOf()

int SkStrStartsWithOneOf ( const char  string[],
const char  prefixes[] 
)

◆ swap()

static void swap ( SkString a,
SkString b 
)
inlinestatic

Variable Documentation

◆ kSkStrAppendS32_MaxSize

constexpr int kSkStrAppendS32_MaxSize = kSkStrAppendU32_MaxSize + 1
staticconstexpr

◆ kSkStrAppendS64_MaxSize

constexpr int kSkStrAppendS64_MaxSize = kSkStrAppendU64_MaxSize + 1
staticconstexpr

◆ kSkStrAppendScalar_MaxSize

constexpr int kSkStrAppendScalar_MaxSize = 15
staticconstexpr

Floats have at most 8 significant digits, so we limit our g to that.

However, the total string could be 15 characters: -1.2345678e-005

In theory we should only expect up to 2 digits for the exponent, but on some platforms we have seen 3 (as in the example above).

◆ kSkStrAppendU32_MaxSize

constexpr int kSkStrAppendU32_MaxSize = 10
staticconstexpr

◆ kSkStrAppendU64_MaxSize

constexpr int kSkStrAppendU64_MaxSize = 20
staticconstexpr