Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gvrender_core_json.c File Reference
#include "config.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <common/macros.h>
#include <common/const.h>
#include <xdot/xdot.h>
#include <gvc/gvplugin_render.h>
#include <gvc/gvplugin_device.h>
#include <common/utils.h>
#include <gvc/gvc.h>
#include <gvc/gvio.h>
#include <gvc/gvcint.h>
#include <util/alloc.h>
#include <util/startswith.h>
#include <util/streq.h>
#include <util/unreachable.h>
Include dependency graph for gvrender_core_json.c:

Go to the source code of this file.

Data Structures

struct  state_t
 information the ID allocator needs to do its job More...
 
struct  gvid_t
 
struct  intm
 

Macros

#define ID   "id"
 
#define ND_gid(n)   (((gvid_t*)aggetrec(n, ID, 0))->id)
 
#define ED_gid(n)   (((gvid_t*)aggetrec(n, ID, 0))->id)
 
#define GD_gid(n)   (((gvid_t*)aggetrec(n, ID, 0))->id)
 

Typedefs

typedef int(* putstrfn) (void *chan, const char *str)
 
typedef int(* flushfn) (void *chan)
 

Enumerations

enum  format_type { FORMAT_JSON , FORMAT_JSON0 , FORMAT_DOT_JSON , FORMAT_XDOT_JSON }
 

Functions

static bool IS_CLUSTER (Agraph_t *s)
 
static void json_begin_graph (GVJ_t *job)
 
static void stoj (char *ins, state_t *sp, GVJ_t *job)
 
static void indent (GVJ_t *job, int level)
 
static void set_attrwf (Agraph_t *g, bool toplevel, bool value)
 
static void write_polyline (GVJ_t *job, xdot_polyline *polyline)
 
static void write_stops (GVJ_t *job, int n_stops, xdot_color_stop *stp, state_t *sp)
 
static void write_radial_grad (GVJ_t *job, xdot_radial_grad *rg, state_t *sp)
 
static void write_linear_grad (GVJ_t *job, xdot_linear_grad *lg, state_t *sp)
 
static void write_xdot (xdot_op *op, GVJ_t *job, state_t *sp)
 
static void write_xdots (char *val, GVJ_t *job, state_t *sp)
 
static bool isXDot (const char *name)
 
static void write_attrs (Agobj_t *obj, GVJ_t *job, state_t *sp)
 
static void write_hdr (Agraph_t *g, GVJ_t *job, bool top, state_t *sp)
 
static void write_graph (Agraph_t *g, GVJ_t *job, bool top, state_t *sp)
 
static void write_subg (Agraph_t *g, GVJ_t *job, state_t *sp)
 
static bool write_subgs (Agraph_t *g, GVJ_t *job, bool top, state_t *sp)
 
static int agseqasc (const void *x, const void *y)
 
static void write_edge (Agedge_t *e, GVJ_t *job, bool top, state_t *sp)
 
static int write_edges (Agraph_t *g, GVJ_t *job, bool top, state_t *sp)
 
static void write_node (Agnode_t *n, GVJ_t *job, bool top, state_t *sp)
 
static int write_nodes (Agraph_t *g, GVJ_t *job, bool top, bool has_subgs, state_t *sp)
 
static void freef (void *ident)
 
static int lookup (Dt_t *map, char *name)
 
static void insert (Dt_t *map, char *name, int v)
 
static int label_subgs (Agraph_t *g, int lbl, Dt_t *map)
 
static void json_end_graph (GVJ_t *job)
 

Variables

static Dtdisc_t intDisc
 
gvrender_engine_t json_engine
 
gvrender_features_t render_features_json1
 
gvrender_features_t render_features_json
 
gvdevice_features_t device_features_json_nop
 
gvdevice_features_t device_features_json
 
gvplugin_installed_t gvrender_json_types []
 
gvplugin_installed_t gvdevice_json_types []
 

Macro Definition Documentation

◆ ED_gid

#define ED_gid (   n)    (((gvid_t*)aggetrec(n, ID, 0))->id)

Definition at line 54 of file gvrender_core_json.c.

◆ GD_gid

#define GD_gid (   n)    (((gvid_t*)aggetrec(n, ID, 0))->id)

Definition at line 55 of file gvrender_core_json.c.

◆ ID

#define ID   "id"

Definition at line 52 of file gvrender_core_json.c.

◆ ND_gid

#define ND_gid (   n)    (((gvid_t*)aggetrec(n, ID, 0))->id)

