OmniSciDB  5ade3759e0
StringLike.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
26 #ifndef STRING_LIKE_H
27 #define STRING_LIKE_H
28 
29 #include "../Shared/funcannotations.h"
30 
31 #include <cstdint>
32 
33 /*
34  * @brief string_like performs the SQL LIKE and ILIKE operation
35  * @param str string argument to be matched against pattern. single-byte
36  * character set only for now. null-termination not required.
37  * @param str_len length of str
38  * @param pattern pattern string for SQL LIKE
39  * @param pat_len length of pattern
40  * @param escape_char the escape character. '\\' is expected by default.
41  * @param is_ilike true if it is ILIKE, i.e., case-insensitive matching
42  * @return true if str matchs pattern, false otherwise. error condition
43  * not handled for now.
44  */
45 extern "C" DEVICE bool string_like(const char* str,
46  int str_len,
47  const char* pattern,
48  int pat_len,
49  char escape_char);
50 
51 extern "C" DEVICE bool string_ilike(const char* str,
52  int str_len,
53  const char* pattern,
54  int pat_len,
55  char escape_char);
56 
57 extern "C" DEVICE bool string_like_simple(const char* str,
58  const int32_t str_len,
59  const char* pattern,
60  const int32_t pat_len);
61 
62 extern "C" DEVICE bool string_ilike_simple(const char* str,
63  const int32_t str_len,
64  const char* pattern,
65  const int32_t pat_len);
66 
67 extern "C" DEVICE bool string_lt(const char* lhs,
68  const int32_t lhs_len,
69  const char* rhs,
70  const int32_t rhs_len);
71 
72 extern "C" DEVICE bool string_le(const char* lhs,
73  const int32_t lhs_len,
74  const char* rhs,
75  const int32_t rhs_len);
76 
77 extern "C" DEVICE bool string_eq(const char* lhs,
78  const int32_t lhs_len,
79  const char* rhs,
80  const int32_t rhs_len);
81 
82 extern "C" DEVICE bool string_ne(const char* lhs,
83  const int32_t lhs_len,
84  const char* rhs,
85  const int32_t rhs_len);
86 
87 extern "C" DEVICE bool string_ge(const char* lhs,
88  const int32_t lhs_len,
89  const char* rhs,
90  const int32_t rhs_len);
91 
92 extern "C" DEVICE bool string_gt(const char* lhs,
93  const int32_t lhs_len,
94  const char* rhs,
95  const int32_t rhs_len);
96 
97 extern "C" DEVICE int32_t StringCompare(const char* s1,
98  const int32_t s1_len,
99  const char* s2,
100  const int32_t s2_len);
101 
102 #endif // STRING_LIKE_H
DEVICE bool string_like(const char *str, int str_len, const char *pattern, int pat_len, char escape_char)
DEVICE bool string_ilike(const char *str, int str_len, const char *pattern, int pat_len, char escape_char)
DEVICE bool string_ge(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:325
DEVICE bool string_like_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
Definition: StringLike.cpp:43
DEVICE bool string_gt(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:318
DEVICE bool string_le(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:311
#define DEVICE
DEVICE bool string_ilike_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
Definition: StringLike.cpp:59
DEVICE int32_t StringCompare(const char *s1, const int32_t s1_len, const char *s2, const int32_t s2_len)
Definition: StringLike.cpp:268
DEVICE bool string_lt(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:304
DEVICE bool string_ne(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:339
DEVICE bool string_eq(const char *lhs, const int32_t lhs_len, const char *rhs, const int32_t rhs_len)
Definition: StringLike.cpp:332