Graphviz 13.0.0~dev.20250121.0651
Loading...
Searching...
No Matches
attr.c File Reference

implementation of dynamic attributes More...

#include <cgraph/cghdr.h>
#include <stdbool.h>
#include <stdlib.h>
#include <util/alloc.h>
#include <util/streq.h>
#include <util/unreachable.h>
Include dependency graph for attr.c:

Go to the source code of this file.

Macros

#define MINATTR   4 /* minimum allocation */
 

Functions

static void freesym (void *obj)
 
static void init_all_attrs (Agraph_t *g)
 
Agdatadict_tagdatadict (Agraph_t *g, bool cflag)
 
static Dict_tagdictof (Agraph_t *g, int kind)
 
static Agsym_tagnewsym (Agraph_t *g, const char *name, const char *value, bool is_html, int id, int kind)
 
static void agcopydict (Dict_t *src, Dict_t *dest, Agraph_t *g, int kind)
 
static Agdatadict_tagmakedatadict (Agraph_t *g)
 
static Agsym_tagdictsym (Dict_t *dict, char *name)
 
static Agsym_taglocaldictsym (Dict_t *dict, char *name)
 
Agsym_tagattrsym (void *obj, char *name)
 looks up a string attribute for a graph object given as an argument
 
static int topdictsize (Agobj_t *obj)
 
static Agrec_tagmakeattrs (Agraph_t *context, void *obj)
 
static void freeattr (Agobj_t *obj, Agattr_t *attr)
 
Agattr_tagattrrec (void *obj)
 
static void addattr (Agraph_t *g, Agobj_t *obj, Agsym_t *sym)
 
static Agsym_tgetattr (Agraph_t *g, int kind, char *name)
 
static void unviewsubgraphsattr (Agraph_t *parent, char *name)
 
static int agxset_ (void *obj, Agsym_t *sym, const char *value, bool is_html)
 
static Agsym_tsetattr (Agraph_t *g, int kind, char *name, const char *value, bool is_html)
 
static Agsym_tagattr_ (Agraph_t *g, int kind, char *name, const char *value, bool is_html)
 
Agsym_tagattr (Agraph_t *g, int kind, char *name, const char *value)
 creates or looks up attributes of a graph
 
Agsym_tagattr_html (Agraph_t *g, int kind, char *name, const char *value)
 agattr, but creates HTML-like values
 
Agsym_tagnxtattr (Agraph_t *g, int kind, Agsym_t *attr)
 permits traversing the list of attributes of a given type
 
void agraphattr_init (Agraph_t *g)
 
int agraphattr_delete (Agraph_t *g)
 
void agnodeattr_init (Agraph_t *g, Agnode_t *n)
 
void agnodeattr_delete (Agnode_t *n)
 
void agedgeattr_init (Agraph_t *g, Agedge_t *e)
 
void agedgeattr_delete (Agedge_t *e)
 
char * agget (void *obj, char *name)
 
char * agxget (void *obj, Agsym_t *sym)
 
int agset (void *obj, char *name, const char *value)
 
int agxset (void *obj, Agsym_t *sym, const char *value)
 
int agxset_html (void *obj, Agsym_t *sym, const char *value)
 
int agsafeset (void *obj, char *name, const char *value, const char *def)
 ensures the given attribute is declared before setting it locally on an object
 
static void agraphattr_init_wrapper (Agraph_t *g, Agobj_t *ignored1, void *ignored2)
 
int agcopyattr (void *oldobj, void *newobj)
 copies all of the attributes from one object to another
 

Variables

Dtdisc_t AgDataDictDisc
 
static char DataDictName [] = "_AG_datadict"
 
static Agdesc_t ProtoDesc
 
static Agraph_tProtoGraph
 
char * AgDataRecName = "_AG_strdata"
 

Macro Definition Documentation

◆ MINATTR

#define MINATTR   4 /* minimum allocation */

Definition at line 30 of file attr.c.

Function Documentation

◆ addattr()

static void addattr ( Agraph_t g,
Agobj_t obj,
Agsym_t sym 
)
static

Definition at line 242 of file attr.c.

References agattrrec(), aghtmlstr(), agstrdup(), agstrdup_html(), Agsym_s::defval, gv_recalloc(), Agsym_s::id, MINATTR, NULL, and Agattr_s::str.

