Imported Upstream version 1.5
[routino] / src / tagging.h
1 /***************************************
2  $Header: /home/amb/routino/src/RCS/tagging.h,v 1.2 2010/05/23 10:18:59 amb Exp $
3
4  The data types for the tagging rules.
5
6  Part of the Routino routing software.
7  ******************/ /******************
8  This file Copyright 2010 Andrew M. Bishop
9
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Affero General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU Affero General Public License for more details.
19
20  You should have received a copy of the GNU Affero General Public License
21  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  ***************************************/
23
24 #ifndef TAGGING_H
25 #define TAGGING_H    /*+ To stop multiple inclusions. +*/
26
27
28 /* Data types */
29
30 /*+ A structure to contain the tagging action. +*/
31 typedef struct _TaggingAction
32 {
33  int output;                    /*+ A flag to indicate if the output tags or input tags are to be changed. +*/
34
35  char *k;                       /*+ The tag key (or NULL). +*/
36  char *v;                       /*+ The tag value (or NULL). +*/
37 }
38  TaggingAction;
39
40
41 /*+ A structure to contain the tagging rule. +*/
42 typedef struct _TaggingRule
43 {
44  char *k;                       /*+ The tag key (or NULL). +*/
45  char *v;                       /*+ The tag value (or NULL). +*/
46
47  TaggingAction *actions;        /*+ The actions to take. +*/
48  int            nactions;       /*+ The number of actions. +*/
49 }
50  TaggingRule;
51
52
53 /*+ A structure to contain the list of rules and associated information. +*/
54 typedef struct _TaggingRuleList
55 {
56  TaggingRule *rules;            /*+ The array of rules. +*/
57  int          nrules;           /*+ The number of rules. +*/
58 }
59  TaggingRuleList;
60
61
62 /*+ A structure to hold a list of tags to be processed. +*/
63 typedef struct _TagList
64 {
65  int ntags;                     /*+ The number of tags. +*/
66
67  char **k;                      /*+ The list of tag keys. +*/
68  char **v;                      /*+ The list of tag values. +*/
69 }
70  TagList;
71
72
73 /* Variables */
74
75 extern TaggingRuleList NodeRules;
76 extern TaggingRuleList WayRules;
77 extern TaggingRuleList RelationRules;
78
79
80 /* Functions */
81
82 int ParseXMLTaggingRules(const char *filename);
83
84 TaggingRule *AppendTaggingRule(TaggingRuleList *rules,const char *k,const char *v);
85 void AppendTaggingAction(TaggingRule *rule,const char *k,const char *v,int output);
86
87 TagList *NewTagList(void);
88 void AppendTag(TagList *tags,const char *k,const char *v);
89 void ModifyTag(TagList *tags,const char *k,const char *v);
90 void DeleteTagList(TagList *tags);
91
92 TagList *ApplyTaggingRules(TaggingRuleList *rules,TagList *tags);
93
94
95 #endif /* TAGGING_H */