mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
69 lines
1.1 KiB
C++
69 lines
1.1 KiB
C++
#include <stdlib.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
using namespace std;
|
|
|
|
#define maxlen 1000
|
|
|
|
int main (int argc, char ** argv)
|
|
{
|
|
if (argc != 4)
|
|
{
|
|
cout << "use: makerlsfile infile outfile rulename" << endl;
|
|
exit(1);
|
|
}
|
|
|
|
|
|
char line[maxlen], infile[maxlen], outfile[maxlen];\
|
|
char ch;
|
|
int i, j;
|
|
|
|
/*
|
|
cout << "infile: ";
|
|
cin >> infile;
|
|
cout << "outfile: ";
|
|
cin >> outfile;
|
|
*/
|
|
|
|
ifstream inf (argv[1]);
|
|
ofstream outf (argv[2]);
|
|
string rulename = argv[3];
|
|
|
|
outf << "namespace netgen" << endl << '{' << endl;
|
|
outf << "const char * " << rulename << "[] = {" << endl;
|
|
while (inf.good())
|
|
{
|
|
i = 0;
|
|
|
|
inf.get(ch);
|
|
while (ch != '\n' && inf.good() && i < maxlen)
|
|
{
|
|
if (ch == '\"')
|
|
{
|
|
line[i] = '\\';
|
|
line[i+1] = '\"';
|
|
i+= 2;
|
|
}
|
|
else if (ch == '\\')
|
|
{
|
|
line[i] = '\\';
|
|
line[i+1] = '\\';
|
|
i+= 2;
|
|
}
|
|
else
|
|
{
|
|
line[i] = ch;
|
|
i++;
|
|
}
|
|
inf.get(ch);
|
|
}
|
|
line[i] = 0;
|
|
cout << line << endl;
|
|
outf << "\"" << line << "\\n\",\\" << endl;
|
|
}
|
|
outf << "0};" << endl;
|
|
outf << '}' << endl;
|
|
return 0;
|
|
}
|