// File: snawaz[P]cson/test.cpp
// Function: main
int main()
{
	using namespace test;

	auto x = cson
	(
	 	name = "Rafi", 
		age = 55,
		dict = cson
		(
			name = 1947, 
			age = "The type of age is deduced now which is std::string", 
			fun = [](std::string const & name) { std::cout << "Hello " << name << std::endl; },
			items = {"Shaan", "udit", "Sonu"}
		),
		fun = {1,2,3,4}, 
		work = "Singing"
	);

	x.dict.fun("Sarfaraz Nawaz");

	std::cout << x.name << "," << x.age <<"," << x.work << std::endl;
	x.name="Mukesh";
	x.age++; //well it is int
	std::cout << x.name << "," << x.age <<"," << x.work << std::endl;

	std::cout << x << std::endl;
	std::cout << x[work] << std::endl;

	std::cout << x[dict][age] << std::endl;
	std::cout << x.dict[age] << std::endl;
	std::cout << x[dict].age << std::endl;

	for(auto const & key : x.keys()) {
		std::cout << "key => " << key << std::endl;
    }

    std::cout << "---- iterate using .for_each ----" << std::endl;
    // we can also iterate over keys and values, but for that we have to
    // use .for_each() method passing a generic lambda (requires C++14 or above)
    auto printable_values = cson(
        name = "Rafi",
		age = 55,
		dict = cson
		(
			name = 1947,
			age = "The type of age is deduced now which is std::string"
		),
		work = "Singing"
	);

    printable_values.for_each([](std::string const & key, auto && value) {
        // note: in each iteration the type of 'value' could be different, which is why it's declared to be `auto`
        std::cout << key << " : " << value << std::endl;
    });
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movl $0x0, -0x4(%rbp)
leaq 0x9dd9(%rip), %rsi      # 0xc102
leaq 0x5cd4(%rip), %rdx      # 0x8004
leaq -0xd0(%rbp), %rdi
callq 0x3fd0
movl $0x37, -0xd8(%rbp)
leaq 0x9db6(%rip), %rdi      # 0xc103
leaq -0xd8(%rbp), %rsi
callq 0x4050
movl %eax, -0x3e0(%rbp)
jmp 0x2361
movl -0x3e0(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl $0x79b, -0x180(%rbp)    # imm = 0x79B
leaq 0x9d84(%rip), %rdi      # 0xc102
leaq -0x180(%rbp), %rsi
callq 0x4070
movl %eax, -0x3e4(%rbp)
jmp 0x2392
movl -0x3e4(%rbp), %eax
movl %eax, -0x17c(%rbp)
leaq 0x9d5e(%rip), %rsi      # 0xc103
leaq 0x5c5d(%rip), %rdx      # 0x8009
leaq -0x1a0(%rbp), %rdi
callq 0x4090
jmp 0x23ba
leaq 0x9d45(%rip), %rdi      # 0xc106
leaq -0x1a2(%rbp), %rsi
callq 0x2e40
jmp 0x23cf
movq 0x99d2(%rip), %rax      # 0xbda8
movq %rax, -0x1e0(%rbp)
movups 0x99b4(%rip), %xmm0     # 0xbd98
movaps %xmm0, -0x1f0(%rbp)
leaq -0x1f0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq $0x3, -0x1c8(%rbp)
movq -0x1d0(%rbp), %rdx
movq -0x1c8(%rbp), %rcx
leaq 0x9cee(%rip), %rsi      # 0xc107
leaq -0x1c0(%rbp), %rdi
callq 0x4110
jmp 0x2427
leaq -0x178(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
leaq -0x1a1(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
callq 0x2df0
jmp 0x2451
leaq 0x9cad(%rip), %rsi      # 0xc105
leaq -0x130(%rbp), %rdi
leaq -0x178(%rbp), %rdx
callq 0x2e50
jmp 0x246d
movl $0x1, -0x228(%rbp)
movl $0x2, -0x224(%rbp)
movl $0x3, -0x220(%rbp)
movl $0x4, -0x21c(%rbp)
leaq -0x228(%rbp), %rax
movq %rax, -0x218(%rbp)
movq $0x4, -0x210(%rbp)
movq -0x218(%rbp), %rdx
movq -0x210(%rbp), %rcx
leaq 0x9c43(%rip), %rsi      # 0xc106
leaq -0x208(%rbp), %rdi
callq 0x41f0
jmp 0x24d1
leaq 0x9c2c(%rip), %rsi      # 0xc104
leaq 0x5b6e(%rip), %rdx      # 0x804d
leaq -0x248(%rbp), %rdi
callq 0x42d0
jmp 0x24ed
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xd4(%rbp), %rdx
leaq -0x130(%rbp), %rcx
leaq -0x208(%rbp), %r8
leaq -0x248(%rbp), %r9
callq 0x2da0
jmp 0x251e
leaq -0x248(%rbp), %rdi
callq 0x4350
leaq -0x208(%rbp), %rdi
callq 0x4370
leaq -0x130(%rbp), %rdi
callq 0x2e80
leaq -0x178(%rbp), %rdi
callq 0x2ea0
leaq -0x1c0(%rbp), %rdi
callq 0x4390
leaq -0x1a0(%rbp), %rdi
callq 0x43b0
leaq -0xd0(%rbp), %rdi
callq 0x43d0
leaq -0x60(%rbp), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x21b0
movq -0x3f0(%rbp), %rdx
leaq 0x5ab7(%rip), %rsi      # 0x8055
leaq -0x268(%rbp), %rdi
callq 0x2140
jmp 0x25ac
movq -0x3f8(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x2ed0
jmp 0x25c1
leaq -0x268(%rbp), %rdi
callq 0x2090
leaq -0x269(%rbp), %rdi
callq 0x2120
movq 0x99f8(%rip), %rdi      # 0xbfd8
leaq -0xb0(%rbp), %rsi
callq 0x20d0
movq %rax, -0x400(%rbp)
jmp 0x25f5
movq -0x400(%rbp), %rdi
leaq 0x5a61(%rip), %rsi      # 0x8064
callq 0x20e0
movq %rax, -0x408(%rbp)
jmp 0x2611
movq -0x408(%rbp), %rdi
movl -0x90(%rbp), %esi
callq 0x2190
movq %rax, -0x410(%rbp)
jmp 0x262c
movq -0x410(%rbp), %rdi
leaq 0x5a2a(%rip), %rsi      # 0x8064
callq 0x20e0
movq %rax, -0x418(%rbp)
jmp 0x2648
movq -0x418(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x20d0
movq %rax, -0x420(%rbp)
jmp 0x2661
movq -0x420(%rbp), %rdi
movq 0x9959(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x2676
leaq 0x59e9(%rip), %rsi      # 0x8066
leaq -0xb0(%rbp), %rdi
callq 0x2130
jmp 0x268b
movl -0x90(%rbp), %eax
incl %eax
movl %eax, -0x90(%rbp)
movq 0x9938(%rip), %rdi      # 0xbfd8
leaq -0xb0(%rbp), %rsi
callq 0x20d0
movq %rax, -0x428(%rbp)
jmp 0x26b5
movq -0x428(%rbp), %rdi
leaq 0x59a1(%rip), %rsi      # 0x8064
callq 0x20e0
movq %rax, -0x430(%rbp)
jmp 0x26d1
movq -0x430(%rbp), %rdi
movl -0x90(%rbp), %esi
callq 0x2190
movq %rax, -0x438(%rbp)
jmp 0x26ec
movq -0x438(%rbp), %rdi
leaq 0x596a(%rip), %rsi      # 0x8064
callq 0x20e0
movq %rax, -0x440(%rbp)
jmp 0x2708
movq -0x440(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x20d0
movq %rax, -0x448(%rbp)
jmp 0x2721
movq -0x448(%rbp), %rdi
movq 0x9899(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x2736
movq 0x989b(%rip), %rdi      # 0xbfd8
leaq -0xb0(%rbp), %rsi
callq 0x2f20
movq %rax, -0x450(%rbp)
jmp 0x2752
movq -0x450(%rbp), %rdi
movq 0x9868(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x2767
leaq 0x9996(%rip), %rsi      # 0xc104
leaq -0xb0(%rbp), %rdi
callq 0x2f70
movq %rax, -0x458(%rbp)
jmp 0x2783
movq -0x458(%rbp), %rsi
movq 0x9847(%rip), %rdi      # 0xbfd8
callq 0x20d0
movq %rax, -0x460(%rbp)
jmp 0x279f
movq -0x460(%rbp), %rdi
movq 0x981b(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x27b4
leaq 0x994a(%rip), %rsi      # 0xc105
leaq -0xb0(%rbp), %rdi
callq 0x2f90
movq %rax, -0x468(%rbp)
jmp 0x27d0
movq -0x468(%rbp), %rdi
leaq 0x9925(%rip), %rsi      # 0xc103
callq 0x2fb0
movq %rax, -0x470(%rbp)
jmp 0x27ec
movq -0x470(%rbp), %rsi
movq 0x97de(%rip), %rdi      # 0xbfd8
callq 0x20d0
movq %rax, -0x478(%rbp)
jmp 0x2808
movq -0x478(%rbp), %rdi
movq 0x97b2(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x281d
leaq -0x88(%rbp), %rdi
leaq 0x98d8(%rip), %rsi      # 0xc103
callq 0x2fb0
movq %rax, -0x480(%rbp)
jmp 0x2839
movq -0x480(%rbp), %rsi
movq 0x9791(%rip), %rdi      # 0xbfd8
callq 0x20d0
movq %rax, -0x488(%rbp)
jmp 0x2855
movq -0x488(%rbp), %rdi
movq 0x9765(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x286a
leaq 0x9894(%rip), %rsi      # 0xc105
leaq -0xb0(%rbp), %rdi
callq 0x2f90
movq %rax, -0x490(%rbp)
jmp 0x2886
movq -0x490(%rbp), %rsi
addq $0x8, %rsi
movq 0x9740(%rip), %rdi      # 0xbfd8
callq 0x20d0
movq %rax, -0x498(%rbp)
jmp 0x28a6
movq -0x498(%rbp), %rdi
movq 0x9714(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x28bb
leaq -0x290(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2fd0
jmp 0x28d0
leaq -0x290(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rdi
callq 0x43f0
movq %rax, -0x298(%rbp)
movq -0x278(%rbp), %rdi
callq 0x4420
movq %rax, -0x2a0(%rbp)
leaq -0x298(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x4450
testb $0x1, %al
jne 0x2a73
leaq -0x290(%rbp), %rdi
callq 0x44d0
jmp 0x2b09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2a08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x29fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x29f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x29e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x29d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x29cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x4350
leaq -0x208(%rbp), %rdi
callq 0x4370
leaq -0x130(%rbp), %rdi
callq 0x2e80
leaq -0x178(%rbp), %rdi
callq 0x2ea0
leaq -0x1c0(%rbp), %rdi
callq 0x4390
leaq -0x1a0(%rbp), %rdi
callq 0x43b0
leaq -0xd0(%rbp), %rdi
callq 0x43d0
jmp 0x2d8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2a4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x2090
leaq -0x269(%rbp), %rdi
callq 0x2120
jmp 0x2d7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2d7e
leaq -0x298(%rbp), %rdi
callq 0x4490
movq %rax, -0x2a8(%rbp)
movq 0x954b(%rip), %rdi      # 0xbfd8
leaq 0x55d9(%rip), %rsi      # 0x806d
callq 0x20e0
movq %rax, -0x4a0(%rbp)
jmp 0x2aa2
movq -0x4a0(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
callq 0x20d0
movq %rax, -0x4a8(%rbp)
jmp 0x2abe
movq -0x4a8(%rbp), %rdi
movq 0x94fc(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x2ad3
jmp 0x2ad5
leaq -0x298(%rbp), %rdi
callq 0x44b0
jmp 0x2904
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x44d0
jmp 0x2d7e
movq 0x94c8(%rip), %rdi      # 0xbfd8
leaq 0x555e(%rip), %rsi      # 0x8075
callq 0x20e0
movq %rax, -0x4b0(%rbp)
jmp 0x2b25
movq -0x4b0(%rbp), %rdi
movq 0x9495(%rip), %rsi      # 0xbfc8
callq 0x2110
jmp 0x2b3a
leaq 0x95c1(%rip), %rsi      # 0xc102
leaq 0x54bc(%rip), %rdx      # 0x8004
leaq -0x338(%rbp), %rdi
callq 0x3fd0
jmp 0x2b56
movl $0x37, -0x340(%rbp)
leaq 0x959c(%rip), %rdi      # 0xc103
leaq -0x340(%rbp), %rsi
callq 0x4050
movl %eax, -0x4b4(%rbp)
jmp 0x2b7b
movl -0x4b4(%rbp), %eax
movl %eax, -0x33c(%rbp)
movl $0x79b, -0x398(%rbp)    # imm = 0x79B
leaq 0x956a(%rip), %rdi      # 0xc102
leaq -0x398(%rbp), %rsi
callq 0x4070
movl %eax, -0x4b8(%rbp)
jmp 0x2bac
movl -0x4b8(%rbp), %eax
movl %eax, -0x394(%rbp)
leaq 0x9544(%rip), %rsi      # 0xc103
leaq 0x5443(%rip), %rdx      # 0x8009
leaq -0x3b8(%rbp), %rdi
callq 0x4090
jmp 0x2bd4
leaq -0x390(%rbp), %rdi
leaq -0x394(%rbp), %rsi
leaq -0x3b8(%rbp), %rdx
callq 0x4580
jmp 0x2bf0
leaq 0x950e(%rip), %rsi      # 0xc105
leaq -0x368(%rbp), %rdi
leaq -0x390(%rbp), %rdx
callq 0x45c0
jmp 0x2c0c
leaq 0x94f1(%rip), %rsi      # 0xc104
leaq 0x5433(%rip), %rdx      # 0x804d
leaq -0x3d8(%rbp), %rdi
callq 0x42d0
jmp 0x2c28
leaq -0x318(%rbp), %rdi
leaq -0x338(%rbp), %rsi
leaq -0x33c(%rbp), %rdx
leaq -0x368(%rbp), %rcx
leaq -0x3d8(%rbp), %r8
callq 0x4530
jmp 0x2c52
leaq -0x3d8(%rbp), %rdi
callq 0x4350
leaq -0x368(%rbp), %rdi
callq 0x45f0
leaq -0x390(%rbp), %rdi
callq 0x4610
leaq -0x3b8(%rbp), %rdi
callq 0x43b0
leaq -0x338(%rbp), %rdi
callq 0x43d0
leaq -0x318(%rbp), %rdi
callq 0x31e0
jmp 0x2c9c
leaq -0x318(%rbp), %rdi
callq 0x4630
leaq -0xb0(%rbp), %rdi
callq 0x33d0
movl -0x4(%rbp), %eax
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2d52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2d46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2d3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x2d2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x4350
leaq -0x368(%rbp), %rdi
callq 0x45f0
leaq -0x390(%rbp), %rdi
callq 0x4610
leaq -0x3b8(%rbp), %rdi
callq 0x43b0
leaq -0x338(%rbp), %rdi
callq 0x43d0
jmp 0x2d7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x4630
leaq -0xb0(%rbp), %rdi
callq 0x33d0
movq -0xe0(%rbp), %rdi
callq 0x21a0
nopw %cs:(%rax,%rax)