GRU - Generic Reusable Utilities
gru_keypair.h
Go to the documentation of this file.
1 /*
2  Copyright 2017 Otavio Rodolfo Piske
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 
17 #ifndef GRU_KEYPAIR_H
18 #define GRU_KEYPAIR_H
19 
20 #include <stdint.h>
21 #include <string.h>
22 
23 #include "gru_portable.h"
24 #include "gru_status.h"
25 #include "gru_variant.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
34 typedef struct gru_keypair_t_ {
35  char *key;
38 
45 
51 
57 
58 
65 gru_export bool gru_keypair_set_key(gru_keypair_t *kp, const char *key);
66 
67 
75 
76 
83 gru_export bool gru_keypair_key_equals(const gru_keypair_t *kp, const char *key);
84 
85 
92 gru_export gru_keypair_t *gru_keypair_parse(const char *str, gru_status_t *status);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif //GRU_KEYPAIR_H
gru_export gru_keypair_t * gru_keypair_clone(const gru_keypair_t *kp, gru_status_t *status)
Clone a key/pair struct.
Definition: gru_keypair.c:61
gru_export gru_keypair_t * gru_keypair_new(gru_status_t *status)
Creates a new key/pair struct.
Definition: gru_keypair.c:18
gru_export bool gru_keypair_set_key(gru_keypair_t *kp, const char *key)
Sets the key.
Definition: gru_keypair.c:51
gru_export bool gru_keypair_key_equals(const gru_keypair_t *kp, const char *key)
Checks whether a key/pair struct matches the key.
Definition: gru_keypair.c:85
struct gru_keypair_t_ gru_keypair_t
A key/pair structure.
gru_export void gru_keypair_destroy_list_item(void **ptr)
Destructor wrapper for gru_list_clean.
Definition: gru_keypair.c:47
gru_export void gru_keypair_destroy(gru_keypair_t **ptr)
Destroys a key/pair struct.
Definition: gru_keypair.c:33
gru_export gru_keypair_t * gru_keypair_parse(const char *str, gru_status_t *status)
Parse a string in the format key=pair and returns an gru_keypair_t.
Definition: gru_keypair.c:97
#define gru_export
Definition: gru_portable.h:19
A key/pair structure.
Definition: gru_keypair.h:34
gru_variant_t * pair
Definition: gru_keypair.h:36
char * key
Definition: gru_keypair.h:35
Status type.
Definition: gru_status.h:47
An abstract struct that can hold different types.
Definition: gru_variant.h:43