Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
strview.h File Reference

Non-owning string references. More...

#include <assert.h>
#include <cgraph/alloc.h>
#include <cgraph/startswith.h>
#include <cgraph/strcasecmp.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
Include dependency graph for strview.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  strview_t
 a non-owning string reference More...
 

Functions

static strview_t strview (const char *referent, char terminator)
 create a string reference
 
static char * strview_str (strview_t source)
 make a heap-allocated string from this string view
 
static bool strview_case_eq (strview_t a, strview_t b)
 compare two string references for case insensitive equality
 
static bool strview_case_str_eq (strview_t a, const char *b)
 compare a string reference to a string for case insensitive equality
 
static int strview_cmp (strview_t a, strview_t b)
 compare two string references
 
static bool strview_eq (strview_t a, strview_t b)
 compare two string references for equality
 
static bool strview_str_eq (strview_t a, const char *b)
 compare a string reference to a string for equality
 
static bool strview_str_contains (strview_t haystack, const char *needle)
 does the given string appear as a substring of the string view?
 

Detailed Description

This is similar to C++17’s std::string_view. Instances of strview_t should generally be passed around by value rather than pointer as they are small.

Definition in file strview.h.

Function Documentation

◆ strview()

static strview_t strview ( const char *  referent,
char  terminator 
)
inlinestatic

Definition at line 26 of file strview.h.

References NULL.

Referenced by gv_get_ps_fontlist(), gvplugin_install(), gvplugin_list(), gvplugin_load(), gvPluginList(), pic_textspan(), set_attr_object_type(), strview_case_str_eq(), strview_str_eq(), and update_columns().

Here is the caller graph for this function:

◆ strview_case_eq()

static bool strview_case_eq ( strview_t  a,
strview_t  b 
)
inlinestatic

Definition at line 49 of file strview.h.

References strview_t::data, NULL, and strview_t::size.

Referenced by gvplugin_list(), gvPluginList(), and strview_case_str_eq().

Here is the caller graph for this function:

◆ strview_case_str_eq()

static bool strview_case_str_eq ( strview_t  a,
const char *  b 
)
inlinestatic

Definition at line 62 of file strview.h.

References strview_t::data, NULL, strview(), and strview_case_eq().

Here is the call graph for this function:

◆ strview_cmp()

static int strview_cmp ( strview_t  a,
strview_t  b 
)
inlinestatic

Definition at line 71 of file strview.h.

References cmp(), strview_t::data, and strview_t::size.

Referenced by gvplugin_install(), and strview_eq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strview_eq()

static bool strview_eq ( strview_t  a,
strview_t  b 
)
inlinestatic

Definition at line 89 of file strview.h.

References strview_t::data, NULL, and strview_cmp().

Referenced by gvplugin_install(), gvplugin_load(), and strview_str_eq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strview_str()

static char * strview_str ( strview_t  source)
inlinestatic

Definition at line 41 of file strview.h.

References strview_t::data, gv_strndup(), NULL, and strview_t::size.

Referenced by add_column(), gv_get_ps_fontlist(), gvPluginList(), and svg_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strview_str_contains()

static bool strview_str_contains ( strview_t  haystack,
const char *  needle 
)
inlinestatic

Definition at line 107 of file strview.h.

References strview_t::data, NULL, offset, strview_t::size, and startswith().

Here is the call graph for this function:

◆ strview_str_eq()

static bool strview_str_eq ( strview_t  a,
const char *  b 
)
inlinestatic

Definition at line 98 of file strview.h.

References strview_t::data, NULL, strview(), and strview_eq().

Referenced by add_column(), gvplugin_load(), object_type_helper(), onematch(), parseStyle(), picfontname(), prformat(), and svg_size().

Here is the call graph for this function:
Here is the caller graph for this function: