| 559 | |
| 560 | |
| 561 | fmt::format_context::iterator fmt::formatter<BinaryNinja::Metadata>::format(const BinaryNinja::Metadata& obj, format_context& ctx) const |
| 562 | { |
| 563 | switch (obj.GetType()) |
| 564 | { |
| 565 | default: |
| 566 | case InvalidDataType: |
| 567 | return fmt::format_to(ctx.out(), "(invalid)"); |
| 568 | case BooleanDataType: |
| 569 | return fmt::format_to(ctx.out(), "{}", obj.GetBoolean()); |
| 570 | case StringDataType: |
| 571 | return fmt::format_to(ctx.out(), "{}", obj.GetString()); |
| 572 | case UnsignedIntegerDataType: |
| 573 | return fmt::format_to(ctx.out(), "{}", obj.GetUnsignedInteger()); |
| 574 | case SignedIntegerDataType: |
| 575 | return fmt::format_to(ctx.out(), "{}", obj.GetSignedInteger()); |
| 576 | case DoubleDataType: |
| 577 | return fmt::format_to(ctx.out(), "{}", obj.GetDouble()); |
| 578 | case RawDataType: |
| 579 | return fmtByteString(obj.GetRaw(), ctx); |
| 580 | case KeyValueDataType: |
| 581 | { |
| 582 | *ctx.out()++ = '{'; |
| 583 | bool first = true; |
| 584 | for (auto& [name, value]: obj.GetKeyValueStore()) |
| 585 | { |
| 586 | if (!first) |
| 587 | { |
| 588 | *ctx.out()++ = ','; |
| 589 | *ctx.out()++ = ' '; |
| 590 | } |
| 591 | first = false; |
| 592 | |
| 593 | fmtQuotedString(name, ctx); |
| 594 | *ctx.out()++ = ':'; |
| 595 | *ctx.out()++ = ' '; |
| 596 | fmt::format_to(ctx.out(), "{}", value); |
| 597 | } |
| 598 | *ctx.out()++ = '}'; |
| 599 | return ctx.out(); |
| 600 | } |
| 601 | case ArrayDataType: |
| 602 | *ctx.out()++ = '['; |
| 603 | bool first = true; |
| 604 | for (auto& value: obj.GetArray()) |
| 605 | { |
| 606 | if (!first) |
| 607 | { |
| 608 | *ctx.out()++ = ','; |
| 609 | *ctx.out()++ = ' '; |
| 610 | } |
| 611 | first = false; |
| 612 | fmt::format_to(ctx.out(), "{}", value); |
| 613 | } |
| 614 | *ctx.out()++ = ']'; |
| 615 | return ctx.out(); |
| 616 | } |
| 617 | } |
| 618 |
no test coverage detected