| 515 | |
| 516 | |
| 517 | fmt::format_context::iterator fmtQuotedString(const std::string& string, fmt::format_context& ctx) |
| 518 | { |
| 519 | *ctx.out()++ = '\"'; |
| 520 | for (char ch: string) |
| 521 | { |
| 522 | if (ch == '\n') |
| 523 | { |
| 524 | *ctx.out()++ = '\\'; |
| 525 | *ctx.out()++ = 'n'; |
| 526 | } |
| 527 | else if (ch == '\r') |
| 528 | { |
| 529 | *ctx.out()++ = '\\'; |
| 530 | *ctx.out()++ = 'r'; |
| 531 | } |
| 532 | else if (ch == '\t') |
| 533 | { |
| 534 | *ctx.out()++ = '\\'; |
| 535 | *ctx.out()++ = 't'; |
| 536 | } |
| 537 | else if (ch == '\"') |
| 538 | { |
| 539 | *ctx.out()++ = '\\'; |
| 540 | *ctx.out()++ = '\"'; |
| 541 | } |
| 542 | else if (ch == '\\') |
| 543 | { |
| 544 | *ctx.out()++ = '\\'; |
| 545 | *ctx.out()++ = '\\'; |
| 546 | } |
| 547 | else if (ch < 0x20 || ch >= 0x7f) |
| 548 | { |
| 549 | fmt::format_to(ctx.out(), "\\x{:02x}", ch); |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | *ctx.out()++ = ch; |
| 554 | } |
| 555 | } |
| 556 | *ctx.out()++ = '\"'; |
| 557 | return ctx.out(); |
| 558 | } |
| 559 | |
| 560 | |
| 561 | fmt::format_context::iterator fmt::formatter<BinaryNinja::Metadata>::format(const BinaryNinja::Metadata& obj, format_context& ctx) const |