// File: tdv[P]boss/boss/examples/simple_enum/main.cpp
// Function: ShowAllObjects(Boss::RefObjPtr<Boss::IEnum>)
void ShowAllObjects(Boss::RefObjPtr<Boss::IEnum> collection)
{
  Boss::EnumHelper<Boss::IBase> Collection(collection);
  for (auto i = Collection.First() ; i.Get() ; i = Collection.Next())
  {
    double Price = 0;
    {
      Boss::RefObjQIPtr<MyNs::IFaces::IFixPrice> FixPrice(i);
      if (!FixPrice.Get())
        throw std::runtime_error("Unknown object.");
      if (FixPrice->GetPrice(&Price) != Boss::Status::Ok)
        throw std::runtime_error("Failed to get price.");
    }
    std::string ObjectType = "FixPrice";
    Boss::RefObjQIPtr<MyNs::IFaces::IBestOffer> BestOffer(i);
    std::vector<double> Offers;
    if (BestOffer.Get())
    {
      ObjectType = "BestOffer";
      Boss::RefObjPtr<Boss::IEnum> AllOffers;
      if (BestOffer->GetAllOffers(AllOffers.GetPPtr()) != Boss::Status::Ok)
        throw std::runtime_error("Failed to get all offers for \"BestOffer\" object.");
      Boss::EnumHelper<MyNs::IFaces::IFixPrice> OffersEnum(AllOffers);
      for (auto j = OffersEnum.First() ; j.Get() ; j = OffersEnum.Next())
      {
        double OfferPrice = 0;
        if (j->GetPrice(&OfferPrice) != Boss::Status::Ok)
          throw std::runtime_error("Failed to get offer price.");
        Offers.push_back(OfferPrice);
      }
    }
    else
    {
      Boss::RefObjQIPtr<MyNs::IFaces::IAuction> Auction(i);
      if (Auction.Get())
        ObjectType = "Auction";
    }
    std::cout << "ObjectType: " << ObjectType << std::endl;
    std::cout << "\tPrice: " << Price << std::endl;
    if (!Offers.empty())
    {
      std::cout << "\tOffers:\n\t\t";
      std::copy(std::begin(Offers), std::end(Offers),
                std::ostream_iterator<double>(std::cout, "\n\t\t"));
    }
    std::cout << std::endl;
  }
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, %rsi
movq %rsi, 0x1c0(%rsp)
leaq 0x1b0(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x1a2b0
movq 0xc0(%rsp), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x1a2f0
jmp 0x1870e
leaq 0x1b0(%rsp), %rdi
callq 0x1a3b0
leaq 0x198(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x1a3d0
jmp 0x18732
jmp 0x18734
leaq 0x198(%rsp), %rdi
callq 0x1a460
movq %rax, 0xb8(%rsp)
jmp 0x1874b
movq 0xb8(%rsp), %rax
cmpq $0x0, %rax
jne 0x187ce
movl $0x2, 0x194(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x1add0
jmp 0x19030
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x1a3b0
jmp 0x19052
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x19045
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x19021
movq $0x0, 0x188(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x1a470
jmp 0x187f1
leaq 0x180(%rsp), %rdi
callq 0x1a4c0
movq %rax, 0xb0(%rsp)
jmp 0x18808
movq 0xb0(%rsp), %rax
cmpq $0x0, %rax
jne 0x1889f
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa8(%rsp)
leaq 0xae8ef(%rip), %rsi     # 0xc7128
callq 0x365a0
jmp 0x18840
movq 0xa8(%rsp), %rdi
leaq 0xea061(%rip), %rsi     # 0x1028b0
leaq 0x143ca(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x1905f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18aa1
movq 0xa8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x23060
jmp 0x18aa1
leaq 0x180(%rsp), %rdi
callq 0x1a4d0
movq %rax, 0xa0(%rsp)
jmp 0x188b6
movq 0xa0(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq 0x188(%rsp), %rsi
callq *%rax
movl %eax, 0x9c(%rsp)
jmp 0x188d8
movl 0x9c(%rsp), %eax
cmpl $0x0, %eax
je 0x18950
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x90(%rsp)
leaq 0xae835(%rip), %rsi     # 0xc7138
callq 0x365a0
jmp 0x1890a
movq 0x90(%rsp), %rdi
leaq 0xe9f97(%rip), %rsi     # 0x1028b0
leaq 0x14300(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x1905f
movq 0x90(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x23060
jmp 0x18aa1
leaq 0x180(%rsp), %rdi
callq 0x1a4e0
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x24fc0
movq 0x88(%rsp), %rdx
leaq 0xae7cc(%rip), %rsi     # 0xc714d
leaq 0x160(%rsp), %rdi
callq 0x980f0
jmp 0x18990
leaq 0x15f(%rsp), %rdi
callq 0x24fe0
leaq 0x150(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x1a500
jmp 0x189b4
leaq 0x138(%rsp), %rdi
callq 0x1a550
leaq 0x150(%rsp), %rdi
callq 0x1a560
movq %rax, 0x80(%rsp)
jmp 0x189d8
movq 0x80(%rsp), %rax
cmpq $0x0, %rax
je 0x18d9b
leaq 0xae765(%rip), %rsi     # 0xc7156
leaq 0x160(%rsp), %rdi
callq 0x96710
jmp 0x18a00
xorl %eax, %eax
movl %eax, %esi
leaq 0x130(%rsp), %rdi
callq 0x1a570
jmp 0x18a13
leaq 0x150(%rsp), %rdi
callq 0x1a5b0
movq %rax, 0x78(%rsp)
jmp 0x18a27
leaq 0x130(%rsp), %rdi
callq 0x1a5c0
movq %rax, 0x70(%rsp)
jmp 0x18a3b
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movl %eax, 0x6c(%rsp)
jmp 0x18a54
movl 0x6c(%rsp), %eax
cmpl $0x0, %eax
je 0x18b47
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x60(%rsp)
leaq 0xae6e3(%rip), %rsi     # 0xc7160
callq 0x365a0
jmp 0x18a84
movq 0x60(%rsp), %rdi
leaq 0xe9e20(%rip), %rsi     # 0x1028b0
leaq 0x14189(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x1905f
leaq 0x180(%rsp), %rdi
callq 0x1a4e0
jmp 0x19021
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x15f(%rsp), %rdi
callq 0x24fe0
jmp 0x19021
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18ff1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18fd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18d89
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x23060
jmp 0x18d89
leaq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x1a2b0
jmp 0x18b5e
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x1a5d0
jmp 0x18b75
leaq 0x120(%rsp), %rdi
callq 0x1a3b0
leaq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x1a680
jmp 0x18b99
jmp 0x18b9b
leaq 0x118(%rsp), %rdi
callq 0x1a710
movq %rax, 0x58(%rsp)
jmp 0x18baf
movq 0x58(%rsp), %rax
cmpq $0x0, %rax
jne 0x18c2f
movl $0x5, 0x194(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x1a950
jmp 0x18d5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x1a3b0
jmp 0x18d89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18d7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x18d4e
movq $0x0, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x1a720
movq %rax, 0x50(%rsp)
jmp 0x18c4f
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq 0x110(%rsp), %rsi
callq *%rax
movl %eax, 0x4c(%rsp)
jmp 0x18c6b
movl 0x4c(%rsp), %eax
cmpl $0x0, %eax
je 0x18cd4
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x40(%rsp)
leaq 0xae501(%rip), %rsi     # 0xc7191
callq 0x365a0
jmp 0x18c97
movq 0x40(%rsp), %rdi
leaq 0xe9c0d(%rip), %rsi     # 0x1028b0
leaq 0x13f76(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x1905f
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x23060
jmp 0x18d4e
leaq 0x138(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x1a730
jmp 0x18ceb
jmp 0x18ced
leaq 0x108(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x1a7a0
jmp 0x18d04
leaq 0x118(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x1a910
jmp 0x18d1b
leaq 0x108(%rsp), %rdi
callq 0x1a950
jmp 0x18b9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x1a950
leaq 0x118(%rsp), %rdi
callq 0x1a950
jmp 0x18d7c
leaq 0x128(%rsp), %rdi
callq 0x1a970
leaq 0x130(%rsp), %rdi
callq 0x1a980
jmp 0x18e1c
leaq 0x128(%rsp), %rdi
callq 0x1a970
leaq 0x130(%rsp), %rdi
callq 0x1a980
jmp 0x18fd7
leaq 0x100(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x1a9a0
jmp 0x18db2
leaq 0x100(%rsp), %rdi
callq 0x1a9f0
movq %rax, 0x38(%rsp)
jmp 0x18dc6
movq 0x38(%rsp), %rax
cmpq $0x0, %rax
je 0x18e0f
leaq 0xae3d4(%rip), %rsi     # 0xc71ac
leaq 0x160(%rsp), %rdi
callq 0x96710
jmp 0x18de7
jmp 0x18e0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x1aa00
jmp 0x18fd7
leaq 0x100(%rsp), %rdi
callq 0x1aa00
leaq 0xf063d(%rip), %rdi     # 0x109460
leaq 0xae38a(%rip), %rsi     # 0xc71b4
callq 0x8ef10
movq %rax, 0x30(%rsp)
jmp 0x18e36
movq 0x30(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x981c0
movq %rax, 0x28(%rsp)
jmp 0x18e4f
movq 0x28(%rsp), %rdi
leaq 0x75995(%rip), %rsi     # 0x8e7f0
callq 0x8da00
jmp 0x18e62
leaq 0xf05f7(%rip), %rdi     # 0x109460
leaq 0xae351(%rip), %rsi     # 0xc71c1
callq 0x8ef10
movq %rax, 0x20(%rsp)
jmp 0x18e7c
movq 0x20(%rsp), %rdi
movsd 0x188(%rsp), %xmm0
callq 0x8fe80
movq %rax, 0x18(%rsp)
jmp 0x18e96
movq 0x18(%rsp), %rdi
leaq 0x7594e(%rip), %rsi     # 0x8e7f0
callq 0x8da00
jmp 0x18ea9
leaq 0x138(%rsp), %rdi
callq 0x1aa20
testb $0x1, %al
jne 0x18f5b
leaq 0xf059b(%rip), %rdi     # 0x109460
leaq 0xae2fe(%rip), %rsi     # 0xc71ca
callq 0x8ef10
jmp 0x18ed3
leaq 0x138(%rsp), %rdi
callq 0x1ab00
movq %rax, 0x10(%rsp)
jmp 0x18ee7
movq 0x10(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x1ab30
movq %rax, 0x8(%rsp)
jmp 0x18f08
movq 0x8(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0xf0544(%rip), %rsi     # 0x109460
leaq 0xae2af(%rip), %rdx     # 0xc71d2
leaq 0xe0(%rsp), %rdi
callq 0x1ab60
jmp 0x18f32
movq 0xf8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rcx
callq 0x1aa70
jmp 0x18f59
jmp 0x18f5b
leaq 0xf04fe(%rip), %rdi     # 0x109460
leaq 0x75887(%rip), %rsi     # 0x8e7f0
callq 0x8da00
jmp 0x18f70
leaq 0x138(%rsp), %rdi
callq 0x1ab90
leaq 0x150(%rsp), %rdi
callq 0x1abf0
leaq 0x160(%rsp), %rdi
callq 0x956c0
leaq 0xc8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x1ac10
jmp 0x18fae
leaq 0x198(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x1ad90
jmp 0x18fc5
leaq 0xc8(%rsp), %rdi
callq 0x1add0
jmp 0x18734
leaq 0x138(%rsp), %rdi
callq 0x1ab90
leaq 0x150(%rsp), %rdi
callq 0x1abf0
leaq 0x160(%rsp), %rdi
callq 0x956c0
jmp 0x19021
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1add0
leaq 0x198(%rsp), %rdi
callq 0x1add0
jmp 0x19045
leaq 0x1b8(%rsp), %rdi
callq 0x1adf0
addq $0x1c8, %rsp            # imm = 0x1C8
retq
leaq 0x1b8(%rsp), %rdi
callq 0x1adf0
movq 0x1a8(%rsp), %rdi
callq 0xc42f0
nop