Graphviz 13.0.0~dev.20250402.0110
Loading...
Searching...
No Matches

reference-counted strings More...

Collaboration diagram for string utilities:

Functions

char * agstrdup (Agraph_t *, const char *)
 returns a pointer to a reference-counted copy of the argument string, creating one if necessary
 
char * agstrdup_text (Agraph_t *, const char *)
 returns a pointer to a reference-counted regular text copy of the argument string, creating one if necessary
 
char * agstrdup_html (Agraph_t *, const char *)
 returns a pointer to a reference-counted HTML-like copy of the argument string, creating one if necessary
 
int aghtmlstr (const char *)
 
char * agstrbind (Agraph_t *g, const char *)
 
char * agstrbind_text (Agraph_t *g, const char *)
 
char * agstrbind_html (Agraph_t *g, const char *)
 
int agstrfree (Agraph_t *, const char *, bool is_html)
 
char * agstrcanon (char *, char *)
 
char * agcanonStr (char *str)
 

Detailed Description

Storage management of strings as reference-counted strings. The caller does not need to dynamically allocate storage.

All uses of cgraph strings need to be freed using agstrfree in order to correctly maintain the reference count.

agcanonStr returns a pointer to a version of the input string canonicalized for output for later re-parsing. This includes quoting special characters and keywords. It uses its own internal buffer, so the value will be lost on the next call to agcanonStr. agcanon is identical with agcanonStr except it can be used with any character string. The second argument indicates whether or not the string should be canonicalized as an HTML-like string.

Function Documentation

◆ agcanonStr()

char * agcanonStr ( char *  str)

canonicalize a string for printing. must agree with strings in scan.l Shared static buffer - unsafe.

Definition at line 249 of file write.c.

References agstrcanon(), getoutputbuffer(), NULL, and str.

Referenced by _write_canonstr(), canon(), canon(), write_plain(), and writenodeandport().

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

◆ aghtmlstr()

int aghtmlstr ( const char *  s)

query if a string is an ordinary string or an HTML-like string

Definition at line 436 of file refstr.c.

References refstr_t::is_html, and NULL.

Referenced by addattr(), agattr(), agcopyattr(), agcopydict(), agmakeattrs(), agsafeset(), agset(), agstrcanon(), agxset(), agxset_(), applyattrs(), applyattrs(), attrstmt(), attrstmt(), cloneAttrs(), cloneDfltAttrs(), cloneGraph(), common_init_edge(), common_init_node(), copyAttr(), copyAttr(), delete_items(), delete_items(), do_graph_label(), freeattr(), freesym(), getval(), myagxget(), setattr(), unviewsubgraphsattr(), write_port(), and writeNondefaultAttr().

Here is the caller graph for this function:

◆ agstrbind()

char * agstrbind ( Agraph_t g,
const char *  s 
)

returns a pointer to a reference-counted string if it exists, or NULL if not

Definition at line 337 of file refstr.c.

References agstrbind_html(), agstrbind_text(), NULL, ref(), refdict(), and strdict_find().

Referenced by aginternalmaplookup(), idmap(), and myiddisc_map().

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

◆ agstrbind_html()

char * agstrbind_html ( Agraph_t g,
const char *  s 
)

returns a pointer to a reference-counted HTML-like string if it exists, or NULL if not

Definition at line 352 of file refstr.c.

References refdict(), and refstrbind().

Referenced by agattr(), agsafeset(), agset(), agstrbind(), and agxset().

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

◆ agstrbind_text()

char * agstrbind_text ( Agraph_t g,
const char *  s 
)

returns a pointer to a reference-counted regular text string if it exists, or NULL if not

Definition at line 356 of file refstr.c.

References refdict(), and refstrbind().

Referenced by agstrbind().

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

◆ agstrcanon()

char * agstrcanon ( char *  arg,
char *  buf 
)

canonicalize a string for printing. must agree with strings in scan.l Unsafe if buffer is not large enough.

Definition at line 219 of file write.c.

References _agstrcanon(), agcanonhtmlstr(), and aghtmlstr().

Referenced by agcanonStr().

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

◆ agstrdup()

char * agstrdup ( Agraph_t g,
const char *  s 
)

Use of this function should be avoided where possible. It is not possible to explicitly indicate whether the caller is trying to create a regular text string or an HTML-like string. It is better to be explicit with your intent and instead call either agstrdup_text or agstrdup_html.

Definition at line 397 of file refstr.c.

References agstrdup_html(), agstrdup_text(), NULL, ref(), refdict(), and strdict_find().

Referenced by addattr(), agbindrec(), aginternalmapinsert(), agmakeattrs(), agnewsym(), agxset_(), canon(), concat(), concat(), concatPort(), concatPort(), endstr(), endstr(), gvusershape_open(), idmap(), myiddisc_map(), setattr(), and write_canonstr().

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

◆ agstrdup_html()

char * agstrdup_html ( Agraph_t g,
const char *  s 
)

Definition at line 393 of file refstr.c.

References agstrdup_internal().

Referenced by addattr(), agmakeattrs(), agnewsym(), agstrdup(), agxset_(), cloneAttrs(), copyAttr(), endstr_html(), endstr_html(), myagxset(), myagxset(), setattr(), and toHtml().

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

◆ agstrdup_text()

char * agstrdup_text ( Agraph_t g,
const char *  s 
)

Definition at line 389 of file refstr.c.

References agstrdup_internal().

Referenced by agstrdup().

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

◆ agstrfree()

int agstrfree ( Agraph_t g,
const char *  s,
bool  is_html 
)
Parameters
is_htmlIs the string being freed an HTML-like string?

Definition at line 413 of file refstr.c.

References FAILURE, NULL, refstr_t::refcnt, refdict(), refstr_t::s, strdict_find(), strdict_remove(), and SUCCESS.

Referenced by agdelrec(), aginternalmapdelete(), agrecclose(), agxset_(), appendnode(), appendnode(), bindattrs(), bindattrs(), canon(), cloneAttrs(), concat(), concat(), concatPort(), concatPort(), copyAttr(), delete_items(), delete_items(), freeattr(), freesym(), freeUsershape(), idfree(), myiddisc_free(), opensubg(), opensubg(), setattr(), startgraph(), startgraph(), and write_canonstr().

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