google / emboss

Emboss is a tool for generating code that reads and writes binary data structures.
Apache License 2.0
72 stars 22 forks source link

FR: Add CopyBytesFrom for array types #207

Open AlanRosenthal opened 6 days ago

AlanRosenthal commented 6 days ago
  0      [+8]  UInt:8[8]   identification_pattern

Ideally I'd be able to:

    pw::Result<emboss::FileHeaderWriter> result =
        MakeEmbossWriter<emboss::FileHeaderWriter>(file_header_data);
    if (!result.ok()) {
      return;
    }
    emboss::FileHeaderWriter writer = result.value();
    std::array<uint8_t, 8> identification_pattern_data = {0x62, 0x74, 0x73,
    0x6E, 0x6F, 0x6F, 0x70, 0x00};
    writer.identification_pattern().CopyBytesFrom(identification_pattern_data);
reventlov commented 6 days ago

It would probably be useful to add CopyBytesFrom() to all view types, not just arrays of bytes.