std::cerr<<"I was not able to save "<<i<<"-th of "<<elements<<" elements."<<std::endl;
returnfalse;
for(i=0;i<elements;i++)
data[i].save(file);
}
catch(...)
{
throwExceptions::FileSerializationError(file.getFileName(),"unable to write the "+std::to_string(i)+"-th array element of "+std::to_string(elements)+" into the file.");
}
returntrue;
}
staticboolload(File&file,
staticvoidload(File&file,
Value*data,
constIndexelements)
{
for(Indexi=0;i<elements;i++)
if(!data[i].load(file))
Indexi=0;
try
{
for(i=0;i<elements;i++)
data[i].load(file);
}
catch(...)
{
std::cerr<<"I was not able to load "<<i<<"-th of "<<elements<<" elements."<<std::endl;
returnfalse;
throwExceptions::FileDeserializationError(file.getFileName(),"unable to read the "+std::to_string(i)+"-th array element of "+std::to_string(elements)+" from the file.");
}
returntrue;
}
};
template<typenameValue,
typenameDevice,
typenameIndex>
classArrayIO<Value,Device,Index,false>
structArrayIO<Value,Device,Index,false>
{
public:
staticboolsave(File&file,
staticvoidsave(File&file,
constValue*data,
constIndexelements)
{
if(elements==0)
return;
try
{
file.save<Value,Value,Device>(data,elements);
returntrue;
}
catch(...)
{
throwExceptions::FileSerializationError(file.getFileName(),"unable to write "+std::to_string(elements)+" array elements into the file.");
}
}
staticboolload(File&file,
staticvoidload(File&file,
Value*data,
constIndexelements)
{
if(elements==0)
return;
try
{
file.load<Value,Value,Device>(data,elements);
returntrue;
}
catch(...)
{
throwExceptions::FileDeserializationError(file.getFileName(),"unable to read "+std::to_string(elements)+" array elements from the file.");