Fixed-width strings: Difference between revisions

Jump to navigation Jump to search
m
Line 54: Line 54:
=== Sample instance data ===
=== Sample instance data ===


This is a sample representation of instance data, just to illustrate the concept.
This is a sample representation of instance data, just to illustrate the concept. In this sample, a String instance would occupy between 8+n (direct data) and 16 bytes.
 
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.
 
  class String ... {
  class String ... {
   ...
   ...
  private:
  private:
  // common data
   uint32_t length;
   uint32_t length;
   struct {
   struct {
Line 65: Line 69:
     unsigned int padding:y;    // padding to 32 bits
     unsigned int padding:y;    // padding to 32 bits
   } data;
   } data;
  // variable data according to tag
   union {
   union {
     struct {                    // data follows directly
     struct {                    // data follows directly
55

edits

Navigation menu