CUBRID Engine  latest
parse_type.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * parse_type.cpp
21  */
22 
23 #include "parse_type.hpp"
24 #include "parser.h"
25 #include "string_buffer.hpp"
26 
28 {
29  static const char *arr[] =
30  {
31  "GENERIC TYPE NONE",
32  "GENERIC ANY STRING TYPE",
33  "GENERIC VARIABLE STRING TYPE",
34  "GENERIC ANY CHAR TYPE",
35  "GENERIC ANY NCHAR TYPE",
36  "GENERIC ANY BIT TYPE",
37  "GENERIC DISCRETE NUMBER TYPE",
38  "GENERIC ANY NUMBER TYPE",
39  "GENERIC DATE TYPE",
40  "GENERIC DATETIME TYPE",
41  "GENERIC SEQUENCE TYPE",
42  "GENERIC LOB TYPE",
43  "GENERIC QUERY TYPE", // what is this?
44  "GENERIC PRIMITIVE TYPE",
45  "GENERIC ANY TYPE",
46  "JSON VALUE",
47  "JSON DOCUMENT",
48  "GENERIC SCALAR TYPE",
49  };
50  static_assert ((PT_GENERIC_TYPE_SCALAR + 1) == (sizeof (arr) / sizeof (const char *)),
51  "miss-match between pt_generic_type_enum and its name array");
52  return arr[type];
53 }
54 
55 //--------------------------------------------------------------------------------
57 {
58  switch (type.type)
59  {
61  //sb("%s", str(type.val.type));
62  sb ("%s", pt_show_type_enum (type.val.type));
63  break;
65  sb ("%s", pt_generic_type_to_string (type.val.generic_type));
66  break;
67  case pt_arg_type::INDEX:
68  sb ("IDX%d", type.val.index);
69  break;
70  }
71  return sb.get_buffer();
72 }
pt_generic_type_enum generic_type
Definition: parse_type.hpp:71
const char * pt_generic_type_to_string(pt_generic_type_enum type)
Definition: parse_type.cpp:27
const char * pt_arg_type_to_string_buffer(const pt_arg_type &type, string_buffer &sb)
Definition: parse_type.cpp:56
enum pt_arg_type::@135 type
const char * pt_show_type_enum(PT_TYPE_ENUM t)
const char * get_buffer() const
pt_generic_type_enum
Definition: parse_type.hpp:31
union pt_arg_type::pt_arg_type_val val