1 | /* -*- c-basic-offset: 2 -*- */ |
2 | /* |
3 | Copyright(C) 2016-2017 Brazil |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License version 2.1 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with this library; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | |
19 | #pragma once |
20 | |
21 | #include "grn.h" |
22 | |
23 | #ifdef __cplusplus |
24 | extern "C" { |
25 | #endif |
26 | |
27 | #define GRN_RAW_STRING_INIT(string) do { \ |
28 | string.value = NULL; \ |
29 | string.length = 0; \ |
30 | } while (GRN_FALSE) |
31 | |
32 | #define GRN_RAW_STRING_SET(string, bulk) \ |
33 | if (bulk && GRN_TEXT_LEN(bulk) > 0) { \ |
34 | string.value = GRN_TEXT_VALUE(bulk); \ |
35 | string.length = GRN_TEXT_LEN(bulk); \ |
36 | } else { \ |
37 | string.value = NULL; \ |
38 | string.length = 0; \ |
39 | } |
40 | |
41 | #define GRN_RAW_STRING_FILL(string, bulk) \ |
42 | if (bulk && GRN_TEXT_LEN(bulk) > 0) { \ |
43 | string.value = GRN_TEXT_VALUE(bulk); \ |
44 | string.length = GRN_TEXT_LEN(bulk); \ |
45 | } |
46 | |
47 | #define GRN_RAW_STRING_EQUAL_CSTRING(string, cstring) \ |
48 | (cstring ? \ |
49 | (string.length == strlen(cstring) && \ |
50 | memcmp(string.value, cstring, string.length) == 0) : \ |
51 | (string.length == 0)) |
52 | |
53 | typedef struct { |
54 | const char *value; |
55 | size_t length; |
56 | } grn_raw_string; |
57 | |
58 | void grn_raw_string_lstrip(grn_ctx *ctx, grn_raw_string *string); |
59 | |
60 | #ifdef __cplusplus |
61 | } |
62 | #endif |
63 | |