Read/Write Multi Level Array to file

I need to improve memory usage in my program and storing a my buffers to a temporary file when it's not using them would be helpful.
Here's a basic layout of the classes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
typedef ui8  uint8_t; // etc
typedef vect std::vector;
class CdeItem
{
  vect< ui8 > addr; // Address, Adjust Address
  vect< ui8 > val;
  ui8  type;
  ui8  size; // Size = size >> 1 ( value type is stored on other bit )
  ui16 loop;
}
class HckItem
{
  vect< CdeItem > m_vect;
}
class HckList
{
  vect< HckItem > m_vect;
}

Is there any requirements for the io or will something like this be fine?
1
2
3
4
5
HckList hl;
wxFile file;
file.Write( hl, sizeof( hl ) );
file.Seek( 0, wxFromStart );
file.Read( hl, file.GetLength() );
BTW the limits for the arrays are as follows:
1
2
3
4
5
6
HckItem = 0xFFFF ( 65535 )
CdeItem = 0xFF ( 255 )
addr = 2 ( Address, Adjust Address by )
val = 0xFF ( for list codes )
val = 2 ( for normal codes: default value, adjust value )
val = 3 ( for range codes: current value, max / min, min ) ( supports different kinds of range )

The text file format takes longer to analyse and there are instances where this is loaded into a repeating loop.
I think if you are doing a binary file that's just fine.
Thx, didn't wan't to risk destroying the data before consulting the forums
Topic archived. No new replies allowed.