File indexing completed on 2024-05-19 15:27:47

0001 /* This file is part of KGraphViewer.
0002    Copyright (C) 2006-2007 Gael de Chalendar <kleag@free.fr>
0003 
0004    KGraphViewer is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; if not, write to the Free Software
0015    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0016    02110-1301, USA
0017 */
0018 
0019 #ifndef DOT_GRAPHPARSINGHELPER_H
0020 #define DOT_GRAPHPARSINGHELPER_H
0021 
0022 #include <list>
0023 #include <map>
0024 #include <string>
0025 
0026 namespace KGraphViewer
0027 {
0028 class DotGraph;
0029 class GraphSubgraph;
0030 class GraphNode;
0031 class GraphEdge;
0032 class GraphElement;
0033 
0034 struct DotGraphParsingHelper {
0035     typedef std::map<std::string, std::string> AttributesMap;
0036 
0037     DotGraphParsingHelper();
0038 
0039     void createnode(const std::string &nodeid);
0040     void createsubgraph();
0041     void setgraphattributes();
0042     void setsubgraphattributes();
0043     void setnodeattributes();
0044     void setedgeattributes();
0045     void setattributedlist();
0046     void createedges();
0047     void edgebound(const std::string &bound)
0048     {
0049         edgebounds.push_back(bound);
0050     }
0051     void finalactions();
0052     void setgraphelementattributes(GraphElement *ge, const AttributesMap &attributes);
0053 
0054     std::string attrid;
0055     std::string valid;
0056     std::string attributed;
0057     std::string subgraphid;
0058 
0059     unsigned int uniq;
0060 
0061     AttributesMap attributes;
0062     AttributesMap graphAttributes;
0063     AttributesMap nodesAttributes;
0064     AttributesMap edgesAttributes;
0065     std::list<AttributesMap> graphAttributesStack;
0066     std::list<AttributesMap> nodesAttributesStack;
0067     std::list<AttributesMap> edgesAttributesStack;
0068 
0069     std::list<std::string> edgebounds;
0070 
0071     unsigned int z;
0072     unsigned int maxZ;
0073 
0074     DotGraph *graph;
0075 
0076     GraphSubgraph *gs;
0077     GraphNode *gn;
0078     GraphEdge *ge;
0079 };
0080 
0081 }
0082 
0083 #endif