Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RocfluidMP/utilities/rocflo/makeflo/util.h File Reference
#include <string>
Include dependency graph for RocfluidMP/utilities/rocflo/makeflo/util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool incrementAscii (char *cur)
 
bool fileExists (const char *fName)
 
bool endsWith (const char *a, const char *suffix)
 
string replaceExtention (const string &a, const string &newSuffix)
 
const char * fortranifyString (const char *src)
 

Function Documentation

bool endsWith ( const char *  a,
const char *  suffix 
)

Definition at line 67 of file RocfluidMP/utilities/rocflo/makeflo/util.cpp.

Referenced by main(), read_file(), and writeBlocks().

68 {
69  int al=strlen(a);
70  int sl=strlen(suffix);
71  if (al<sl) return false;
72  const char *a_suff=&a[al-sl];
73  return 0==strcmp(a_suff,suffix);
74 }

Here is the caller graph for this function:

bool fileExists ( const char *  fName)

Definition at line 78 of file RocfluidMP/utilities/rocflo/makeflo/util.cpp.

References cimg_library::cimg::fclose(), and cimg_library::cimg::fopen().

Referenced by read_multiple().

78  {
79  FILE *f=fopen(fName,"rb");
80  if (f==NULL)
81  return false;
82  else {
83  fclose(f);
84  return true;
85  }
86 }
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
void int int int REAL REAL REAL const char * fName
Definition: write.cpp:76
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

const char* fortranifyString ( const char *  src)

Definition at line 116 of file RocfluidMP/utilities/rocflo/makeflo/util.cpp.

References i.

Referenced by read_file(), and write_fortran().

117 {
118  const int bufLen=500;
119  static char buf[bufLen];
120  strcpy(buf,src);
121  //Pad with spaces
122  for (int i=strlen(buf);i<bufLen;i++) buf[i]=' ';
123  buf[bufLen-1]=0; //Zero-terminate for C use
124  return buf;
125 }
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

bool incrementAscii ( char *  cur)

Definition at line 90 of file RocfluidMP/utilities/rocflo/makeflo/util.cpp.

References i.

Referenced by read_multiple(), and writeBlocks().

91 {
92  //Starting from end, work backwards until we reach
93  // the first decimal digit.
94  int i=strlen(cur)-1;
95  while (i>=0 && !isdigit(cur[i])) i--;
96  if (i<0) return false; //No digits found
97 
98  //Carry loop
99  while (true) {
100  //Increment the current digit
101  cur[i]++;
102  if (cur[i]!='9'+1)
103  break; //No carry needed-- finished
104  //Otherwise, wrap around and carry to next digit
105  cur[i]='0';
106  i--;
107  if (i<0 || !isdigit(cur[i])) return false; //Too many carries
108  }
109  return true;
110 }
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

string replaceExtention ( const string &  a,
const string &  newSuffix 
)

Definition at line 128 of file RocfluidMP/utilities/rocflo/makeflo/util.cpp.

Referenced by main().

129 {
130  string ret(a);
131  int dotLoc=ret.rfind(".");
132  if (dotLoc==-1) return ret.append(newSuffix);
133  return ret.erase(dotLoc).append(newSuffix);
134 }

Here is the caller graph for this function: