// File: /workspace/github_cpp_makefile_star2_O2/mgo1977[P]c---parsing-argument-options/example1.cc
// Function: main
int main(int argc, char** argv) {

    /*
     * This is a simple example, to show the usage of this tool.
     * These are the main steps to use:
     *
     *  a. create all options, between set of the existing ones you have:
     *  b. Now, the easy part: create the parser, add the options and parse it
     *
     *  Please, take a look at the documentation in the header file "Parser.h"
     *  for a full description of each option
     *
     */

    BoolOption    debug         ('d', "debug",      false, "enables the debug mode");
    StringOption  username      ('u', "username",   true , "set the username");
    IntegerOption port          ('p', "port",       false, 23, "server port");
    FloatOption   portability   ('n', "portability",false, "smart option...");
    StringListOption  book      ('j', "book",       false, "book of interest. could be more than one");

    // default value is the limit of the type. for int types => (sizeof(int) * 1024)
    std::list<int> defaultPortRange;
    defaultPortRange.push_back(1);
    defaultPortRange.push_back(sizeof(int)*1024);
    IntegerRange  portRange     ('r', "portrange",  false, defaultPortRange, "range of ports");

    Parser parser;

    parser.addOption(debug)
          .addOption(username)
          .addOption(port)
          .addOption(portability)
          .addOption(book)
          .addOption(portRange);

    vector<string> otherArguments = parser.parse(argc, argv);

    if ( debug.isSet() ) {
        cout << "debug flag was set" << endl;
    }

    // username is mandatory, so we don't need to check it
    cout << "username was set to '" << username.getValue() << "'" << endl;

    // port has a default value, so we can choose not to check it
    // and work with the default value transparently
    cout << "port was set to '" << port.getValue() << "'" << endl;


    if ( portability.isSet() ) {
        cout << "portability was set to '" << portability.getValue() << "'" << endl;
    }

    if ( book.isSet() ) {
        std::list<std::string> values = book.getValue();

        cout << "book was set with " << values.size() << " entries: ";

        for(std::list<string>::iterator entry = values.begin();
            entry != values.end();
            ++entry
        ) {
            if ( entry != values.begin() )
                cout << ", ";

            cout << "'" << *entry << "'";
        }

        cout << endl;

    }

    //if ( portRange.isSet() ) {
        std::list<int> list = portRange.getValue();
        if ( list.size() > 0 ) {
            cout << "Range seted from '" << list.front() << "' to '" << list.back() << "'." << endl;
        } else {
            cout << "is null" << std::endl;
        }
    //}
 
    // if other arguments were specified, we can easily access them
    if ( ! otherArguments.empty() ) {

        cout << "otherArguments: ";

        for(vector<string>::iterator argIter = otherArguments.begin();
            argIter != otherArguments.end();
            ++argIter
        ) {

            if ( argIter != otherArguments.begin() )
                cout << ", ";

            cout << "'" << *argIter << "'";

        }

        cout << endl;

    }


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x2fbc(%rip), %rdx      # 0x60d3
leaq 0x2fbb(%rip), %r8       # 0x60d9
leaq -0x240(%rbp), %rdi
pushq $0x64
popq %rsi
xorl %ecx, %ecx
callq 0x3944
leaq 0x2fc2(%rip), %rdx      # 0x60f8
leaq 0x2fb3(%rip), %r8       # 0x60f0
leaq -0x400(%rbp), %rdi
pushq $0x75
popq %rsi
pushq $0x1
popq %rcx
callq 0x396e
leaq -0x1e0(%rbp), %r8
movl $0x17, (%r8)
leaq 0x2fa4(%rip), %rdx      # 0x6108
leaq 0x2f96(%rip), %r9       # 0x6101
leaq -0x148(%rbp), %rdi
pushq $0x70
popq %rsi
xorl %ecx, %ecx
callq 0x39c2
leaq 0x2f8a(%rip), %rdx      # 0x610d
leaq 0x2f8f(%rip), %r8       # 0x6119
leaq -0xe0(%rbp), %rdi
pushq $0x6e
popq %rsi
xorl %ecx, %ecx
callq 0x39ee
leaq 0x2f87(%rip), %rdx      # 0x6129
leaq 0x2f85(%rip), %r8       # 0x612e
leaq -0x2d0(%rbp), %rdi
pushq $0x6a
popq %rsi
xorl %ecx, %ecx
callq 0x3a14
leaq -0x78(%rbp), %rdi
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
andq $0x0, 0x10(%rdi)
leaq -0x1e0(%rbp), %rsi
movl $0x1, (%rsi)
callq 0x3a62
leaq -0x1e0(%rbp), %rsi
movl $0x1000, (%rsi)         # imm = 0x1000
leaq -0x78(%rbp), %rdi
callq 0x3a62
leaq 0x2f5e(%rip), %rdx      # 0x6157
leaq 0x2f61(%rip), %r9       # 0x6161
leaq -0x360(%rbp), %rdi
pushq $0x72
popq %rsi
leaq -0x78(%rbp), %r8
xorl %ecx, %ecx
callq 0x3a72
leaq -0x1e0(%rbp), %rdi
callq 0x3a92
leaq -0x1e0(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x3b1e
leaq -0x400(%rbp), %rsi
movq %rax, %rdi
callq 0x3b1e
leaq -0x148(%rbp), %rsi
movq %rax, %rdi
callq 0x3b1e
leaq -0xe0(%rbp), %rsi
movq %rax, %rdi
callq 0x3b1e
leaq -0x2d0(%rbp), %rsi
movq %rax, %rdi
callq 0x3b1e
leaq -0x360(%rbp), %rsi
movq %rax, %rdi
callq 0x3b1e
leaq -0x60(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
movl %r14d, %edx
movq %rbx, %rcx
callq 0x248c
cmpb $0x1, -0x1e8(%rbp)
jne 0x32b9
movq 0x5d2b(%rip), %rdi      # 0x8fd0
leaq 0x2ec4(%rip), %rsi      # 0x6170
callq 0x21a0
movq %rax, %rdi
callq 0x20c0
movq 0x5d10(%rip), %rdi      # 0x8fd0
leaq 0x2ebc(%rip), %rsi      # 0x6183
callq 0x21a0
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x3b44
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x2190
leaq 0x2f01(%rip), %rsi      # 0x61f3
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x20b0
movq 0x5cbe(%rip), %rbx      # 0x8fd0
leaq 0x2e80(%rip), %rsi      # 0x6199
movq %rbx, %rdi
callq 0x21a0
movzbl -0xf0(%rbp), %ecx
xorl $0x1, %ecx
movl -0xec(%rbp,%rcx,4), %esi
movq %rax, %rdi
callq 0x22d0
leaq 0x2eb2(%rip), %rsi      # 0x61f3
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20c0
cmpb $0x1, -0x88(%rbp)
jne 0x339f
movq 0x5c6f(%rip), %rdi      # 0x8fd0
leaq 0x2e43(%rip), %rsi      # 0x61ab
callq 0x21a0
movzbl -0x88(%rbp), %ecx
xorl $0x1, %ecx
movss -0x84(%rbp,%rcx,4), %xmm0
movq %rax, %rdi
callq 0x2120
leaq 0x2e64(%rip), %rsi      # 0x61f3
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20c0
cmpb $0x1, -0x278(%rbp)
jne 0x345e
leaq -0x48(%rbp), %rbx
leaq -0x2d0(%rbp), %rsi
movq %rbx, %rdi
callq 0x3b6e
movq 0x5c0a(%rip), %rdi      # 0x8fd0
leaq 0x2df7(%rip), %rsi      # 0x61c4
callq 0x21a0
movq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0x20f0
leaq 0x2df2(%rip), %rsi      # 0x61d7
movq %rax, %rdi
callq 0x21a0
movq 0x5bdc(%rip), %r15      # 0x8fd0
leaq 0x2df8(%rip), %r12      # 0x61f3
leaq 0x2c73(%rip), %r13      # 0x6075
movq %rbx, %r14
movq (%r14), %r14
cmpq %rbx, %r14
je 0x3442
cmpq -0x48(%rbp), %r14
je 0x341e
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r15, %rdi
movq %r12, %rsi
callq 0x21a0
leaq 0x10(%r14), %rsi
movq %rax, %rdi
callq 0x2190
movq %rax, %rdi
movq %r12, %rsi
callq 0x21a0
jmp 0x3405
movq 0x5b87(%rip), %rdi      # 0x8fd0
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x41c2
movq 0x5b72(%rip), %rbx      # 0x8fd0
leaq -0x48(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x3b9a
cmpq $0x0, -0x38(%rbp)
je 0x34c1
movq 0x5b54(%rip), %rdi      # 0x8fd0
leaq 0x2d5f(%rip), %rsi      # 0x61e2
callq 0x21a0
movq -0x48(%rbp), %rcx
movl 0x10(%rcx), %esi
movq %rax, %rdi
callq 0x22d0
leaq 0x2d57(%rip), %rsi      # 0x61f5
movq %rax, %rdi
callq 0x21a0
movq -0x40(%rbp), %rcx
movl 0x10(%rcx), %esi
movq %rax, %rdi
callq 0x22d0
movq %rax, %rbx
leaq 0x2d3d(%rip), %rsi      # 0x61fc
jmp 0x34c8
leaq 0x2d37(%rip), %rsi      # 0x61ff
movq %rbx, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20c0
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x3558
movq 0x5ae7(%rip), %rdi      # 0x8fd0
leaq 0x2d17(%rip), %rsi      # 0x6207
callq 0x21a0
movq -0x60(%rbp), %rbx
movq 0x5ad0(%rip), %r14      # 0x8fd0
leaq 0x2cec(%rip), %r15      # 0x61f3
leaq 0x2b67(%rip), %r12      # 0x6075
cmpq -0x58(%rbp), %rbx
je 0x354c
cmpq -0x60(%rbp), %rbx
je 0x3525
movq %r14, %rdi
movq %r12, %rsi
callq 0x21a0
movq %r14, %rdi
movq %r15, %rsi
callq 0x21a0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2190
movq %rax, %rdi
movq %r15, %rsi
callq 0x21a0
addq $0x20, %rbx
jmp 0x350e
movq 0x5a7d(%rip), %rdi      # 0x8fd0
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x4202
leaq -0x60(%rbp), %rdi
callq 0x37c4
leaq -0x1e0(%rbp), %rdi
callq 0x3bc6
leaq -0x360(%rbp), %rdi
callq 0x3bf0
leaq -0x78(%rbp), %rdi
callq 0x4202
leaq -0x2d0(%rbp), %rdi
callq 0x3c24
leaq -0xe0(%rbp), %rdi
callq 0x3c8e
leaq -0x148(%rbp), %rdi
callq 0x3c8e
leaq -0x400(%rbp), %rdi
callq 0x3c58
leaq -0x240(%rbp), %rdi
callq 0x3c8e
xorl %eax, %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3628
jmp 0x3628
jmp 0x3628
jmp 0x3623
movq %rax, %rbx
jmp 0x365c
jmp 0x35ec
jmp 0x35ec
movq %rax, %rbx
jmp 0x3668
movq %rax, %rbx
jmp 0x367d
movq %rax, %rbx
jmp 0x3689
movq %rax, %rbx
jmp 0x3695
movq %rax, %rbx
jmp 0x36a1
jmp 0x362d
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20b0
jmp 0x3647
jmp 0x363b
movq %rax, %rbx
jmp 0x3650
movq %rax, %rbx
jmp 0x3647
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x41c2
jmp 0x3647
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x4202
leaq -0x60(%rbp), %rdi
callq 0x37c4
leaq -0x1e0(%rbp), %rdi
callq 0x3bc6
leaq -0x360(%rbp), %rdi
callq 0x3bf0
leaq -0x78(%rbp), %rdi
callq 0x4202
leaq -0x2d0(%rbp), %rdi
callq 0x3c24
leaq -0xe0(%rbp), %rdi
callq 0x3c8e
leaq -0x148(%rbp), %rdi
callq 0x3c8e
leaq -0x400(%rbp), %rdi
callq 0x3c58
leaq -0x240(%rbp), %rdi
callq 0x3c8e
movq %rbx, %rdi
callq 0x22e0
nop