FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ini-cpp/example.cpp at master · SSARCandy/ini-cpp · GitHub
SSARCandy
/
ini-cpp
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
54
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
ini-cpp
/
example.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (34 loc) · 1.62 KB
Breadcrumbs
ini-cpp
/
example.cpp
Copy path
File metadata and controls
44 lines (34 loc) · 1.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
iostream
>
#
include
<
string
>
#
include
<
typeinfo
>
#
include
<
boost/core/demangle.hpp
>
#
include
"
ini/ini.h
"
using
namespace
inih
;
namespace
bc
=
boost::core;
int
main
() {
INIReader r{
"
./test/fixtures/config.ini
"
};
const
auto
& v1 = r.
Get
<std::string>(
"
section1
"
,
"
any
"
);
const
auto
& v2 = r.
Get
<
int
>(
"
section1
"
,
"
any
"
);
const
auto
& v3 = r.
Get
<
double
>(
"
section1
"
,
"
any
"
);
const
auto
& v4 = r.
GetVector
<
float
>(
"
section2
"
,
"
any_vec
"
);
const
auto
& v5{r.
GetVector
<std::string>(
"
section2
"
,
"
any_vec
"
)};
/*
* output
* v1 = "1" type: std::string
* v2 = 1 type: int
* v3 = 1.0 type: double
* v4 = [1, 2, 3] type: std::vector<float>
* v5 = ["1", "2", "3"] type: std::vector<std::string>
*/
std::cout <<
"
v1 =
"
<< v1 <<
"
, which is type:
"
<<
bc::demangle
(
typeid
(v1).
name
()) << std::endl;
std::cout <<
"
v2 =
"
<< v2 <<
"
, which is type:
"
<<
bc::demangle
(
typeid
(v2).
name
()) << std::endl;
std::cout <<
"
v3 =
"
<< v3 <<
"
, which is type:
"
<<
bc::demangle
(
typeid
(v3).
name
()) << std::endl;
std::cout <<
"
v4 =
"
;
for
(
auto
& v : v4) std::cout << v <<
"
"
; std::cout <<
"
, which is type:
"
<<
bc::demangle
(
typeid
(v4).
name
()) << std::endl;
std::cout <<
"
v5 =
"
;
for
(
auto
& v : v5) std::cout << v <<
"
"
; std::cout <<
"
, which is type:
"
<<
bc::demangle
(
typeid
(v5).
name
()) << std::endl;
//
section exist, key not exist
r.
InsertEntry
(
"
section1
"
,
"
my_custom_key
"
,
"
hello world
"
);
//
section&key not exist
r.
InsertEntry
(
"
new_section
"
,
"
key1
"
,
5
);
//
Dump ini to file
INIWriter::write
(
"
output.ini
"
, r);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL