Author Topic: GDF - Global Data Format  (Read 3320 times)

0 Members and 1 Guest are viewing this topic.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
GDF - Global Data Format
« on: March 12, 2012, 01:11:38 am »
A few projects ago, I was thinking how I really didn't have any good ways to save data, and I was too lazy to do all this fancy data storage stuff, especially between languages.  So I made GDF, which is just a really basic file format, that I am making libs for in various languages.  Yes, there's probably lots of things like this out there, but oh well, I like this! So there.

Quick description:
There are 5 data types, integers (32 bits), longs (64 bits), floats (32 bits), double (64 bits), boolean (8 bits), strings (X bits)
It is stack based, working on an array (stack) of entries, each entry consisting of a data type and a value.  There's really not much more to it.  I have the java and php versions done (done != bugless) and am working on a version in AXE just for fun, though I don't know if I'll finish that as GDF isn't really meant for that structureless of a language, plus the whole really big numbers that the calc doesn't like thing, so we'll see...

Examples!
Code: [Select]
/* PHP code */
$gdf = new GDF();
$gdf->readGDF(fopen("test.gdf", "rb"));
echo $gdf->getSize() . " total entries.<br><br>";
while ($gdf->getSize() > 0) {
    $cur = $gdf->rpopEntry();
    echo "<br><i>" . DATATYPE::toString($cur->datatype) . "</i>: " . $cur->value;
}
Reads and prints all entries in a gdf file called "test.gdf" (html formatting)

Code: [Select]
/* Java code */
try {
    InputStream mr = new FileInputStream(new File("test.gdf"));
    GDF gdf = new GDF();
    gdf.readGDF(mr);
    System.out.println(gdf.getSize() + " total entries.\n")
    while (gdf.getSize() > 0) {
        GDF.Entry entry = gdf.rpopEntry();
        System.out.println(entry.datatype.toString() + ": " + entry.value);
    }
} catch (Exception ex) {
    ex.printStackTrace();
}
Same thing as before but in java to the standard output stream.

There's a bit more to actually saving etc, but I have almost everything pretty well documented, so it should be pretty easy to figure out.  Maybe I'll add more sample later.
The zip includes GDF.java, the java source file, and GDF.inc, the php source file.
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: GDF - Global Data Format
« Reply #1 on: March 12, 2012, 01:13:14 am »
Looks pretty nice.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.