Definition at line 53 of file gvrender_core_json.c.

Typedef Documentation

◆ flushfn

typedef int(* flushfn) (void *chan)

Definition at line 710 of file gvrender_core_json.c.

◆ putstrfn

typedef int(* putstrfn) (void *chan, const char *str)

Definition at line 709 of file gvrender_core_json.c.

Enumeration Type Documentation

◆ format_type

Enumerator
FORMAT_JSON 
FORMAT_JSON0 
FORMAT_DOT_JSON 
FORMAT_XDOT_JSON 

Definition at line 34 of file gvrender_core_json.c.

Function Documentation

◆ agseqasc()

static int agseqasc ( const void *  x,
const void *  y 
)
static

Definition at line 434 of file gvrender_core_json.c.

References AGSEQ.

Referenced by write_edges().

Here is the caller graph for this function:

◆ freef()

static void freef ( void *  ident)
static

Definition at line 603 of file gvrender_core_json.c.

References free(), and intm::id.

Here is the call graph for this function:

◆ indent()

static void indent ( GVJ_t job,
int  level 
)
static

Definition at line 129 of file gvrender_core_json.c.

References gvputs().

Referenced by write_attrs(), write_edge(), write_edges(), write_graph(), write_hdr(), write_linear_grad(), write_node(), write_nodes(), write_radial_grad(), write_subgs(), write_xdot(), and write_xdots().

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

◆ insert()

static void insert ( Dt_t map,
char *  name,
int  v 
)
static

Definition at line 625 of file gvrender_core_json.c.

References agwarningf(), dtinsert, dtmatch, gv_alloc(), gv_strdup(), intm::id, and intm::v.

Referenced by label_subgs().

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

◆ IS_CLUSTER()

static bool IS_CLUSTER ( Agraph_t s)
static

Definition at line 57 of file gvrender_core_json.c.

References agnameof(), and startswith().

Referenced by label_subgs().

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

◆ isXDot()

static bool isXDot ( const char *  name)
static

Definition at line 340 of file gvrender_core_json.c.

References streq().

Referenced by write_attrs().

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

◆ json_begin_graph()

static void json_begin_graph ( GVJ_t job)
static

Definition at line 61 of file gvrender_core_json.c.

References attach_attrs(), FORMAT_JSON, FORMAT_JSON0, GVC_s::g, obj_state_s::g, GVJ_s::gvc, gvc, gvCloneGVC(), gvFreeCloneGVC(), gvRender(), gvplugin_active_render_s::id, NULL, GVJ_s::obj, GVJ_s::render, and obj_state_s::u.

Here is the call graph for this function:

◆ json_end_graph()

static void json_end_graph ( GVJ_t job)
static

Definition at line 712 of file gvrender_core_json.c.

References Agiodisc_s::afread, AgIoDisc, CHAR_LATIN1, Agraph_s::clos, Agclos_s::disc, state_t::doXDot, Agiodisc_s::flush, FORMAT_JSON, FORMAT_XDOT_JSON, obj_state_s::g, GD_charset, gvflush(), gvputs(), gvplugin_active_render_s::id, Agdisc_s::io, state_t::isLatin, state_t::Level, NULL, GVJ_s::obj, Agiodisc_s::putstr, GVJ_s::render, set_attrwf(), obj_state_s::u, and write_graph().

Here is the call graph for this function:

◆ label_subgs()

static int label_subgs ( Agraph_t g,
int  lbl,
Dt_t map 
)
static

Definition at line 640 of file gvrender_core_json.c.

References agfstsubg(), agnameof(), agnxtsubg(), agroot(), GD_gid, insert(), IS_CLUSTER(), and label_subgs().

Referenced by label_subgs(), and write_graph().

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

◆ lookup()

static int lookup ( Dt_t map,
char *  name 
)
static

Definition at line 618 of file gvrender_core_json.c.

References dtmatch, and intm::v.

Referenced by write_graph().

Here is the caller graph for this function:

◆ set_attrwf()

static void set_attrwf ( Agraph_t g,
bool  toplevel,
bool  value 
)
static

Definition at line 136 of file gvrender_core_json.c.

References AGATTRWF, agfstnode(), agfstout(), agfstsubg(), agnxtnode(), agnxtout(), agnxtsubg(), and set_attrwf().

Referenced by json_end_graph(), and set_attrwf().

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

◆ stoj()

static void stoj ( char *  ins,
state_t sp,
GVJ_t job 
)
static

Convert dot string to a valid json string embedded in double quotes and output

