Atlas Codecs

From WorldForgeWiki
(Redirected from Atlas Codec Reference Guide)
Jump to: navigation, search

Packed

Syntax

The form for each element of this codec is as follows: [type][|name=][data][|endtype]

type is mandatory, name must be present for map attributes and must not be present for list items, endtype applies to lists and maps but not to other data types. Type specifiers

  • ( ) for lists
  • [ ] for maps
  • $ for string
  • @ for int
  • # for float

Example:

[@id=17$name=Fred +28the +2b great+29#weight=1.5(args=@1@2@3)]

This example represents a map with the following attributes:

  • name="id", type="int", value="17"
  • name="name", type="string", value="Fred (the + great)"
  • name="weight", type="float", value="1.5"
  • name="args", type="list", value=
    • type="int", value="1"
    • type="int", value="2"
    • type="int", value="3"

Special characters

The following characters cannot appear verbatim in strings:

  • + (plus symbol)
  • [ (left square bracket)
  • ] (right square bracket)
  • ( (left parenthesis)
  • ) (right parenthesis)
  • @ (at symbol)
  • # (hash symbol)
  • $ (dollar symbol)
  • = (equals symbol)
  • \n (newline character)
  • \r (carriage return character)

They are encoded by sending a plus symbol followed by the ascii value of the character in hexadecimal. See the example above for details.

Notes

No UNICODE or other multibyte character support exists at present.

Bach

Syntax

Elements in mapping and lists are separated with ,.

Mapping is surrounded with {}. Elements in mapping are encoded as name:value. Name is encoded without quotes if it consists of digits or uppercase or lowercase letter (a-z) or _. Name must not start with a number. Quoted name can contain anything, see strings. Value can be anything.

List is surrounded with []. Values can be anything. Top level object in streams is a list. So stream starts with [ and ends with ] (same as <atlas> and </atlas> in XML).

Integer can start with +- (optional) and digits.

Float numbers consist of mantissa and exponent (optional). Mantissa can contain one .. Otherwise they are encoded as integers and are separated with e or E (in case there is an exponent).

String is surrounded with " and " is quoted as \" and \ is quoted as \\. (in future may allow octals and special characters like \n).

  1. is comment character: all character from this to end of line is comment. (Might be some day decoded as "comment" -attribute or something equivalent)

Whitespace is allowed outside values and names (Regular expression \s or any of \t \n\r\f\v).

Example:

{
   parents: ["info"], 
   arg: {
     name: "Joe", 
     pos: [4.5, 6.7, 2.3], 
     meaning_of_life: 42
   }
}

XML

Syntax

DTD

<!-- Tags -->

<!ELEMENT atlas       (map*)>
<!ATTLIST atlas       version  CDATA #IMPLIED>

<!ELEMENT string     (#PCDATA)>
<!ATTLIST string     name  CDATA #IMPLIED>

<!ELEMENT int     (#PCDATA)>
<!ATTLIST int     name  CDATA #IMPLIED>

<!ELEMENT float     (#PCDATA)>
<!ATTLIST float     name  CDATA #IMPLIED>

<!ELEMENT list     (string|int|float|list|map)*>
<!ATTLIST list     name  CDATA #IMPLIED>

<!ELEMENT map     (string|int|float|list|map)*>
<!ATTLIST map     name  CDATA #IMPLIED>

Examples:


<int name="foo">4</int>

<map name="loc">
  <string name="ref">42</string>
  <list name="coords"><float>1.2</float><float>-3.5</float><float>0.0</float><list>
</map>

<map>
  <string name="id">dragon_123</string>
  <string name="name">Dragon the magnificent</string>
</map>

<list name="args">
  <map>
    <string name="message">Hello!</string>
  </map>
  <map>
    <string name="id">elf_123</string>
  </map>
</list>