Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
string_int_pair.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
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 
21 /*
22  * string_int_pair.h
23  *
24  * Created on: 3 Oct 2015
25  * Author: billy
26  */
27 
28 #ifndef STRING_INT_PAIR_H_
29 #define STRING_INT_PAIR_H_
30 
31 #include "typedefs.h"
32 #include "memory_allocations.h"
34 #include "jansson.h"
35 
36 
44 typedef struct StringIntPair
45 {
47  char *sip_string_s;
48 
51 
53  uint32 sip_value;
55 
56 
62 typedef struct StringIntPairArray
63 {
66 
68  uint32 sipa_size;
70 
71 
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 
89 
90 
99 
100 
113 GRASSROOTS_UTIL_API bool SetStringIntPair (StringIntPair *pair_p, char *text_s, MEM_FLAG text_mem, const uint32 value);
114 
115 
124 
125 
133 
134 
142 
158 GRASSROOTS_UTIL_API json_t *GetStringIntPairsAsResourceJSON (const StringIntPairArray *pairs_p, const char * const protocol_s);
159 
160 
173 GRASSROOTS_UTIL_API json_t *GetStringIntPairAsResourceJSON (const StringIntPair *pair_p, const char * const protocol_s);
174 
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 
181 
182 #endif /* STRING_INT_PAIR_H_ */
StringIntPairArray::SortStringIntPairsByCountDescending
void SortStringIntPairsByCountDescending(StringIntPairArray *pairs_p)
Sort the entries of a StringIntPairArray into descending order of their values.
MEM_FLAG
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
grassroots_util_library.h
GetStringIntPairsAsResourceJSON
json_t * GetStringIntPairsAsResourceJSON(const StringIntPairArray *pairs_p, const char *const protocol_s)
Get the JSON fragment representing a StringIntPairArray.
StringIntPairArray::sipa_values_p
StringIntPair * sipa_values_p
An array of StringIntPairs.
Definition: string_int_pair.h:65
StringIntPairArray
A datatype for storing a set of StringIntPairs.
Definition: string_int_pair.h:62
StringIntPair::SetStringIntPair
bool SetStringIntPair(StringIntPair *pair_p, char *text_s, MEM_FLAG text_mem, const uint32 value)
Set the data for a StringIntPair.
GetStringIntPairAsResourceJSON
json_t * GetStringIntPairAsResourceJSON(const StringIntPair *pair_p, const char *const protocol_s)
Get the JSON fragment representing a StringIntPair.
StringIntPairArray::sipa_size
uint32 sipa_size
The number of StringIntPairs in the array.
Definition: string_int_pair.h:68
typedefs.h
StringIntPairArray::AllocateStringIntPairArray
StringIntPairArray * AllocateStringIntPairArray(const uint32 size)
Allocate a StringIntPairArray of a given size.
StringIntPair::sip_string_mem
MEM_FLAG sip_string_mem
The memory flag for the key.
Definition: string_int_pair.h:50
StringIntPair::sip_string_s
char * sip_string_s
The key.
Definition: string_int_pair.h:47
StringIntPairArray::SortStringIntPairsByCountAscending
void SortStringIntPairsByCountAscending(StringIntPairArray *pairs_p)
Sort the entries of a StringIntPairArray into ascending order of their values.
StringIntPair::ClearStringIntPair
void ClearStringIntPair(StringIntPair *pair_p)
Clear the entries for a StringIntPair and freeing any memory associated with its value if appropriate...
memory_allocations.h
StringIntPair::sip_value
uint32 sip_value
The value.
Definition: string_int_pair.h:53
StringIntPairArray::FreeStringIntPairArray
void FreeStringIntPairArray(StringIntPairArray *array_p)
Free a StringIntPairArray and any memory associated from its keys where appropriate.
StringIntPair
A datatype for holding a key-value pair where the key is a c-style string and the value is an unsigne...
Definition: string_int_pair.h:44
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47