Referenced by setattr().

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

◆ agattr_()

static Agsym_t * agattr_ ( Agraph_t g,
int  kind,
char *  name,
const char *  value,
bool  is_html 
)
static

Definition at line 355 of file attr.c.

References agopen(), getattr(), ProtoDesc, ProtoGraph, and setattr().

Referenced by agattr(), and agattr_html().

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

◆ agcopydict()

static void agcopydict ( Dict_t src,
Dict_t dest,
Agraph_t g,
int  kind 
)
static

Definition at line 96 of file attr.c.

References aghtmlstr(), agnewsym(), Agsym_s::defval, dtfirst, dtinsert, dtnext, dtsize(), Agsym_s::fixed, Agsym_s::id, Agsym_s::name, and Agsym_s::print.

Referenced by agmakedatadict().

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

◆ agdictof()

static Dict_t * agdictof ( Agraph_t g,
int  kind 
)
static

Definition at line 58 of file attr.c.

References agdatadict(), agerrorf(), AGINEDGE, AGNODE, AGOUTEDGE, AGRAPH, Agdatadict_s::dict, Agdatadict_s::e, Agdatadict_s::g, Agdatadict_s::n, and NULL.

Referenced by agmakeattrs(), agnxtattr(), getattr(), setattr(), and topdictsize().

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

◆ agdictsym()

static Agsym_t * agdictsym ( Dict_t dict,
char *  name 
)
static

Definition at line 139 of file attr.c.

References dtsearch, and Agsym_s::name.

Referenced by agattrsym(), aglocaldictsym(), getattr(), and setattr().

Here is the caller graph for this function:

◆ aglocaldictsym()

static Agsym_t * aglocaldictsym ( Dict_t dict,
char *  name 
)
static

Definition at line 147 of file attr.c.

References agdictsym(), dtview(), NULL, and view.

Referenced by agxset_(), setattr(), and unviewsubgraphsattr().

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

◆ agmakeattrs()

static Agrec_t * agmakeattrs ( Agraph_t context,
void *  obj 
)
static

Definition at line 184 of file attr.c.

References agbindrec(), AgDataRecName, agdictof(), aghtmlstr(), agraphof(), agroot(), agstrdup(), agstrdup_html(), AGTYPE, Agsym_s::defval, Agattr_s::dict, dtfirst, dtnext, gv_calloc(), Agsym_s::id, MINATTR, NULL, Agattr_s::str, and topdictsize().

Referenced by agedgeattr_init(), agnodeattr_init(), and agraphattr_init().

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

◆ agmakedatadict()

static Agdatadict_t * agmakedatadict ( Agraph_t g)
static

Definition at line 110 of file attr.c.

References agbindrec(), agcopydict(), agdatadict(), AgDataDictDisc, agdtopen(), AGEDGE, AGNODE, agparent(), AGRAPH, DataDictName, Agdatadict_s::dict, Dttree, dtview(), Agdatadict_s::e, Agdatadict_s::g, Agdatadict_s::n, and ProtoGraph.

Referenced by agraphattr_init().

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

◆ agnewsym()

static Agsym_t * agnewsym ( Agraph_t g,
const char *  name,
const char *  value,
bool  is_html,
int  id,
int  kind 
)
static
Parameters
is_htmlIs value an HTML-like string?

Definition at line 86 of file attr.c.

References agstrdup(), agstrdup_html(), Agsym_s::defval, gv_alloc(), id, Agsym_s::id, Agsym_s::kind, and Agsym_s::name.

Referenced by agcopydict(), agxset_(), setattr(), and unviewsubgraphsattr().

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

◆ agraphattr_init_wrapper()

static void agraphattr_init_wrapper ( Agraph_t g,
Agobj_t ignored1,
void *  ignored2 
)
static

Definition at line 549 of file attr.c.

References agraphattr_init().

Referenced by init_all_attrs().

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

◆ agxset_()

static int agxset_ ( void *  obj,
Agsym_t sym,
const char *  value,
bool  is_html 
)
static

Definition at line 504 of file attr.c.

References agattrrec(), agdatadict(), aghtmlstr(), aglocaldictsym(), agmethod_upd(), agnewsym(), AGRAPH, agraphof(), agstrdup(), agstrdup_html(), agstrfree(), AGTYPE, Agsym_s::defval, Agdatadict_s::dict, dtinsert, Agdatadict_s::g, Agsym_s::id, Agsym_s::name, Agtag_s::objtype, SUCCESS, Agobj_s::tag, and topdictsize().

