o
odin.langpkg.dev
packages / library / wsv

wsv

d24fb00library

An Odin implementation for WSV

Unlicense · updated 11 months ago

an Odin implementation

WSV is just like csv, but it uses standardized whitespaces as separators instead of commas(or whatever else you feel like on that day). For more information about the format, please check the specification here.

By leveraging Odin's reflection we can parse .wsv files and store its values directly on generic structs that have the supported types of .wsv as its members. This package uses the concepts of Array of Structs(AOS) and Struct of Arrays(SOA) to creat a neat generic API. It works on arrays, structs and also #soa Odin arrays.

You are encouraged to look at the code and understand how it works and, if desired, create your own more specific implementations.

Public API:

  • For reading:
    • read_file_into_struct_of_arrays; read_file_into_array_of_structs
    • Reader with iterator_next or read_all
  • For writing:
    • write_struct_of_arrays_to_file; write_struct_of_arrays_to_builder; write_array_of_structs_to_file; write_array_of_structs_to_builder; write_all
  • For converting from .wsv to .csv: convert_to_csv

Pay attention here section:

  • write_(whatever)_to_builder always writes using utf8
  • You can check examples.odin for usage examples
  • The files folder is only used for tests and examples, you can delete it in in your project

Lacking completeness and how you can contribute:

These are the things I haven't implemented and am not thinking about implementing, so if you, yes, you, the reader, wants to contribute I would start with them:

  • Missing utf32 big and little endian encoding
  • Missing conversion from .csv to .wsv
  • Missing serialization and deserialization of complex and quaternion types
  • Missing unit tests (I only implemented 2 unit tests and the project could for sure use more)