Parameters
insInput string
spState, used to determine encoding of the input string
jobOutput job

Definition at line 81 of file gvrender_core_json.c.

References free(), gvputc(), gvputs(), ins(), state_t::isLatin, and latin1ToUTF8().

Referenced by write_attrs(), write_hdr(), write_node(), write_stops(), and write_xdot().

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

◆ write_attrs()

static void write_attrs ( Agobj_t obj,
GVJ_t job,
state_t sp 
)
static

Definition at line 346 of file gvrender_core_json.c.

References agnxtattr(), agroot(), AGTYPE, agxget(), state_t::doXDot, gvputs(), indent(), isXDot(), state_t::Level, Agsym_s::name, NULL, stoj(), streq(), type, and write_xdots().

Referenced by write_edge(), write_graph(), and write_node().

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

◆ write_edge()

static void write_edge ( Agedge_t e,
GVJ_t job,
bool  top,
state_t sp 
)
static

Definition at line 461 of file gvrender_core_json.c.

References aghead, agtail, ED_gid, gvprintf(), gvputs(), indent(), state_t::Level, ND_gid, top(), and write_attrs().

Referenced by write_edges().

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

◆ write_edges()

static int write_edges ( Agraph_t g,
GVJ_t job,
bool  top,
state_t sp 
)
static

Definition at line 482 of file gvrender_core_json.c.

References agfstnode(), agfstout(), agnxtnode(), agnxtout(), agseqasc(), free(), gv_calloc(), gvputs(), indent(), state_t::Level, top(), and write_edge().

Referenced by write_graph().

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

◆ write_graph()

static void write_graph ( Agraph_t g,
GVJ_t job,
bool  top,
state_t sp 
)
static

Definition at line 656 of file gvrender_core_json.c.

References AGEDGE, agfstnode(), agfstout(), aginit(), agnameof(), AGNODE, agnxtnode(), agnxtout(), AGRAPH, dtclose(), dtopen(), Dtoset, ED_gid, GD_gid, gvprintf(), gvputs(), ID, indent(), intDisc, IS_CLUST_NODE, label_subgs(), state_t::Level, lookup(), ND_gid, top(), write_attrs(), write_edges(), write_hdr(), write_nodes(), and write_subgs().

Referenced by json_end_graph(), and write_subg().

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

◆ write_hdr()

static void write_hdr ( Agraph_t g,
GVJ_t job,
bool  top,
state_t sp 
)
static

Definition at line 368 of file gvrender_core_json.c.

References agisdirected(), agisstrict(), agnameof(), gvprintf(), gvputs(), indent(), state_t::Level, stoj(), and top().

Referenced by write_graph().

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

◆ write_linear_grad()

static void write_linear_grad ( GVJ_t job,
xdot_linear_grad lg,
state_t sp 
)
static

Definition at line 192 of file gvrender_core_json.c.

References gvprintf(), indent(), state_t::Level, xdot_linear_grad::n_stops, xdot_linear_grad::stops, write_stops(), xdot_linear_grad::x0, xdot_linear_grad::x1, xdot_linear_grad::y0, and xdot_linear_grad::y1.

Referenced by write_xdot().

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

◆ write_node()

static void write_node ( Agnode_t n,
GVJ_t job,
bool  top,
state_t sp 
)
static

Definition at line 531 of file gvrender_core_json.c.

References agnameof(), gvprintf(), gvputs(), indent(), state_t::Level, ND_gid, stoj(), top(), and write_attrs().

Referenced by write_nodes().

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

◆ write_nodes()

static int write_nodes ( Agraph_t g,
GVJ_t job,
bool  top,
bool  has_subgs,
state_t sp 
)
static

Definition at line 551 of file gvrender_core_json.c.

References agfstnode(), agnxtnode(), gvputs(), indent(), IS_CLUST_NODE, state_t::Level, top(), and write_node().

Referenced by write_graph().

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

◆ write_polyline()

static void write_polyline ( GVJ_t job,
xdot_polyline polyline 
)
static

Definition at line 155 of file gvrender_core_json.c.

References cnt(), xdot_polyline::cnt, gvprintf(), and xdot_polyline::pts.

Referenced by write_xdot().

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

◆ write_radial_grad()

static void write_radial_grad ( GVJ_t job,
xdot_radial_grad rg,
state_t sp 
)
static

Definition at line 182 of file gvrender_core_json.c.

