libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_string_view.h File Reference

Go to the source code of this file.

Data Structures

struct  GblStringView
 

Macros

#define GBL_STRING_VIEW_NPOS
 
#define GBL_STRV(...)
 
#define GBL_STRING_VIEW_CSTR(view)
 
#define GBL_STRING_VIEW_CSTR_ALLOCA(view)
 

Detailed Description

GblStringView structure and related functions.

This file contains the GblStringView structure and related API. A GblStringView is an immutable slice of a string, containing simply a pointer to the string and its size. When doing non-mutating operations on strings, such as searching, this is the preferred string type for the job with the most detailed API.

Note
GblStringView also reserves one bit of its length field to store whether it's NULL-terminated or not. This allows for more efficient conversions between string_view types and NULL-terminated C strings, as a copy can be ellided when the view is already of a NULL-terminated C string.
Author
2023 Falco Girgis

Definition in file gimbal_string_view.h.

Macro Definition Documentation

◆ GBL_STRING_VIEW_NPOS

#define GBL_STRING_VIEW_NPOS

Constant value used to signify the last position or an invalid position in a GblStringView.

Definition at line 36 of file gimbal_string_view.h.

◆ GBL_STRV

#define GBL_STRV (   ...)

Convenience shorthand macro for creating a GblStringView from an existing string or substring.

Definition at line 38 of file gimbal_string_view.h.

◆ GBL_STRING_VIEW_CSTR

#define GBL_STRING_VIEW_CSTR (   view)

Convenience macro for converting a GblStringView to a C string, elliding creation of a temporary when the view is already NULL terminated.

Definition at line 40 of file gimbal_string_view.h.

◆ GBL_STRING_VIEW_CSTR_ALLOCA

#define GBL_STRING_VIEW_CSTR_ALLOCA (   view)

Convenience macro for creating a NULL-terminated C string from a GblStringView on the stack, using alloca()

Definition at line 42 of file gimbal_string_view.h.