1 /* -*- c-basic-offset: 2 -*- */
2 /*
3   Copyright(C) 2016-2018  Brazil
4   Copyright(C) 2019-2021  Sutou Kouhei <kou@clear-code.com>
5 
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License version 2.1 as published by the Free Software Foundation.
9 
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14 
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19 module groonga_d.raw_string;
20 
21 
22 private static import groonga_d.groonga;
23 
24 extern(C):
25 nothrow @nogc:
26 
27 /+
28 #define GRN_RAW_STRING_INIT(string_) do { string_.value = null; string_.length = 0; } while (groonga_d.groonga.GRN_FALSE)
29 
30 #define GRN_RAW_STRING_SET(string_, bulk) if (bulk && GRN_TEXT_LEN(bulk) > 0) { string_.value = GRN_TEXT_VALUE(bulk); string_.length = GRN_TEXT_LEN(bulk); } else { string_.value = null; string_.length = 0; }
31 
32 #define GRN_RAW_STRING_FILL(string_, bulk) if (bulk && GRN_TEXT_LEN(bulk) > 0) { string_.value = GRN_TEXT_VALUE(bulk); string_.length = GRN_TEXT_LEN(bulk); }
33 
34 #define GRN_RAW_STRING_EQUAL(string_, other_string) (string_.length == other_string.length && memcmp(string_.value, other_string.value, string_.length) == 0)
35 
36 #define GRN_RAW_STRING_EQUAL_CSTRING(string_, cstring) (cstring ? (string_.length == strlen(cstring) && memcmp(string_.value, cstring, string_.length) == 0) : (string_.length == 0))
37 
38 #define GRN_RAW_STRING_EQUAL_CSTRING_CI(string_, cstring) ((cstring) ? ((string_.length == strlen(cstring)) && (grn_strncasecmp(string_.value, cstring, string_.length) == 0)) : (string_.length == 0))
39 
40 #define GRN_RAW_STRING_START_WITH_CSTRING(string_, cstring) (cstring ? (string_.length >= strlen(cstring) && memcmp(string_.value, cstring, strlen(cstring)) == 0) : (string_.length == 0))
41 +/
42 
43 struct grn_raw_string
44 {
45 	const (char)* value;
46 	size_t length;
47 }
48 
49 //GRN_API
50 void grn_raw_string_lstrip(groonga_d.groonga.grn_ctx* ctx, grn_raw_string* string_);
51 
52 //GRN_API
53 bool grn_raw_string_have_sub_string(groonga_d.groonga.grn_ctx* ctx, .grn_raw_string* string_, .grn_raw_string* sub_string);
54 
55 //GRN_API
56 bool grn_raw_string_have_sub_string_cstring(groonga_d.groonga.grn_ctx* ctx, .grn_raw_string* string_, const (char)* sub_cstring);