00001 #include "headers.h"
00002 #include "fileUtil.h"
00003
00004 using namespace std;
00005
00006 bool IRoot::allSettingsToFile(const char *fileName) {
00007 try {
00008 ofstream file( fileName, ios_base::binary|ios_base::trunc|ios_base::out );
00009 file.exceptions( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
00010 put( file, SettingsMagic );
00011 file_saveAllSettings(file);
00012 return true;
00013 } catch(exception &e) {
00014 return false;
00015 }
00016 }
00017
00018 bool IRoot::allSettingsFromFile(const char *fileName) {
00019 ASSERT(getMode()==Clear);
00020 try {
00021 ifstream file( fileName, ios_base::binary|ios_base::in );
00022 file.exceptions( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
00023 if (get<Uint16>(file)!=SettingsMagic)
00024 return false;
00025 file_loadAllSettings(file);
00026 return true;
00027 } catch(exception &e) {
00028 return false;
00029 }
00030 }
00031
00032
00033 void IQuality2SE::regularRangeErrors( float quality, int levelEnd, float *errors ) {
00034 ASSERT( checkBoundsFunc<float>(0,quality,1)==quality && levelEnd>2 && errors );
00035
00036 float (IQuality2SE::*func)(float,int)= &IQuality2SE::rangeSE;
00037
00038 for (int level=0; level<levelEnd; ++level)
00039 errors[level]= (this->*func)( quality, powers[level*2] );
00040 }