dynamic file

Hello everyone!

I'm planning to create 'Dynamic file'
here's of it works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
dfile d;
// void open( char *filename )
d.open("example.txt");

// int create( char *dataname, int datasize );
int intvector = d.create( "intvector", 4 ); // data name, data size

int r = 8;
int g = 4;
int b = 2;
// it returns the position of the data in file
// int push( int datatype, void *in);
int rpointer = d.push(intvector, &r );
int gpointer = d.push(intvector, &g );
int bpointer = d.push(intvector, &b );

// void remove( int datatype, int pointer )
d.remove(intvector, gpointer);

// now it writes into example.txt somewhere that there's now room
// for intvector and if i would push another intvector it would
// write the same place where that old intvector get deleted 


This is my first plan but there's more.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
I want to handle x sizes of data types for example:
char a[] = "1234";
char b[] = "000";
char c[] = "987654321";
int dynamicdata = d.create( "dynamicdata", -1 );
int apointer = d.push( dynamicdata, a, 4 );
int bpointer = d.push( dynamicdata, b, 3 );
int cpointer = d.push( dynamicdata, c, 9 );
d.remove(dynamicdata, bpointer);
// now it writes into example.txt that x amount of data is free
// and next time im going to wrote a data for example size 2
// it will write there that free data is now 1 there
// if i wrote the bigger data then it writes that there are no more free space 
// left and it writes the rest of the data at the end of the file 


The first question will be, does this thing i want to create exist?
Is there library for that?

The second question if there is no such thing then creating something like
this would be effective or waste of cpu and waste of my time and
changing file source should be done by writing the whole file again?
Thanks!



The first question will be, does this thing i want to create exist?

If I'm reading this, then yes. It's called a memory-map and there are several libraries for it.
Can you recommend one?
somewhy i dont really like boost.
I guess it would not hurt if i would create my own.
Topic archived. No new replies allowed.