MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
cl.cc File Reference
#include "mbconfig.h"
#include <iostream>
#include <sstream>
#include "input.h"
#include "mathp.h"
#include "dummypgin.h"
Include dependency graph for cl.cc:

Go to the source code of this file.

Functions

int main (int argc, const char *const argv[])
 

Function Documentation

int main ( int  argc,
const char *const  argv[] 
)

Definition at line 43 of file cl.cc.

References MathParser::GetForever(), and verbose.

44 {
45  int verbose = 1;
46 
47  if (argc > 1) {
48  if (strcmp(argv[1], "-?") == 0
49  || strcmp(argv[1], "-h") == 0
50  || strcmp(argv[1], "--help") == 0) {
51  std::cerr
52  << "usage: " << argv[0]
53  << " reads from stdin" << std::endl
54  << " " << argv[0] << " {-?|-h|--help}"
55  " prints this message" << std::endl
56  << " " << argv[0]
57  << " <arg1> [<arg2> ...]"
58  " evaluates the expressions" << std::endl;
59  exit(EXIT_SUCCESS);
60  } else if (strcmp(argv[1], "-s") == 0) {
61  verbose = 0;
62  argv++;
63  argc--;
64  }
65  }
66 
67 #ifdef USE_TABLE
68  //Table t(1);
69  Table t(true);
70 #endif /* USE_TABLE */
71 
72  if (argc > 1) {
73  for (int i = 1; i < argc; i++) {
74  std::istringstream in(argv[i]);
75  InputStream In(in);
76 #ifdef USE_TABLE
77  MathParser mp(In, t);
78 #else /* !USE_TABLE */
79  MathParser mp(In);
80 #endif /* !USE_TABLE */
81 
82  if (verbose) {
83  std::cout << "argv[" << i << "] = ";
84  }
85 
86  try {
87  mp.GetForever(std::cout, "; ");
88  std::cout << std::endl;
89  } catch (...) {
90  std::cout << std::endl;
91  exit(EXIT_FAILURE);
92  }
93  }
94  exit(EXIT_SUCCESS);
95  }
96 
97  InputStream In(std::cin);
98 #ifdef USE_TABLE
99  MathParser mp(In, t);
100 #else /* !USE_TABLE */
101  MathParser mp(In);
102 #endif /* !USE_TABLE */
103 
104  try {
105  mp.GetForever(std::cout, "\n");
106  std::cout << std::endl;
107  exit(EXIT_SUCCESS);
108  } catch (...) {
109  std::cout << std::endl;
110  exit(EXIT_FAILURE);
111  }
112 }
static int verbose
Definition: ann_tr.c:51
Definition: table.h:43

Here is the call graph for this function: