Hmm? It has a blob data type (basically you just dump any binary data to it). Also, most object structures can be mapped to a relational model, so that shouldn't be a problem. Anyway, it probably isn't that appealing to people that don't have much relational database experience. Just thought I'd add it to the topic as another possibility.avansc wrote:as far as i know you still cant write entire objects to it... i may be wrong. but i think a self made binary file would still be beter in terms of that.
Custom file formats
Moderator: Coders of Rage
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: Custom file formats
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Custom file formats
Do you have a simple example of how you would write an entire object to a binary file? I think I know what you mean but I'm not exactly sure.avansc wrote: as far as i know you still cant write entire objects to it... i may be wrong. but i think a self made binary file would still be beter in terms of that.
Last edited by dandymcgee on Sat Mar 07, 2009 6:21 pm, edited 1 time in total.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: Custom file formats
dandymcgee wrote:Do have a simple example of how you would write an entire object to a binary file? I think I know what you mean but I'm not exactly sure.avansc wrote: as far as i know you still cant write entire objects to it... i may be wrong. but i think a self made binary file would still be beter in terms of that.
here is something. note that this is just what i made in 5 min. you can do pointers but there are ways of gettign around it.
anyways. as you can see its pretty nifty. ps: just make sure you delete the file manually, i just noticed i didnt put that in there.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <fstream.h>
using namespace std;
class map
{
public:
map();
void fill();
void printData();
private:
int data[10][10];
};
map::map()
{
}
void map::fill()
{
for(int a = 0;a < 10;a++)
{
for(int b = 0;b < 10;b++)
{
this->data[a][b] = (a+1)*(b+1);
}
}
}
void map::printData()
{
for(int a = 0;a < 10;a++)
{
for(int b = 0;b < 10;b++)
{
printf("%d , ",data[a][b]);
}
printf("\n");
}
}
void saveMap(char *fileName, map *temp);
map *loadMap(char *fileName);
void saveMap(char *fileName, map *temp)
{
ofstream myFile(fileName, ios::out | ios::binary);
myFile.write((char*)temp, sizeof(map));
myFile.close();
}
map *loadMap(char *fileName)
{
map *temp = (map*)malloc(sizeof(map));
fstream myFile(fileName, ios::binary | ios::in);
myFile.read((char*)temp, sizeof(map));
myFile.close();
return temp;
}
int main()
{
printf("start of program.\n");
map *temp = new map();
temp->fill();
temp->printData();
saveMap("lev.bin", temp);
printf("\n");
map *lmap = (map*)malloc(sizeof(map));
lmap = loadMap("lev.bin");
lmap->printData();
return 0;
}
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Custom file formats
so, i can either create a binary file or create a txt file holding information which i can load through C++ classes/functions, binary files are not human readable so it is already encrypted and i would have to create an editor for it, if i use a txt file, it is human readable, but is there a way to encrypt it and have it non-readable? i'm not saying i will do that, but that is what some professional companies do, and i might keep it in mind for later.
Personal Youtube: http://www.youtube.com/user/xXShadowAsasNXx
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Custom file formats
you could also overload the insertion operator:
Just another way to do it.
Code: Select all
class Class
{
int i, j;
friend ostream &operator<<(ostream &stream, Class classVar);
public:
Class(int I, int J)
{
i = I;
j = J;
}
};
ostream &operator<<(ostream &stream, Class classVar)
{
stream << classVar.i << " " << classVar.j << endl;
return stream;
}
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: Custom file formats
GOD i dont like that.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Custom file formats
I would like to use binary files. Not specifically to edit for the reasons Cole S. gave, but as a final output for a file that will be used with the program. I've made my own .obj model loader that parses the text in the .obj file. Problem is, these files load somewhat slow (3 seconds for 10 models around 1,000 polygons each) and the text format makes them large. I'd make a file converter to turn the text into raw numerical data, as most of it is numbers anyways.avansc wrote:wht do so few people utilize binary files?