Skip to content

ryandw11/ODS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Release Maven Snapshot

Object Data Structure (ODS)

Object Data Structure is a file format inspired by NBT. Everything in this file format is made of tags.
ODS is not human-readable, data is stored in bytes.

Requires Java 8+

Support Discord

Access release builds of Object Data Structure by using the following methods:
Maven:

<repositories>
    <repository>
        <id>ObjectDataStructure</id>
        <url>https://repo.ryandw11.com/repository/maven-releases/</url>
    </repository>
</repositories>

<dependency>
    <groupId>me.ryandw11</groupId>
    <artifactId>ods</artifactId>
    <version>1.0.5</version>
</dependency>

Gradle:

repositories {
    maven { url 'https://repo.ryandw11.com/repository/maven-releases/' }
}
    
dependencies {
    implementation 'me.ryandw11:ods:1.0.5'
}

Fat Jar:
You can get the fat jar from releases or get automatic builds from ci.ryandw11.com.

Usage

As stated above ODS uses tags. There are many primative tags: StringTag, IntTag, ShortTag, LongTag, ByteTag, DoubleTag, FloatTag.
There are also the ListTag and MapTag. They both store primative tags in a list and map format respectivly.
Finally there are ObjectTags. ObjectTags store other tags. For more information about the possibilites be sure to check out the wiki and javadoc!

ODS Utility Class

The ODS class is full of useful methods that allow the easy serialization of primative objects.
The ODS class also allows the serialization of custom objects.

Example for saving

        ObjectDataStructure ods = new ObjectDataStructure(new File("test.ods"));

        List<Tag<?>> tags = new ArrayList<>();
        tags.add(new StringTag("ExampleKey", "This is an example string!"));
        tags.add(new IntTag("ExampleInt", 754));

        ObjectTag car = new ObjectTag("Car");
        car.addTag(new StringTag("type", "Jeep"));
        car.addTag(new IntTag("gas", 30));
        car.addTag(new ListTag<>("coords", ODS.wrap(Arrays.asList(10, 5, 10))));

        ObjectTag owner = new ObjectTag("Owner");
        owner.addTag(new StringTag("firstName", "Jeff"));
        owner.addTag(new StringTag("lastName", "Bob"));
        owner.addTag(new IntTag("Age", 30));
        car.addTag(owner);

        tags.add(car);

        ods.save(tags);

Example for loading

        System.out.println("The value of ExampleKey is: " + ods.<StringTag>get("ExampleKey").getValue());

        ObjectTag myCar = ods.get("Car");
        System.out.println("The car is a " + myCar.getTag("type").getValue());

        StringTag ownerFirstName = ods.get("Car.Owner.firstName");
        StringTag ownerLastName = ods.get("Car.Owner.lastName");
        System.out.println("The owner of the car is " + ODS.unwrap(ownerFirstName) + " " + ODS.unwrap(ownerLastName));

ODS Visualizer

This tool allows you inspect ods files. Picture Of the Visualizer
Click here to go to the visualizer repository.

Offical Language Ports

Porting to another language.

To port this to another language you just need to follow the file format specifications. The specifications for the ODS file type can be found below. Test ODS files can be found below. The Visualizer tool might be helpful.

Existing Ports

  • There are none! To add your port to this list open an issue or create a PR!

Addons

ODSCompressionPlus

ODSCompressionPlus provides additional compression formats, such as: Zstd.

Specification

Each tag has a header consisting of 7 bytes.

1 Byte 4 Bytes 2 Bytes
The Data Type The size of the tag (in bytes) starting from the next byte. The number of bytes the key has.
Each tag has a key. There can only be one tag with a ceratin key.

Data Types

ByteType
0Reserved
1String
2int
3Float
4Double
5Short
6Long
7Char
8Byte
9List
10Map
11Object
12Compressed Object

Compression Types

  • None
  • GZIP
  • ZLIB

About

A very fast file storage format designed for video games.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages