├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake └── InitUCMake.cmake ├── config └── Config.cmake.in ├── include └── UGraphviz │ ├── Attrs.hpp │ ├── Graph.hpp │ ├── Registry.hpp │ ├── Subgraph.hpp │ └── UGraphviz.hpp └── src ├── core ├── CMakeLists.txt ├── Graph.cpp ├── Registry.cpp └── Subgraph.cpp └── test ├── 00_basic ├── CMakeLists.txt └── main.cpp ├── 01_attr ├── CMakeLists.txt └── main.cpp ├── 02_subgraph ├── CMakeLists.txt └── main.cpp └── 03_port ├── CMakeLists.txt └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # antlr4 fils 2 | *.java 3 | *.interp 4 | *.tokens 5 | *.class 6 | 7 | _deps/ 8 | 9 | # binary files 10 | *.png 11 | *.jpg 12 | *.bmp 13 | *.gif 14 | *.dds 15 | 16 | *.zip 17 | *.7z 18 | *.rar 19 | 20 | *.pdf 21 | 22 | *.mp4 23 | 24 | # directories 25 | resources/ 26 | bin/ 27 | lib/ 28 | build/ 29 | _deps/ 30 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(UGraphviz VERSION 0.3.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake(VERSION 0.6.4) 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddSubDirsRec(src) 12 | 13 | Ubpa_Export( 14 | TARGET 15 | DIRECTORIES 16 | "include" 17 | ) 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ubpa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UGraphviz 2 | **U**bpa **Graphviz** C++ wrapper 3 | 4 | ⭐ Star us on GitHub — it helps! 5 | 6 | [![repo-size](https://img.shields.io/github/languages/code-size/Ubpa/UGraphviz?style=flat)](https://github.com/Ubpa/UGraphviz/archive/master.zip) [![tag](https://img.shields.io/github/v/tag/Ubpa/UGraphviz)](https://github.com/Ubpa/UGraphviz/tags) [![license](https://img.shields.io/github/license/Ubpa/UGraphviz)](LICENSE) 7 | 8 | ## Example 9 | 10 | ```c++ 11 | #include 12 | 13 | #include 14 | 15 | using namespace Ubpa; 16 | 17 | using namespace std; 18 | 19 | int main() { 20 | UGraphviz::Graph graph("hello world", true); 21 | 22 | auto& registry = graph.GetRegistry(); 23 | 24 | auto v_a = registry.RegisterNode("a"); 25 | auto v_b = registry.RegisterNode("b"); 26 | auto v_c = registry.RegisterNode("c"); 27 | auto v_d = registry.RegisterNode("d"); 28 | 29 | auto e_ab = registry.RegisterEdge(v_a, v_b); 30 | auto e_ac = registry.RegisterEdge(v_a, v_c); 31 | auto e_bd = registry.RegisterEdge(v_b, v_d); 32 | auto e_cd = registry.RegisterEdge(v_c, v_d); 33 | 34 | graph 35 | .AddEdge(e_ab) 36 | .AddEdge(e_ac) 37 | .AddEdge(e_bd) 38 | .AddEdge(e_cd); 39 | 40 | cout << graph.Dump() << endl; 41 | 42 | return 0; 43 | } 44 | ``` 45 | 46 | Result is 47 | 48 | ``` 49 | strict digraph "hello_world" { 50 | "a" -> "b" 51 | "a" -> "c" 52 | "b" -> "d" 53 | "c" -> "d" 54 | } 55 | ``` 56 | 57 | ![Alt text](https://g.gravizo.com/source/gravizo_mask_result?https%3A%2F%2Fraw.githubusercontent.com%2FUbpa%2FUGraphviz%2Fmaster%2FREADME.md) 58 | 59 |
60 | result graphviz source code 61 | gravizo_mask_result 62 | digraph hello_world { 63 | "a" -> "b" 64 | "a" -> "c" 65 | "b" -> "d" 66 | "c" -> "d" 67 | } 68 | gravizo_mask_result 69 |
70 | 71 | **other example** 72 | 73 | - [attribute](src/test/01_attr/main.cpp) 74 | - [subgraph](src/test/02_subgraph/main.cpp) 75 | - [port](src/test/03_port/main.cpp) 76 | 77 | ## Licensing 78 | 79 | You can copy and paste the license summary from below. 80 | 81 | ``` 82 | MIT License 83 | 84 | Copyright (c) 2020 Ubpa 85 | 86 | Permission is hereby granted, free of charge, to any person obtaining a copy 87 | of this software and associated documentation files (the "Software"), to deal 88 | in the Software without restriction, including without limitation the rights 89 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 90 | copies of the Software, and to permit persons to whom the Software is 91 | furnished to do so, subject to the following conditions: 92 | 93 | The above copyright notice and this permission notice shall be included in all 94 | copies or substantial portions of the Software. 95 | 96 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 97 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 98 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 99 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 100 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 101 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 102 | SOFTWARE. 103 | ``` 104 | -------------------------------------------------------------------------------- /cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | cmake_parse_arguments( 3 | "ARG" # prefix 4 | "" # # TRUE / FALSE 5 | "VERSION" # 6 | "" # # list 7 | ${ARGN} 8 | ) 9 | # 结果为 ARG_* 10 | # - ARG_