File: makerlsfile.cpp

package info (click to toggle)
netgen 6.2.2601%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 13,076 kB
  • sloc: cpp: 166,627; tcl: 6,310; python: 2,868; sh: 522; makefile: 90
file content (69 lines) | stat: -rw-r--r-- 1,197 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>

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;

  /*
  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;
}