Fixed newline characters throughout the code
[com/gs-lite.git] / src / ftacmp / parse_partn.h
1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3    Licensed under the Apache License, Version 2.0 (the "License");
4    you may not use this file except in compliance with the License.
5    You may obtain a copy of the License at
6
7      http://www.apache.org/licenses/LICENSE-2.0
8
9    Unless required by applicable law or agreed to in writing, software
10    distributed under the License is distributed on an "AS IS" BASIS,
11    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12    See the License for the specific language governing permissions and
13    limitations under the License.
14  ------------------------------------------- */
15 #ifndef _PARTN_PARSE_H_INCLUDED__
16 #define _PARTN_PARSE_H_INCLUDED__
17
18 #include<stdio.h>
19 #include"parse_fta.h"
20 #include"analyze_fta.h"
21
22 /*              Interface to FTA Parser         */
23 void PartnParser_setfileinput(FILE *f);
24 void PartnParser_setstringinput(char *s);
25
26 class partn_def_t{
27 public:
28         std::string name;
29         std::string protocol;
30         std::vector<scalarexp_t *> se_list;
31         std::vector<std::string> field_list;
32
33         partn_def_t(const char *n, const char *p, se_list_t *sl){
34                 name=n;
35                 protocol=p;
36                 se_list = sl->se_list;
37         }
38
39         int verify(table_list *schema, std::string &err_msg);
40         bool is_compatible(gb_table *gb_tbl);
41 };
42
43 class partn_def_list_t{
44 public:
45         std::map<std::string, partn_def_t *> partn_map;
46
47         partn_def_list_t(partn_def_t *pd){
48                 partn_map[pd->name] = pd;
49         }
50         partn_def_list_t *append(partn_def_t *pd){
51                 if(partn_map.count(pd->name)){
52                         fprintf(stderr,"Warning, duplicate entry named %s in partition definitions, ignored.\n",pd->name.c_str());
53                 }else{
54                         partn_map[pd->name] = pd;
55                 }
56                 return this;
57         }
58
59         partn_def_t *get_partn_def(std::string n){
60                 if(partn_map.count(n))
61                         return partn_map[n];
62                 return NULL;
63         }
64
65         int verify(table_list *schema, std::string &err_msg){
66           int retval=0;
67           std::map<std::string, partn_def_t *>::iterator mspi;
68                 for(mspi=partn_map.begin(); mspi!=partn_map.end();++mspi){
69                         if((*mspi).second->verify(schema, err_msg))
70                                 retval=1;
71                 }
72                 return retval;
73         }
74
75
76 };
77
78 #endif