References gvprintf(), indent(), state_t::Level, xdot_radial_grad::n_stops, xdot_radial_grad::r0, xdot_radial_grad::r1, xdot_radial_grad::stops, write_stops(), xdot_radial_grad::x0, xdot_radial_grad::x1, xdot_radial_grad::y0, and xdot_radial_grad::y1.

Referenced by write_xdot().

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

◆ write_stops()

static void write_stops ( GVJ_t job,
int  n_stops,
xdot_color_stop stp,
state_t sp 
)
static

Definition at line 168 of file gvrender_core_json.c.

References color(), gvprintf(), gvputc(), and stoj().

Referenced by write_linear_grad(), and write_radial_grad().

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

◆ write_subg()

static void write_subg ( Agraph_t g,
GVJ_t job,
state_t sp 
)
static

Definition at line 387 of file gvrender_core_json.c.

References agfstsubg(), agnxtsubg(), gvputs(), write_graph(), and write_subg().

Referenced by write_subg(), and write_subgs().

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

◆ write_subgs()

static bool write_subgs ( Agraph_t g,
GVJ_t job,
bool  top,
state_t sp 
)
static

write out subgraphs

Returns
True if the given graph has any subgraphs

Definition at line 401 of file gvrender_core_json.c.

References agfstsubg(), agnxtsubg(), GD_gid, gvprintf(), gvputs(), indent(), state_t::Level, top(), and write_subg().

Referenced by write_graph().

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

◆ write_xdot()

◆ write_xdots()

static void write_xdots ( char *  val,
GVJ_t job,
state_t sp 
)
static

Definition at line 313 of file gvrender_core_json.c.

References agwarningf(), xdot::cnt, freeXDot(), gvputs(), indent(), state_t::Level, xdot::ops, parseXDot(), and write_xdot().

Referenced by write_attrs().

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

Variable Documentation

◆ device_features_json

gvdevice_features_t device_features_json
Initial value:
= {
0,
{0.,0.},
{0.,0.},
{72.,72.},
}

Definition at line 792 of file gvrender_core_json.c.

◆ device_features_json_nop

gvdevice_features_t device_features_json_nop
Initial value:
= {
{0.,0.},
{0.,0.},
{72.,72.},
}
#define LAYOUT_NOT_REQUIRED
Definition gvcjob.h:107

Definition at line 785 of file gvrender_core_json.c.

◆ gvdevice_json_types

gvplugin_installed_t gvdevice_json_types[]
Initial value:
= {
{FORMAT_JSON, "json:json", 1, NULL, &device_features_json},
{FORMAT_JSON0, "json0:json", 1, NULL, &device_features_json},
{FORMAT_DOT_JSON, "dot_json:json", 1, NULL, &device_features_json_nop},
{FORMAT_XDOT_JSON, "xdot_json:json", 1, NULL, &device_features_json_nop},
{0, NULL, 0, NULL, NULL}
}
node NULL
Definition grammar.y:163
gvdevice_features_t device_features_json_nop
@ FORMAT_JSON0
@ FORMAT_JSON
@ FORMAT_DOT_JSON
@ FORMAT_XDOT_JSON
gvdevice_features_t device_features_json

Definition at line 807 of file gvrender_core_json.c.

◆ gvrender_json_types

gvplugin_installed_t gvrender_json_types[]
Initial value:
= {
{0, NULL, 0, NULL, NULL}
}
gvrender_engine_t json_engine
gvrender_features_t render_features_json

Definition at line 799 of file gvrender_core_json.c.

◆ intDisc

Dtdisc_t intDisc
static
Initial value:
= {
offsetof(intm, id),
-1,
offsetof(intm, link),
}
static void freef(void *ident)

Definition at line 609 of file gvrender_core_json.c.

Referenced by write_graph().

◆ json_engine

gvrender_engine_t json_engine

Definition at line 733 of file gvrender_core_json.c.

◆ render_features_json

gvrender_features_t render_features_json
Initial value:
= {
0.,
NULL,
0,
}
@ COLOR_STRING
Definition color.h:27
#define GVRENDER_DOES_TOOLTIPS
Definition gvcjob.h:103
#define GVRENDER_DOES_MAPS
Definition gvcjob.h:97
#define GVRENDER_DOES_TARGETS
Definition gvcjob.h:104
#define GVRENDER_DOES_TRANSFORM
Definition gvcjob.h:95

Definition at line 774 of file gvrender_core_json.c.

◆ render_features_json1

gvrender_features_t render_features_json1
Initial value:

Definition at line 766 of file gvrender_core_json.c.