Skip to content
Snippets Groups Projects
Commit 59984754 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

Added precision for genFilename.

[[Imported from SVN: r1285]]
parent a4221c59
Branches
Tags
No related merge requests found
......@@ -3,6 +3,8 @@
#ifndef __MISC_HH__
#define __MISC_HH__
#include <iostream>
//! Check condition at compilation time
template <bool flag> class CompileTimeChecker;
......@@ -30,7 +32,7 @@ namespace Dune {
//********************************************************************
template <typename T>
inline const char *genFilename(T *path, T *fn, int ntime)
inline const char *genFilename(T *path, T *fn, int ntime, int precision = 6)
{
static char name[256];
char *cp;
......@@ -53,7 +55,24 @@ namespace Dune {
cp = name;
while (*cp)
cp++;
sprintf(cp, "%010d", ntime);
switch(precision)
{
case 2 : { sprintf(cp, "%02d", ntime); break; }
case 3 : { sprintf(cp, "%03d", ntime); break; }
case 4 : { sprintf(cp, "%04d", ntime); break; }
case 5 : { sprintf(cp, "%05d", ntime); break; }
case 6 : { sprintf(cp, "%06d", ntime); break; }
case 7 : { sprintf(cp, "%07d", ntime); break; }
case 8 : { sprintf(cp, "%08d", ntime); break; }
case 9 : { sprintf(cp, "%09d", ntime); break; }
case 10 : { sprintf(cp, "%010d", ntime); break; }
default :
{
std::cerr << "Couldn't gernerate filename with precision = "<<precision << ", file = " << __FILE__ << ", line = " << __LINE__ << "\n";
abort();
}
}
return( (T *) name);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment