Skip to content

Commit 28aed60

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

10 files changed

+50
-50
lines changed

library/lattice/test/src/usage_tetengo.lattice.viterbi_c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
// [viterbi]
1010
#include <assert.h>
11+
#include <stdbool.h>
1112
#include <stdio.h>
1213
#include <stdlib.h>
1314
#include <string.h>
@@ -240,7 +241,7 @@ tetengo_lattice_vocabulary_t* build_vocabulary()
240241
return p_vocabulary;
241242
}
242243

243-
static const char* value_of(const tetengo_lattice_node_t* const p_node, const int first)
244+
static const char* value_of(const tetengo_lattice_node_t* const p_node, const bool first)
244245
{
245246
// The value is accessible by the handle.
246247
const char* const value = (const char*)tetengo_lattice_entryView_valueOf(p_node->value_handle);

library/property/c/include/tetengo/property/propertySet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void tetengo_property_propertySet_destroy(const tetengo_property_propertySet_t*
5757
bool tetengo_property_propertySet_getBool(
5858
const tetengo_property_propertySet_t* p_property_set,
5959
const char* key,
60-
int* p_value);
60+
bool* p_value);
6161

6262
/*!
6363
\brief Sets a value in a boolean.
@@ -66,7 +66,7 @@ bool tetengo_property_propertySet_getBool(
6666
\param key A key.
6767
\param value A value.
6868
*/
69-
void tetengo_property_propertySet_setBool(tetengo_property_propertySet_t* p_property_set, const char* key, int value);
69+
void tetengo_property_propertySet_setBool(tetengo_property_propertySet_t* p_property_set, const char* key, bool value);
7070

7171
/*!
7272
\brief Returns the value in an unsigned 32-bit integer.

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

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

10-
1110
#include <stdbool.h>
1211
#include <stddef.h>
1312
#include <stdint.h> // IWYU pragma: keep
@@ -40,7 +39,7 @@ void tetengo_property_storage_destroy(const tetengo_property_storage_t* p_storag
4039
\retval true When the value is set to p_value.
4140
\retval false Otherwise.
4241
*/
43-
bool tetengo_property_storage_getBool(const tetengo_property_storage_t* p_storage, const char* key, int* p_value);
42+
bool tetengo_property_storage_getBool(const tetengo_property_storage_t* p_storage, const char* key, bool* p_value);
4443

4544
/*!
4645
\brief Sets a value in a boolean.
@@ -49,7 +48,7 @@ bool tetengo_property_storage_getBool(const tetengo_property_storage_t* p_storag
4948
\param key A key.
5049
\param value A value.
5150
*/
52-
void tetengo_property_storage_setBool(tetengo_property_storage_t* p_storage, const char* key, int value);
51+
void tetengo_property_storage_setBool(tetengo_property_storage_t* p_storage, const char* key, bool value);
5352

5453
/*!
5554
\brief Returns the value in an unsigned 32-bit integer.

library/property/c/src/tetengo_property_propertySet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void tetengo_property_propertySet_destroy(const tetengo_property_propertySet_t*
8080
bool tetengo_property_propertySet_getBool(
8181
const tetengo_property_propertySet_t* const p_property_set,
8282
const char* const key,
83-
int* const p_value)
83+
bool* const p_value)
8484
{
8585
try
8686
{
@@ -100,7 +100,7 @@ bool tetengo_property_propertySet_getBool(
100100
const auto o_cpp_value = p_property_set->p_cpp_property_set->get_bool(key);
101101
if (o_cpp_value)
102102
{
103-
*p_value = *o_cpp_value ? 1 : 0;
103+
*p_value = *o_cpp_value;
104104
}
105105
return static_cast<bool>(o_cpp_value);
106106
}
@@ -113,7 +113,7 @@ bool tetengo_property_propertySet_getBool(
113113
void tetengo_property_propertySet_setBool(
114114
tetengo_property_propertySet_t* const p_property_set,
115115
const char* const key,
116-
const int value)
116+
const bool value)
117117
{
118118
try
119119
{

library/property/c/src/tetengo_property_storage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void tetengo_property_storage_destroy(const tetengo_property_storage_t* const p_
5353
bool tetengo_property_storage_getBool(
5454
const tetengo_property_storage_t* const p_storage,
5555
const char* const key,
56-
int* const p_value)
56+
bool* const p_value)
5757
{
5858
try
5959
{
@@ -73,7 +73,7 @@ bool tetengo_property_storage_getBool(
7373
const auto o_cpp_value = p_storage->p_cpp_storage->get_bool(key);
7474
if (o_cpp_value)
7575
{
76-
*p_value = *o_cpp_value ? 1 : 0;
76+
*p_value = *o_cpp_value;
7777
}
7878
return static_cast<bool>(o_cpp_value);
7979
}
@@ -86,7 +86,7 @@ bool tetengo_property_storage_getBool(
8686
void tetengo_property_storage_setBool(
8787
tetengo_property_storage_t* const p_storage,
8888
const char* const key,
89-
const int value)
89+
const bool value)
9090
{
9191
try
9292
{

library/property/test/src/test_tetengo.property.file_storage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ BOOST_AUTO_TEST_CASE(load)
442442
BOOST_TEST_REQUIRE(p_storage);
443443

444444
{
445-
auto value = static_cast<int>(0);
445+
auto value = false;
446446
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
447447
BOOST_TEST_REQUIRE(result);
448448
BOOST_TEST(value);
@@ -532,7 +532,7 @@ BOOST_AUTO_TEST_CASE(load)
532532
BOOST_TEST_REQUIRE(p_storage);
533533

534534
{
535-
auto value = static_cast<int>(0);
535+
auto value = false;
536536
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
537537
BOOST_TEST(!result);
538538
}
@@ -565,7 +565,7 @@ BOOST_AUTO_TEST_CASE(load)
565565
BOOST_TEST_REQUIRE(p_storage);
566566

567567
{
568-
auto value = static_cast<int>(0);
568+
auto value = false;
569569
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
570570
BOOST_TEST(!result);
571571
}
@@ -598,7 +598,7 @@ BOOST_AUTO_TEST_CASE(load)
598598
BOOST_TEST_REQUIRE(p_storage);
599599

600600
{
601-
auto value = static_cast<int>(0);
601+
auto value = false;
602602
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
603603
BOOST_TEST(!result);
604604
}
@@ -631,7 +631,7 @@ BOOST_AUTO_TEST_CASE(load)
631631
BOOST_TEST_REQUIRE(p_storage);
632632

633633
{
634-
auto value = static_cast<int>(0);
634+
auto value = false;
635635
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
636636
BOOST_TEST_REQUIRE(result);
637637
BOOST_TEST(value);

library/property/test/src/test_tetengo.property.property_set.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ BOOST_AUTO_TEST_CASE(get_bool)
8989
BOOST_SCOPE_EXIT_END;
9090
BOOST_TEST_REQUIRE(p_property_set);
9191

92-
auto value = static_cast<int>(0);
92+
auto value = false;
9393
const auto result = tetengo_property_propertySet_getBool(p_property_set, "alpha", &value);
9494
BOOST_TEST(!result);
9595
}
9696
{
97-
auto value = static_cast<int>(0);
97+
auto value = false;
9898
const auto result = tetengo_property_propertySet_getBool(nullptr, "alpha", &value);
9999
BOOST_TEST(!result);
100100
}
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(get_bool)
109109
BOOST_SCOPE_EXIT_END;
110110
BOOST_TEST_REQUIRE(p_property_set);
111111

112-
auto value = static_cast<int>(0);
112+
auto value = false;
113113
const auto result = tetengo_property_propertySet_getBool(p_property_set, nullptr, &value);
114114
BOOST_TEST(!result);
115115
}
@@ -163,8 +163,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
163163
BOOST_SCOPE_EXIT_END;
164164
BOOST_TEST_REQUIRE(p_property_set);
165165

166-
tetengo_property_propertySet_setBool(p_property_set, "alpha", 0);
167-
auto value = static_cast<int>(0);
166+
tetengo_property_propertySet_setBool(p_property_set, "alpha", false);
167+
auto value = false;
168168
const auto result = tetengo_property_propertySet_getBool(p_property_set, "alpha", &value);
169169
BOOST_TEST_REQUIRE(result);
170170
BOOST_TEST(!value);
@@ -180,14 +180,14 @@ BOOST_AUTO_TEST_CASE(set_bool)
180180
BOOST_SCOPE_EXIT_END;
181181
BOOST_TEST_REQUIRE(p_property_set);
182182

183-
tetengo_property_propertySet_setBool(p_property_set, "alpha", 1);
184-
auto value = static_cast<int>(0);
183+
tetengo_property_propertySet_setBool(p_property_set, "alpha", true);
184+
auto value = false;
185185
const auto result = tetengo_property_propertySet_getBool(p_property_set, "alpha", &value);
186186
BOOST_TEST_REQUIRE(result);
187187
BOOST_TEST(value);
188188
}
189189
{
190-
tetengo_property_propertySet_setBool(nullptr, "alpha", 0);
190+
tetengo_property_propertySet_setBool(nullptr, "alpha", false);
191191
}
192192
{
193193
auto* const p_storage_loader = tetengo_property_storageLoader_createMemoryStorageLoader();
@@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(set_bool)
200200
BOOST_SCOPE_EXIT_END;
201201
BOOST_TEST_REQUIRE(p_property_set);
202202

203-
tetengo_property_propertySet_setBool(p_property_set, nullptr, 0);
203+
tetengo_property_propertySet_setBool(p_property_set, nullptr, false);
204204
}
205205
}
206206

library/property/test/src/test_tetengo.property.storage.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ BOOST_AUTO_TEST_CASE(get_bool)
9696
BOOST_TEST_REQUIRE(p_storage);
9797

9898
const auto key = std::filesystem::path{ "hoge" } / "fuga";
99-
auto value = static_cast<int>(0);
99+
auto value = false;
100100
BOOST_TEST(!tetengo_property_storage_getBool(p_storage, key.string().c_str(), &value));
101101
}
102102
{
103103
const auto key = std::filesystem::path{ "hoge" } / "fuga";
104-
auto value = static_cast<int>(0);
104+
auto value = false;
105105
BOOST_TEST(!tetengo_property_storage_getBool(nullptr, key.string().c_str(), &value));
106106
}
107107
{
@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(get_bool)
120120
BOOST_SCOPE_EXIT_END;
121121
BOOST_TEST_REQUIRE(p_storage);
122122

123-
auto value = static_cast<int>(0);
123+
auto value = false;
124124
BOOST_TEST(!tetengo_property_storage_getBool(p_storage, nullptr, &value));
125125
}
126126
{
@@ -186,8 +186,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
186186
BOOST_TEST_REQUIRE(p_storage);
187187

188188
const auto key = std::filesystem::path{ "hoge" } / "fuga";
189-
tetengo_property_storage_setBool(p_storage, key.string().c_str(), 0);
190-
auto value = static_cast<int>(0);
189+
tetengo_property_storage_setBool(p_storage, key.string().c_str(), false);
190+
auto value = false;
191191
BOOST_TEST(tetengo_property_storage_getBool(p_storage, key.string().c_str(), &value));
192192
BOOST_TEST(!value);
193193
}
@@ -208,8 +208,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
208208
BOOST_TEST_REQUIRE(p_storage);
209209

210210
const auto key = std::filesystem::path{ "hoge" } / "fuga";
211-
tetengo_property_storage_setBool(p_storage, key.string().c_str(), 1);
212-
auto value = static_cast<int>(0);
211+
tetengo_property_storage_setBool(p_storage, key.string().c_str(), true);
212+
auto value = false;
213213
BOOST_TEST(tetengo_property_storage_getBool(p_storage, key.string().c_str(), &value));
214214
BOOST_TEST(value);
215215
}
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
230230
BOOST_TEST_REQUIRE(p_storage);
231231

232232
const auto key = std::filesystem::path{ "hoge" } / "fuga";
233-
tetengo_property_storage_setBool(nullptr, key.string().c_str(), 1);
234-
auto value = static_cast<int>(0);
233+
tetengo_property_storage_setBool(nullptr, key.string().c_str(), true);
234+
auto value = false;
235235
BOOST_TEST(!tetengo_property_storage_getBool(p_storage, key.string().c_str(), &value));
236236
}
237237
{
@@ -251,8 +251,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
251251
BOOST_TEST_REQUIRE(p_storage);
252252

253253
const auto key = std::filesystem::path{ "hoge" } / "fuga";
254-
tetengo_property_storage_setBool(p_storage, nullptr, 1);
255-
auto value = static_cast<int>(0);
254+
tetengo_property_storage_setBool(p_storage, nullptr, true);
255+
auto value = false;
256256
BOOST_TEST(!tetengo_property_storage_getBool(p_storage, key.string().c_str(), &value));
257257
}
258258
}

library/property/test/src/test_tetengo.property.storage_proxy.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ BOOST_AUTO_TEST_CASE(get_bool)
6262
BOOST_SCOPE_EXIT_END;
6363
BOOST_TEST_REQUIRE(p_storage);
6464

65-
auto value = static_cast<int>(0);
65+
auto value = false;
6666
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
6767
BOOST_TEST(!result);
6868
}
6969
{
70-
auto value = static_cast<int>(0);
70+
auto value = false;
7171
const auto result = tetengo_property_storage_getBool(nullptr, "alpha", &value);
7272
BOOST_TEST(!result);
7373
}
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(get_bool)
8888
BOOST_SCOPE_EXIT_END;
8989
BOOST_TEST_REQUIRE(p_storage);
9090

91-
auto value = static_cast<int>(0);
91+
auto value = false;
9292
const auto result = tetengo_property_storage_getBool(p_storage, nullptr, &value);
9393
BOOST_TEST(!result);
9494
}
@@ -158,8 +158,8 @@ BOOST_AUTO_TEST_CASE(set_bool)
158158
BOOST_SCOPE_EXIT_END;
159159
BOOST_TEST_REQUIRE(p_storage);
160160

161-
tetengo_property_storage_setBool(p_storage, "alpha", 0);
162-
auto value = static_cast<int>(0);
161+
tetengo_property_storage_setBool(p_storage, "alpha", false);
162+
auto value = false;
163163
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
164164
BOOST_TEST_REQUIRE(result);
165165
BOOST_TEST(!value);
@@ -181,14 +181,14 @@ BOOST_AUTO_TEST_CASE(set_bool)
181181
BOOST_SCOPE_EXIT_END;
182182
BOOST_TEST_REQUIRE(p_storage);
183183

184-
tetengo_property_storage_setBool(p_storage, "alpha", 1);
185-
auto value = static_cast<int>(0);
184+
tetengo_property_storage_setBool(p_storage, "alpha", true);
185+
auto value = false;
186186
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
187187
BOOST_TEST_REQUIRE(result);
188188
BOOST_TEST(value);
189189
}
190190
{
191-
tetengo_property_storage_setBool(nullptr, "alpha", 0);
191+
tetengo_property_storage_setBool(nullptr, "alpha", false);
192192
}
193193
{
194194
auto* const p_real_loader = tetengo_property_storageLoader_createMemoryStorageLoader();
@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(set_bool)
207207
BOOST_SCOPE_EXIT_END;
208208
BOOST_TEST_REQUIRE(p_storage);
209209

210-
tetengo_property_storage_setBool(p_storage, nullptr, 0);
210+
tetengo_property_storage_setBool(p_storage, nullptr, false);
211211
}
212212
}
213213

library/property/test/src/test_tetengo.property.windows_registry_storage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ BOOST_AUTO_TEST_CASE(load)
292292
BOOST_TEST(p_storage);
293293

294294
{
295-
auto value = static_cast<int>(0);
295+
auto value = false;
296296
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
297297
BOOST_TEST(!result);
298298
}
299299
{
300-
auto value = static_cast<int>(0);
300+
auto value = false;
301301
const auto result = tetengo_property_storage_getBool(p_storage, "bravo", &value);
302302
BOOST_TEST(!result);
303303
}
@@ -330,13 +330,13 @@ BOOST_AUTO_TEST_CASE(load)
330330
BOOST_TEST(p_storage);
331331

332332
{
333-
auto value = static_cast<int>(0);
333+
auto value = false;
334334
const auto result = tetengo_property_storage_getBool(p_storage, "alpha", &value);
335335
BOOST_TEST_REQUIRE(result);
336336
BOOST_TEST(!value);
337337
}
338338
{
339-
auto value = static_cast<int>(0);
339+
auto value = false;
340340
const auto result = tetengo_property_storage_getBool(p_storage, "bravo", &value);
341341
BOOST_TEST_REQUIRE(result);
342342
BOOST_TEST(value);

0 commit comments

Comments
 (0)