computer-vision-2/assignments/assignment_3/src/Frame3D/FileUtils.cpp
/* The following function are useful for saving multiple variables such as numbers, and matrices to a single file
 * The write-functions simply append the new data to a output_stream, therefore it is necessary to load the objects in the same order as they have been saved.
 *
 * Before the read functions can be called, the contents of the file should first be read to a char* (using readFile(...)),
 * which can then be used as input parameter for the read functions.
 *
 * The following functions are platform independent, meaning that the files produced on one system can always be read on a different system.
 */
The following function are useful for saving multiple variables such as numbers, and matrices to a single file
The write-functions simply append the new data to a output_stream, therefore it is necessary to load the objects in the same order as they have been saved.

Before the read functions can be called, the contents of the file should first be read to a char* (using readFile(...)),
which can then be used as input parameter for the read functions.

The following functions are platform independent, meaning that the files produced on one system can always be read on a different system.
The following function are useful for saving multiple variables such as numbers and matrices to a single file The write - functions simply append the new data to a output_stream therefore it is necessary to load the objects in the same order as they have been saved . Before the read functions can be called the contents of the file should first be read to a char * ( using readFile ( ... )) which can then be used as input parameter for the read functions . The following functions are platform independent meaning that the files produced on one system can always be read on a different system .
char *readFile(char *filename, int &size) {
	ifstream file (filename, ios::in | ios::binary | ios::ate);
	size = (int)file.tellg()+1;
	file.seekg (0, ios::beg);
	char *txt = (char *)malloc(size);
	file.read (txt,size-1);
	file.close();
	txt[size-1] = 0;
	return txt;
}
char * readFile ( char * filename , int & size ) { ifstream file ( filename , ios :: in | ios :: binary | ios :: ate ) ; size = ( int ) file . tellg ( ) + 1 ; file . seekg ( 0 , ios :: beg ) ; char * txt = ( char * ) malloc ( size ) ; file . read ( txt , size - 1 ) ; file . close ( ) ; txt [ size - 1 ] = 0 ; return txt ; }
The following function are useful for saving multiple variables such as numbers, and matrices to a single file
 The write-functions simply append the new data to a output_stream, therefore it is necessary to load the objects in the same order as they have been saved.
The following function are useful for saving multiple variables such as numbers and matrices to a single file The write - functions simply append the new data to a output_stream therefore it is necessary to load the objects in the same order as they have been saved .