Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my experience, second-guessing the data you'll need is invariably wasted time. What's important is to structure your <em>metadata</em> in a way that is extensible. For XML files, that's straightforward, but binary files require a bit more thought.</p> <p>I tend to store metadata in a structure at the END of the file, not the beginning. This has two advantages:</p> <ul> <li>Truncated/unterminated files are easily detected.</li> <li>Metadata footers can often be appended to existing files without impacting their reading code.</li> </ul> <p>The simplest metadata footer I use looks something like this: </p> <pre><code>struct MetadataFooter{ char[40] creatorVersion; char[40] creatorApplication; .. or whatever } struct FileFooter { int64 metadataFooterSize; // = sizeof(MetadataFooter) char[10] magicString; // a unique identifier for the format: maybe "MYFILEFMT" }; </code></pre> <p>After the raw data, the metadata footer and THEN the file footer are written.</p> <p>When reading the file, seek to the end - sizeof(FileFooter). Read the footer, and verify the magicString. Then, seek back according to metadataFooterSize and read the metadata. Depending on the footer size contained in the file, you can use default values for missing fields.</p> <p>As <a href="https://stackoverflow.com/users/2298/keithb">KeithB</a> points out, you could even use this technique to store the metadata as an XML string, giving the advantages of both totally extensible metadata, with the compactness and speed of binary data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload