Debian Codegraph @

lib/gvc/gvc.h

raw
1 /**
2 * @file
3 * @brief Graphviz context library
4 * @ingroup gvc_api
5 *
6 * **libgvc** provides a context for applications wishing to manipulate
7 * and render graphs. It provides command line parsing,
8 * common rendering code, and a plugin mechanism for renderers.
9 *
10 * [man 3 gvc](https://graphviz.org/pdf/gvc.3.pdf)
11 *
12 */
13
14 /*************************************************************************
15 * Copyright (c) 2011 AT&T Intellectual Property
16 * All rights reserved. This program and the accompanying materials
17 * are made available under the terms of the Eclipse Public License v1.0
18 * which accompanies this distribution, and is available at
19 * https://www.eclipse.org/legal/epl-v10.html
20 *
21 * Contributors: Details at https://graphviz.org
22 *************************************************************************/
23
24 #pragma once
25
26 #include <stdbool.h>
27 #include <stddef.h>
28
29 #include "types.h"
30 #include "gvplugin.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #ifdef GVDLL
37 #ifdef GVC_EXPORTS
38 #define GVC_API __declspec(dllexport)
39 #else
40 #define GVC_API __declspec(dllimport)
41 #endif
42 #endif
43
44 #ifndef GVC_API
45 #define GVC_API /* nothing */
46 #endif
47
48 /// @defgroup gvc_api Graphviz context library (GVC) API
49 /// @ingroup public_apis
50 /// @{
51
52 #define LAYOUT_DONE(g) (agbindrec(g, "Agraphinfo_t", 0, true) && GD_drawing(g))
53
54 /* misc */
55 /* FIXME - this needs eliminating or renaming */
56 GVC_API void gvToggle(int);
57
58 /* set up a graphviz context */
59 GVC_API GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading);
60
61 /* set up a graphviz context - and init graph - retaining old API */
62 GVC_API GVC_t *gvContext(void);
63 /* set up a graphviz context - and init graph - with builtins */
64 GVC_API GVC_t *gvContextPlugins(const lt_symlist_t *builtins, int demand_loading);
65
66 /* get information associated with a graphviz context */
67 GVC_API char **gvcInfo(GVC_t*);
68 GVC_API char *gvcVersion(GVC_t*);
69 GVC_API char *gvcBuildDate(GVC_t*);
70
71 /* parse command line args - minimally argv[0] sets layout engine */
72 GVC_API int gvParseArgs(GVC_t *gvc, int argc, char **argv);
73 GVC_API graph_t *gvNextInputGraph(GVC_t *gvc);
74 GVC_API graph_t *gvPluginsGraph(GVC_t *gvc);
75
76 /* Compute a layout using a specified engine */
77 GVC_API int gvLayout(GVC_t *gvc, graph_t *g, const char *engine);
78
79 /* Compute a layout using layout engine from command line args */
80 GVC_API int gvLayoutJobs(GVC_t *gvc, graph_t *g);
81
82 /* Check if a layout has been done */
83 GVC_API bool gvLayoutDone(graph_t *g);
84
85 /* Render layout into string attributes of the graph */
86 GVC_API void attach_attrs(graph_t *g);
87
88 /* Render layout in a specified format to an open FILE */
89 GVC_API int gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out);
90
91 /* Render layout in a specified format to a file with the given name */
92 GVC_API int gvRenderFilename(GVC_t *gvc, graph_t *g, const char *format, const char *filename);
93
94 /* Render layout in a specified format to an GVC_APIal context */
95 GVC_API int gvRenderContext(GVC_t *gvc, graph_t *g, const char *format, void *context);
96
97 /* Render layout in a specified format to a malloc'ed string */
98 GVC_API int gvRenderData(GVC_t *gvc, graph_t *g, const char *format,
99 char **result, size_t *length);
100
101 /* Free memory allocated and pointed to by *result in gvRenderData */
102 GVC_API void gvFreeRenderData (char* data);
103
104 /* Render layout according to -T and -o options found by gvParseArgs */
105 GVC_API int gvRenderJobs(GVC_t *gvc, graph_t *g);
106
107 /* Clean up layout data structures - layouts are not nestable (yet) */
108 GVC_API int gvFreeLayout(GVC_t *gvc, graph_t *g);
109
110 /* Clean up graphviz context */
111 GVC_API void gvFinalize(GVC_t *gvc);
112 GVC_API int gvFreeContext(GVC_t *gvc);
113
114 /* Return list of plugins of type kind.
115 * kind would normally be "render" "layout" "textlayout" "device" "loadimage"
116 * The size of the list is stored in sz.
117 * The caller is responsible for freeing the storage. This involves
118 * freeing each item, then the list.
119 * Returns NULL on error, or if there are no plugins.
120 * In the former case, sz is unchanged; in the latter, sz = 0.
121 */
122 GVC_API char **gvPluginList(GVC_t *gvc, const char *kind, int *sz);
123
124 /** Add a library from your user application
125 * @param gvc Graphviz context to add library to
126 * @param lib library to add
127 */
128 GVC_API void gvAddLibrary(GVC_t *gvc, gvplugin_library_t *lib);
129
130 /** Perform a Transitive Reduction on a graph
131 * @param g graph to be transformed.
132 */
133 GVC_API int gvToolTred(graph_t *g);
134
135 /// @}
136
137 #undef GVC_API
138
139 #ifdef __cplusplus
140 }
141 #endif