-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cc
44 lines (36 loc) · 1.06 KB
/
demo.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2025. Doomhowl Interactive - bramtechs/brambasiel
* MIT License. Absolutely no warranty.
*
* File created on: 04-01-2025
*/
#include <fstream>
#include <iostream>
#include <multini.hh>
#include <sstream>
using namespace multini;
int main(int argc, char** argv)
{
std::ifstream file("grocery_list.ini", std::ios::in);
if (!file.is_open()) {
std::cerr << "Failed to open file\n";
return EXIT_FAILURE;
}
std::ostringstream ss;
ss << file.rdbuf();
std::string fileContent = ss.str();
multini::INIReader reader(fileContent);
if (reader.hasErrors()) {
std::cerr << reader.errors() << '\n';
return EXIT_FAILURE;
}
// INIReader inherits std::multimap
// https://en.cppreference.com/w/cpp/container/multimap
for (const auto& [header, content] : reader) {
std::cout << "found header: " << header << '\n';
for (const auto& [key, value] : content) {
std::cout << " with entry: " << key << "=" << value << '\n';
}
}
return EXIT_SUCCESS;
}