Yamlconv

From MK8
Revision as of 17:53, 27 February 2015 by Chadderz (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
yamlconv
Creator: Chadderz
File Format:
Version: v1.0.0.0
Date of Latest Version: 2015-02-26
Download: https://github.com

yamlconv is a program to convert BYAML files to XML. It was developed in C# by Chadderz as part of the initial investigations into the BYAML file format. This was to aid understanding and make editing easier than binary. The program can be used by dragging and dropping BYAML or XML files onto the executable, or invoking the program from the command line with the file name(s) to convert.

Since it was only designed as a temporary solution to the problem of editing BYAML files, it was coded quickly and may contain bugs. It may be possible to compile non-Windows versions of the software, as it should only use a small subset of the C# language.

Conversion

The conversion procedure begins at the root node. It is encoded as the root XML node with name "yaml". Every sub-node is then recursively converted. Value nodes may either be converted to XML attributes or XML elements. Integers are encoded directly, booleans are encoded as "true" or "false" and floats are encoded as the numeric representation followed by an "f". A string is encoded as the inner text of an XML element with the attribute "type" set to "string". A path is encoded as a series of "point" elements with attributes "x", "y", "z", "nx", "ny", "nz" and "val". The container element of the path has attribute "type" equal to "path". Finally, arrays are encoded as a series of "value" elements with the container having attribute "type" equal to "array" and dictionaries are encoded as a series of named elements or attributes.

Examples

The following is an example of the output of yamlconv showing all features mentioned above.

<?xml version="1.0" encoding="utf-8"?>
<yaml float_field_example="1.0f" int_field_example="0" bool_field_example="true">
  <string_field_example type="string">Hello!</string_field_example>
  <path_example type="path">
    <point x="0f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" />
    <point x="1f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" />
  </path_example>
  <array_example type="array">
    <value sample_int="0" />
    <value sample_int="1" />
  </array_example>
  <empty_array type="array" />
  <dictionary_example>
    <attr type="string">Hi!</attr>
  </dictionary_example>
  <empty_dictionary />
</yaml>