Skip to content

Commit d24e452

Browse files
committed
Code format
1 parent 326a58c commit d24e452

File tree

5 files changed

+289
-153
lines changed

5 files changed

+289
-153
lines changed

demo.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
@brief INI Parser Library
33
4-
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
4+
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
55
66
@date 2025-05-12
77
@version 1.0
@@ -13,8 +13,9 @@
1313
#include "ini_parser.h"
1414
#include <stdio.h>
1515

16-
int main(void) {
17-
const char *iniContent =
16+
int main(void)
17+
{
18+
const char *iniContent =
1819
"\n" // Empty line
1920
"[section1]\n"
2021
" key1 = value1 \n"
@@ -24,9 +25,10 @@ int main(void) {
2425
"[section2]\n"
2526
"keyA=valueA\n"
2627
"emptyKey=\n";
27-
2828
ini_context_t ctx = {0};
29-
if (!ini_initialize(&ctx, iniContent, strlen(iniContent))) {
29+
30+
if(!ini_initialize(&ctx, iniContent, strlen(iniContent)))
31+
{
3032
fprintf(stderr, "Initialization failed\n");
3133
return 1;
3234
}
@@ -35,13 +37,13 @@ int main(void) {
3537
printf("Section1 exists: %s\n", ini_hasSection(&ctx, "section1") ? "Yes" : "No");
3638
printf("Section3 exists: %s\n", ini_hasSection(&ctx, "section3") ? "Yes" : "No");
3739

38-
if (ini_getValue(&ctx, "section1", "key1", value, sizeof(value))) {
40+
if(ini_getValue(&ctx, "section1", "key1", value, sizeof(value)))
41+
{
3942
printf("section1.key1 = '%s'\n", value);
4043
}
4144

42-
printf("emptyKey has value: %s\n",
45+
printf("emptyKey has value: %s\n",
4346
ini_hasValue(&ctx, "section2", "emptyKey") ? "Yes" : "No");
44-
4547
ini_cleanup(&ctx);
4648
return 0;
4749
}

demo.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
@brief INI Parser Library
33
4-
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
4+
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
55
66
@date 2025-05-12
77
@version 1.0
@@ -13,8 +13,9 @@
1313
#include <cstring>
1414
#include "ini_parser.h"
1515

16-
int main() {
17-
const char* iniContent =
16+
int main()
17+
{
18+
const char *iniContent =
1819
"\n"
1920
"[section1]\n"
2021
" key1 = value1 \n"
@@ -24,26 +25,27 @@ int main() {
2425
"[section2]\n"
2526
"keyA=valueA\n"
2627
"emptyKey=\n";
27-
2828
ini_context_t ctx{};
29-
if (!ini_initialize(&ctx, iniContent, std::strlen(iniContent))) {
29+
30+
if(!ini_initialize(&ctx, iniContent, std::strlen(iniContent)))
31+
{
3032
std::cerr << "Initialization failed\n";
3133
return 1;
3234
}
3335

3436
char value[256];
35-
std::cout << "Section1 exists: "
37+
std::cout << "Section1 exists: "
3638
<< (ini_hasSection(&ctx, "section1") ? "Yes" : "No") << "\n";
37-
std::cout << "Section3 exists: "
39+
std::cout << "Section3 exists: "
3840
<< (ini_hasSection(&ctx, "section3") ? "Yes" : "No") << "\n";
3941

40-
if (ini_getValue(&ctx, "section1", "key1", value, sizeof(value))) {
42+
if(ini_getValue(&ctx, "section1", "key1", value, sizeof(value)))
43+
{
4144
std::cout << "section1.key1 = '" << value << "'\n";
4245
}
4346

44-
std::cout << "emptyKey has value: "
47+
std::cout << "emptyKey has value: "
4548
<< (ini_hasValue(&ctx, "section2", "emptyKey") ? "Yes" : "No") << "\n";
46-
4749
ini_cleanup(&ctx);
4850
return 0;
4951
}

ini_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
@brief INI Parser Library
33
4-
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
4+
A lightweight, single-header, speed and safety focused INI file parsing library written in C with C++ compatibility. Designed for simplicity and portability, this parser provides a low-footprint solution to decode INI format.
55
66
@date 2025-05-12
77
@version 1.0

0 commit comments

Comments
 (0)