Referenced by agxset(), agxset_html(), and setattr().

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

◆ freeattr()

static void freeattr ( Agobj_t obj,
Agattr_t attr 
)
static

Definition at line 215 of file attr.c.

References aghtmlstr(), agraphof(), agstrfree(), free(), Agattr_s::str, and topdictsize().

Referenced by agedgeattr_delete(), agnodeattr_delete(), and agraphattr_delete().

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

◆ freesym()

static void freesym ( void *  obj)
static

Definition at line 227 of file attr.c.

References Ag_G_global, aghtmlstr(), agstrfree(), Agsym_s::defval, free(), and Agsym_s::name.

Here is the call graph for this function:

◆ getattr()

static Agsym_t * getattr ( Agraph_t g,
int  kind,
char *  name 
)
static

Definition at line 256 of file attr.c.

References agdictof(), and agdictsym().

Referenced by agattr_(), and unviewsubgraphsattr().

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

◆ init_all_attrs()

static void init_all_attrs ( Agraph_t g)
static

Definition at line 562 of file attr.c.

References agapply(), agedgeattr_init(), agfstnode(), agfstout(), agnodeattr_init(), agnxtnode(), agnxtout(), agraphattr_init_wrapper(), agroot(), and NULL.

Referenced by agdatadict().

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

◆ setattr()

static Agsym_t * setattr ( Agraph_t g,
int  kind,
char *  name,
const char *  value,
bool  is_html 
)
static
Parameters
is_htmlIs value an HTML-like string?

Definition at line 291 of file attr.c.

References addattr(), agapply(), agdatadict(), agdictof(), agdictsym(), agfstnode(), agfstout(), aghtmlstr(), AGINEDGE, aglocaldictsym(), agmethod_upd(), agnewsym(), AGNODE, agnxtnode(), agnxtout(), AGOUTEDGE, AGRAPH, agroot(), agstrdup(), agstrdup_html(), agstrfree(), agwarningf(), agxset_(), Agsym_s::defval, dtinsert, dtsize(), Agsym_s::id, streq(), UNREACHABLE, and unviewsubgraphsattr().

Referenced by agattr_().

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

◆ topdictsize()

static int topdictsize ( Agobj_t obj)
static

Definition at line 175 of file attr.c.

References agdictof(), agraphof(), agroot(), AGTYPE, and dtsize().

Referenced by agmakeattrs(), agxget(), agxset_(), and freeattr().

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

◆ unviewsubgraphsattr()

static void unviewsubgraphsattr ( Agraph_t parent,
char *  name 
)
static

Definition at line 266 of file attr.c.

References agdatadict(), agfstsubg(), aghtmlstr(), aglocaldictsym(), agnewsym(), agnxtsubg(), AGRAPH, agroot(), agxget(), Agdatadict_s::dict, dtinsert, Agdatadict_s::g, getattr(), Agsym_s::id, and parent.

Referenced by setattr().

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

Variable Documentation

◆ AgDataDictDisc

Dtdisc_t AgDataDictDisc
Initial value:
= {
(int) offsetof(Agsym_t, name),
-1,
(int) offsetof(Agsym_t, link),
}
static void freesym(void *obj)
Definition attr.c:227
node NULL
Definition grammar.y:163
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:641

Definition at line 34 of file attr.c.

Referenced by agmakedatadict().

◆ AgDataRecName

char* AgDataRecName = "_AG_strdata"

Definition at line 173 of file attr.c.

Referenced by agattrrec(), agedgeattr_delete(), agmakeattrs(), agnodeattr_delete(), newedge(), and newnode().

◆ DataDictName

char DataDictName[] = "_AG_datadict"
static

Definition at line 43 of file attr.c.

Referenced by agdatadict(), and agmakedatadict().

◆ ProtoDesc

Agdesc_t ProtoDesc
static
Initial value:
= {.directed = true, .no_loop = true,
.no_write = true}

Definition at line 45 of file attr.c.

Referenced by agattr_().

◆ ProtoGraph

Agraph_t* ProtoGraph
static

Definition at line 47 of file attr.c.

Referenced by agattr_(), and agmakedatadict().