-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (55 loc) · 1.97 KB
/
Copy pathmain.cpp
File metadata and controls
65 lines (55 loc) · 1.97 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// =============================================================================
// Ptree Loader
// =============================================================================
// Usage example for Ptree Loader
//
// @author Dwoggurd (2024)
// =============================================================================
#include <print>
#include <PtreeLoader.h>
#include <filesystem>
// -----------------------------------------------------------------------------
template<ptree_loader::PtreeFileFormat T>
void TestPtreeLoader( const std::filesystem::path &fsPath )
{
boost::property_tree::ptree pt;
ptree_loader::PtreeLoader<T> ptLoader( pt );
ptLoader.Load( fsPath );
std::print( "{}", ptLoader.DumpDiag() );
std::print( "{}", ptLoader.DumpPtree() );
}
// -----------------------------------------------------------------------------
// main()
// -----------------------------------------------------------------------------
int main( int argc, char *argv[] )
{
std::print(
"--------------------------------\n"
"| Ptree Loader |\n"
"--------------------------------\n" );
if ( argc < 2 )
{
std::print( "Usage: PtreeLoader <filename>" );
return 0;
}
const std::filesystem::path fsPath{ argv[1] };
const std::string ext{ fsPath.extension().string() };
// Test PtreeLoader for various file formats (xml/json/info)
if ( ext == ".xml" )
{
std::print( "Assuming XML format...\n" );
TestPtreeLoader<ptree_loader::PtreeFileFormat::xml>( fsPath );
}
else if ( ext == ".json" )
{
std::print( "Assuming JSON format...\n" );
TestPtreeLoader<ptree_loader::PtreeFileFormat::json>( fsPath );
}
else if ( ext == ".info" )
{
std::print( "Assuming INFO format...\n" );
TestPtreeLoader<ptree_loader::PtreeFileFormat::info>( fsPath );
}
return 0;
}
// -----------------------------------------------------------------------------