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_linked_list.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 
26 #ifndef STRING_LINKED_LIST_H
27 #define STRING_LINKED_LIST_H
28 
29 #include <stdio.h>
30 
32 #include "linked_list.h"
33 #include "memory_allocations.h"
34 
35 
36 #ifdef __cplusplus
37  extern "C" {
38 #endif
39 
40 
49 typedef struct StringListNode
50 {
53 
55  char *sln_string_s;
56 
60 
61 
70 GRASSROOTS_UTIL_API StringListNode *AllocateStringListNode (const char * const str_p, const MEM_FLAG mem_flag);
71 
72 
73 
86 GRASSROOTS_UTIL_API bool InitStringListNode (StringListNode *node_p, const char * const value_s, const MEM_FLAG mem_flag);
87 
88 
97 GRASSROOTS_UTIL_API void FreeStringListNode (ListItem * const node_p);
98 
99 
107 
108 
116 
117 
129 
130 
140 
141 
142 
152 GRASSROOTS_UTIL_API bool AddStringToStringLinkedList (LinkedList *list_p, const char * const str_p, const MEM_FLAG mem_flag);
153 
154 
155 
156 
157 
159 
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* #ifndef STRING_LINKED_LIST_H */
166 
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
StringListNode::AddStringToStringLinkedList
bool AddStringToStringLinkedList(LinkedList *list_p, const char *const str_p, const MEM_FLAG mem_flag)
Create and add a new StringListNode to the tail of a LinkedList.
StringListNode::sln_string_s
char * sln_string_s
The string value.
Definition: string_linked_list.h:55
StringListNode::InitStringListNode
bool InitStringListNode(StringListNode *node_p, const char *const value_s, const MEM_FLAG mem_flag)
Initialise a StringListNode.
StringListNode::AllocateStringListNode
StringListNode * AllocateStringListNode(const char *const str_p, const MEM_FLAG mem_flag)
Create a new StringListNode.
StringListNode::ClearStringListNode
void ClearStringListNode(StringListNode *node_p)
Clear a StringListNode by deleting its sln_string_s value as appropriate.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
StringListNode::sln_node
ListItem sln_node
The ListNode.
Definition: string_linked_list.h:52
StringListNode
A ListNode for LinkedLists that also stores a string value.
Definition: string_linked_list.h:49
memory_allocations.h
linked_list.h
A doubly-linked list.
StringListNode::GetStringLinkedListAsString
char * GetStringLinkedListAsString(const LinkedList *const src_p)
Get a new string that is the concatenation of all of the entries on a StringLinkedList.
StringListNode::sln_string_flag
MEM_FLAG sln_string_flag
How the memory for the string is stored and freed.
Definition: string_linked_list.h:58
StringListNode::AllocateStringLinkedList
LinkedList * AllocateStringLinkedList(void)
Create a LinkedList designed to hold StringListNodes.
StringListNode::CopyStringLinkedList
LinkedList * CopyStringLinkedList(const LinkedList *const src_p)
Make a copy of a LinkedList of StringListNodes.
DetachStringFromStringListNode
char * DetachStringFromStringListNode(StringListNode *node_p)
StringListNode::FreeStringListNode
void FreeStringListNode(ListItem *const node_p)
Free a StringListNode.
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43