ba8e1a84bb14ce25b4c491f0486acdd5c41505b6
[com/gs-lite.git] / src / ftacmp / generate_utils.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 __GENERATE_UTILS_H_DEFINED__
16 #define __GENERATE_UTILS_H_DEFINED__
17
18 #include <string>
19 #include <map>
20
21 #include "parse_fta.h"
22 #include "analyze_fta.h"
23 #include "nic_def.h"
24
25 //              This file contains functions used by more than one
26 //              code generation system.
27
28
29 //              replaces dots in node names with undescores - dots are illegal in C variable names
30 std::string normalize_name(std::string name);
31
32
33 //      name of tuple struct
34
35 std::string generate_tuple_name(std::string node_name);
36
37
38 //              LFTA allocation function name.
39
40 std::string generate_alloc_name(std::string node_name);
41
42
43 //              The name of the schema definition string.
44
45 std::string generate_schema_string_name(std::string node_name);
46
47
48 //              Generate representations of a tuple.
49 //              LFTA and HFTA use slightly different names.
50
51 std::string generate_tuple_struct(std::string node_name,
52                                                         std::vector<scalarexp_t *> sl_list);
53
54 std::string generate_host_tuple_struct(table_def *td);
55 std::string generate_host_name_tuple_struct(table_def *td);
56
57
58 //              convert internal tuple format to exteral tuple format.
59 //              mostly, perform htonl conversions.
60
61 std::string generate_hfta_finalize_tuple(table_def *td);
62
63
64
65 //              make code translation so that it embeds
66 //              as a C-string -- escape the escape characters.
67
68 std::string make_C_embedded_string(std::string &instr);
69
70 //              pack, unpack tuple struct for use by user defined operators.
71 std::string generate_host_tuple_pack(table_def *td);
72 std::string generate_host_tuple_unpack(table_def *td);
73
74 int split_string(char *instr,char sep, char **words,int max_words);
75
76
77 // # random numbers for hashing
78 #define NRANDS 100
79
80
81 #endif
82