Fixed-width strings: Difference between revisions

m
Line 57: Line 57:


We need to discuss whether strings should be 0-terminated. Processing a string buffer with C/C++ routines would be much easier if it did. Also, in debug mode, the display of a string is easier.
We need to discuss whether strings should be 0-terminated. Processing a string buffer with C/C++ routines would be much easier if it did. Also, in debug mode, the display of a string is easier.
''Question: can we use bit fields, or better masks plus shift for the compacted values?''


  class String ... {
  class String ... {
Line 65: Line 67:
   struct {
   struct {
     unsigned int width:2;      // 0:1, 1:2, 2:not used, 3:4
     unsigned int width:2;      // 0:1, 1:2, 2:not used, 3:4
     unsigned int tag:3;        // data tag
     unsigned int tag:2;        // data tag: 0:direct, 1:regular, 2:concat, 3:substr
    unsigned int dynamic:1;    // if nonzero, buffer must be deleted
     unsigned int treeDepth:x;  // to be defined (more fields may follow)
     unsigned int treeDepth:x;  // to be defined (more fields may follow)
     unsigned int padding:y;    // padding to 32 bits
     unsigned int padding:y;    // padding to 32 bits
55

edits