Skip to content

Commit 7929dad

Browse files
committed
Change the boolean ints to bool #212
1 parent e3cef4f commit 7929dad

File tree

6 files changed

+50
-44
lines changed

6 files changed

+50
-44
lines changed

library/trie/c/include/tetengo/trie/storage.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#if !defined(TETENGO_TRIE_STORAGE_H)
88
#define TETENGO_TRIE_STORAGE_H
99

10+
#include <stdbool.h>
1011
#include <stddef.h>
1112
#if defined(_WIN32)
1213
#include <wchar.h>
@@ -117,10 +118,10 @@ int tetengo_trie_storage_baseAt(const tetengo_trie_storage_t* p_storage, size_t
117118
\param base_check_index A base-check index.
118119
\param base A base value.
119120
120-
\retval non-zero On no error.
121-
\retval 0 Otherwise.
121+
\retval true On no error.
122+
\retval false Otherwise.
122123
*/
123-
int tetengo_trie_storage_setBaseAt(tetengo_trie_storage_t* p_storage, size_t base_check_index, int base);
124+
bool tetengo_trie_storage_setBaseAt(tetengo_trie_storage_t* p_storage, size_t base_check_index, int base);
124125

125126
/*!
126127
\brief Returns the check value.
@@ -139,10 +140,10 @@ unsigned char tetengo_trie_storage_checkAt(const tetengo_trie_storage_t* p_stora
139140
\param base_check_index A base-check index.
140141
\param check A check value.
141142
142-
\retval non-zero On no error.
143-
\retval 0 Otherwise.
143+
\retval true On no error.
144+
\retval false Otherwise.
144145
*/
145-
int tetengo_trie_storage_setCheckAt(tetengo_trie_storage_t* p_storage, size_t base_check_index, unsigned char check);
146+
bool tetengo_trie_storage_setCheckAt(tetengo_trie_storage_t* p_storage, size_t base_check_index, unsigned char check);
146147

147148
/*!
148149
\brief Returns the value count.
@@ -171,10 +172,10 @@ const void* tetengo_trie_storage_valueAt(const tetengo_trie_storage_t* p_storage
171172
\param p_value A pointer to a value object. Must not be NULL.
172173
\param value_size A value size.
173174
174-
\retval non-zero On no error.
175-
\retval 0 Otherwise.
175+
\retval true On no error.
176+
\retval false Otherwise.
176177
*/
177-
int tetengo_trie_storage_addValueAt(
178+
bool tetengo_trie_storage_addValueAt(
178179
tetengo_trie_storage_t* p_storage,
179180
size_t value_index,
180181
const void* p_value,
@@ -196,10 +197,10 @@ double tetengo_trie_storage_fillingRate(const tetengo_trie_storage_t* p_storage)
196197
\param path A file path.
197198
\param fixed_value_size The value size if it is fixed. Or 0 if the size is variable.
198199
199-
\retval non-zero On no error.
200-
\retval 0 Otherwise.
200+
\retval true On no error.
201+
\retval false Otherwise.
201202
*/
202-
int tetengo_trie_storage_serialize(
203+
bool tetengo_trie_storage_serialize(
203204
const tetengo_trie_storage_t* p_storage,
204205
const path_character_type* path,
205206
size_t fixed_value_size);

library/trie/c/include/tetengo/trie/trie.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#if !defined(TETENGO_TRIE_TRIE_H)
88
#define TETENGO_TRIE_TRIE_H
99

10+
#include <stdbool.h>
1011
#include <stddef.h>
1112

1213

@@ -118,14 +119,14 @@ tetengo_trie_trie_t* tetengo_trie_trie_createWithStorage(tetengo_trie_storage_t*
118119
void tetengo_trie_trie_destroy(const tetengo_trie_trie_t* p_trie);
119120

120121
/*!
121-
\brief Returns non-zero when the trie is empty.
122+
\brief Returns true when the trie is empty.
122123
123124
\param p_trie A pointer to a trie.
124125
125-
\retval non-zero When the trie is empty.
126-
\retval 0 Otherwise.
126+
\retval true When the trie is empty.
127+
\retval false Otherwise.
127128
*/
128-
int tetengo_trie_trie_empty(const tetengo_trie_trie_t* p_trie);
129+
bool tetengo_trie_trie_empty(const tetengo_trie_trie_t* p_trie);
129130

130131
/*!
131132
\brief Returns the size of the trie.
@@ -137,15 +138,15 @@ int tetengo_trie_trie_empty(const tetengo_trie_trie_t* p_trie);
137138
size_t tetengo_trie_trie_size(const tetengo_trie_trie_t* p_trie);
138139

139140
/*!
140-
\brief Returns non-zero when the trie contains the given key.
141+
\brief Returns true when the trie contains the given key.
141142
142143
\param p_trie A pointer to a trie.
143144
\param key A key.
144145
145-
\retval non-zero When the trie contains the given key.
146-
\retval 0 Otherwise.
146+
\retval true When the trie contains the given key.
147+
\retval false Otherwise.
147148
*/
148-
int tetengo_trie_trie_contains(const tetengo_trie_trie_t* p_trie, const char* key);
149+
bool tetengo_trie_trie_contains(const tetengo_trie_trie_t* p_trie, const char* key);
149150

150151
/*!
151152
\brief Finds the value object correspoinding the given key.

library/trie/c/include/tetengo/trie/trieIterator.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#if !defined(TETENGO_TRIE_TRIEITERATOR_H)
88
#define TETENGO_TRIE_TRIEITERATOR_H
99

10+
#include <stdbool.h>
11+
1012

1113
#if defined(__cplusplus)
1214
extern "C" {
@@ -50,14 +52,14 @@ void tetengo_trie_trieIterator_destroy(const tetengo_trie_trieIterator_t* p_iter
5052
const void* tetengo_trie_trieIterator_get(const tetengo_trie_trieIterator_t* p_iterator);
5153

5254
/*!
53-
\brief Returns non-zero when the iterator will return more elements.
55+
\brief Returns true when the iterator will return more elements.
5456
5557
\param p_iterator A pointer to an iterator.
5658
57-
\retval non-zero When the iterator will return more elements.
58-
\retval 0 Otherwise.
59+
\retval true When the iterator will return more elements.
60+
\retval false Otherwise.
5961
*/
60-
int tetengo_trie_trieIterator_hasNext(const tetengo_trie_trieIterator_t* p_iterator);
62+
bool tetengo_trie_trieIterator_hasNext(const tetengo_trie_trieIterator_t* p_iterator);
6163

6264
/*!
6365
\brief Increments the iterator.

library/trie/c/src/tetengo_trie_storage.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int tetengo_trie_storage_baseAt(const tetengo_trie_storage_t* const p_storage, c
187187
}
188188
}
189189

190-
int tetengo_trie_storage_setBaseAt(
190+
bool tetengo_trie_storage_setBaseAt(
191191
tetengo_trie_storage_t* const p_storage,
192192
const size_t base_check_index,
193193
const int base)
@@ -201,11 +201,11 @@ int tetengo_trie_storage_setBaseAt(
201201

202202
p_storage->p_cpp_storage()->set_base_at(base_check_index, base);
203203

204-
return 1;
204+
return true;
205205
}
206206
catch (...)
207207
{
208-
return 0;
208+
return false;
209209
}
210210
}
211211

@@ -226,7 +226,7 @@ unsigned char tetengo_trie_storage_checkAt(const tetengo_trie_storage_t* const p
226226
}
227227
}
228228

229-
int tetengo_trie_storage_setCheckAt(
229+
bool tetengo_trie_storage_setCheckAt(
230230
tetengo_trie_storage_t* const p_storage,
231231
const size_t base_check_index,
232232
const unsigned char check)
@@ -240,11 +240,11 @@ int tetengo_trie_storage_setCheckAt(
240240

241241
p_storage->p_cpp_storage()->set_check_at(base_check_index, check);
242242

243-
return 1;
243+
return true;
244244
}
245245
catch (...)
246246
{
247-
return 0;
247+
return false;
248248
}
249249
}
250250

@@ -287,7 +287,7 @@ const void* tetengo_trie_storage_valueAt(const tetengo_trie_storage_t* const p_s
287287
}
288288
}
289289

290-
int tetengo_trie_storage_addValueAt(
290+
bool tetengo_trie_storage_addValueAt(
291291
tetengo_trie_storage_t* const p_storage,
292292
const size_t value_index,
293293
const void* const p_value,
@@ -308,11 +308,11 @@ int tetengo_trie_storage_addValueAt(
308308
static_cast<const char*>(p_value), static_cast<const char*>(p_value) + value_size);
309309
p_storage->p_cpp_storage()->add_value_at(value_index, std::move(value_bytes));
310310

311-
return 1;
311+
return true;
312312
}
313313
catch (...)
314314
{
315-
return 0;
315+
return false;
316316
}
317317
}
318318

@@ -333,7 +333,7 @@ double tetengo_trie_storage_fillingRate(const tetengo_trie_storage_t* const p_st
333333
}
334334
}
335335

336-
int tetengo_trie_storage_serialize(
336+
bool tetengo_trie_storage_serialize(
337337
const tetengo_trie_storage_t* const p_storage,
338338
const path_character_type* const path,
339339
const size_t fixed_value_size)
@@ -355,11 +355,11 @@ int tetengo_trie_storage_serialize(
355355
};
356356
p_storage->p_cpp_storage()->serialize(stream, serializer);
357357

358-
return 1;
358+
return true;
359359
}
360360
catch (...)
361361
{
362-
return 0;
362+
return false;
363363
}
364364
}
365365

library/trie/c/src/tetengo_trie_trie.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void tetengo_trie_trie_destroy(const tetengo_trie_trie_t* const p_trie)
134134
{}
135135
}
136136

137-
int tetengo_trie_trie_empty(const tetengo_trie_trie_t* const p_trie)
137+
bool tetengo_trie_trie_empty(const tetengo_trie_trie_t* const p_trie)
138138
{
139139
try
140140
{
@@ -143,11 +143,11 @@ int tetengo_trie_trie_empty(const tetengo_trie_trie_t* const p_trie)
143143
throw std::invalid_argument{ "p_trie is NULL." };
144144
}
145145

146-
return std::empty(*p_trie->p_cpp_trie) ? 1 : 0;
146+
return std::empty(*p_trie->p_cpp_trie);
147147
}
148148
catch (...)
149149
{
150-
return 0;
150+
return false;
151151
}
152152
}
153153

@@ -168,7 +168,7 @@ size_t tetengo_trie_trie_size(const tetengo_trie_trie_t* const p_trie)
168168
}
169169
}
170170

171-
int tetengo_trie_trie_contains(const tetengo_trie_trie_t* const p_trie, const char* const key)
171+
bool tetengo_trie_trie_contains(const tetengo_trie_trie_t* const p_trie, const char* const key)
172172
{
173173
try
174174
{
@@ -185,7 +185,7 @@ int tetengo_trie_trie_contains(const tetengo_trie_trie_t* const p_trie, const ch
185185
}
186186
catch (...)
187187
{
188-
return 0;
188+
return false;
189189
}
190190
}
191191

library/trie/c/src/tetengo_trie_trieIterator.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <stdexcept>
1010
#include <utility>
1111

12+
#include <boost/stl_interfaces/iterator_interface.hpp>
13+
1214
#include <tetengo/trie/storage.h>
1315
#include <tetengo/trie/trie.h>
1416
#include <tetengo/trie/trie.hpp>
@@ -75,7 +77,7 @@ const void* tetengo_trie_trieIterator_get(const tetengo_trie_trieIterator_t* p_i
7577
}
7678
}
7779

78-
int tetengo_trie_trieIterator_hasNext(const tetengo_trie_trieIterator_t* p_iterator)
80+
bool tetengo_trie_trieIterator_hasNext(const tetengo_trie_trieIterator_t* p_iterator)
7981
{
8082
try
8183
{
@@ -84,11 +86,11 @@ int tetengo_trie_trieIterator_hasNext(const tetengo_trie_trieIterator_t* p_itera
8486
throw std::invalid_argument{ "p_iterator is NULL." };
8587
}
8688

87-
return p_iterator->p_cpp_iterator_pair->first == p_iterator->p_cpp_iterator_pair->second ? 0 : 1;
89+
return p_iterator->p_cpp_iterator_pair->first != p_iterator->p_cpp_iterator_pair->second;
8890
}
8991
catch (...)
9092
{
91-
return 0;
93+
return false;
9294
}
9395
}
9496

0 commit comments

Comments
 (0)