Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-164

BCON (BSON C Object Notation) C initializers for BSON

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.7
    • Affects Version/s: None
    • Component/s: None
    • None

      BCON provides for JSON-like (or BSON-like) initializers in C.
      Without this, BSON must be constructed by procedural coding via explicit function calls.
      With this, you now have convenient data-driven definition of BSON documents.
      Here are a couple of introductory examples.

      bcon hello[] =

      { "hello", "world", "." }

      ;
      bcon pi[] =

      { "pi", BF(3.14159), BEND }

      ;
      BCON is an array of bcon union elements with the default type of cstring (char *).
      A BCON document must be terminated with a cstring containing a single dot, i.e., ".", or the macro equivalent BEND.

      Cstring literals in double quotes are used for keys as well as for string values.
      There is no explicit colon (':') separator between key and value, just a comma,
      however it must be explicit or C will quietly concatenate the key and value strings for you.
      Readability may be improved by using multiple lines with a key-value pair per line.

      Macros are used to enclose specific types, and an internal type-specifier string prefixes a typed value.
      Macros are also used to specify interpolation of values from pointers to specified types.

      Sub-documents are framed by "

      {" "}

      " string literals, and sub-arrays are framed by "[" "]" literals.

      All of this is needed because C arrays and initializers are mono-typed unlike dict/array types in modern languages.
      BCON attempts to be readable and JSON-like within the context and restrictions of the C language.

            Assignee:
            gjmurakami Gary Murakami
            Reporter:
            gjmurakami Gary Murakami
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: