It's varType and format that I want to store only once for information about the class it's stored in, storing for specific instances are just wasting space.
The Filed class is used along with a load of functions in the same namespace as itself that handles reading and writing to files all the data in any class that's derived from this class.
The pure virtual functions force the user to define how new classes should use this to read/write there info, and the format of how this info is stored is all held inside string format
I only need to know the format once for each class but I don't want to have to user type static std::string format for every new class.
I don't think that's what I'm looking for, honestly I don't go too near to unions because I don't see much point in most of my work.
If you're able to think of how this might work in my situation I'd be more than
happy to try but I just can't see it.
A union is shared space between types, and per instance.
I want shared data between instances (static), and per type (redefined in derived class).
It's sorta the complete opposite XD
EDIT: As I said I don't think this is even possible in any way but I thought I'd at least ask because I couldn't find anything through goggling.
No, I don't think it's possible. On the other hand, unless you're developing on 30-year-old hardware, or your format strings are ridiculously enormous, I don't see why you're worrying over trying to save such a tiny amount of space.
Well the format string is storing bytes which indicate what types are stored in a file for loading to a class.
The bytes can indicate primitive or user defined types and I have functions that decide how to read the data depending on the result.
//These are the data help in some classes of mine
format = HOLD_A, FILED, HOLD_A, FILED
//This is simplified as I do have other flags in here
format = DOUBLE, DOUBLE, DOUBLE
format = INT, INT, INT
1 2 3 4 5
//Format tells function to read like this...
find format[arSize] > (double, double, double)[arSize]
find format[arSize] > (int, int, int)[arSize]
This is just a simple example but the principle is that using the format string, no matter how complex an object is, all the user defined classes can be traced and read from/stored to file. (or all data can be saved in form of a string, this string is not the format string)
I was thinking that it could be better just saving the format into a macro but I don't know if there's a way to attach enum data to a "stringified" macro.
Because macros are PRE-processor I imagine that they'll be read before the enumerator type in my coding?
If this does work I'd use it as such wouldn't I?
#define FORMAT_VPOLY3D #HOLD_A #PVECTOR3D #HOLD_A #TRIANGLE
//Since "a""b""c" should automatically be cut to "abc"