parsingTest.cpp
Go to the documentation of this file.
1 /* $Id: parsingTest.cpp 3583 2010-07-13 20:39:42Z kmartin $ */
18 #include <cppad/cppad.hpp>
19 #include "OSConfig.h"
20 #include "OSInstance.h"
21 #include "OSOption.h"
22 #include "OSResult.h"
23 #include "OSiLReader.h"
24 #include "OSiLWriter.h"
25 #include "OSoLReader.h"
26 #include "OSoLWriter.h"
27 #include "OSrLReader.h"
28 #include "OSrLWriter.h"
29 #include "OSFileUtil.h"
30 #include "CoinError.hpp"
31 
32 #include "OSWSUtil.h"
33 #include "OShL.h"
34 #include "OSErrorClass.h"
35 #include "OSBase64.h"
36 #include "OSMathUtil.h"
37 
38 
39 #include <CoinMpsIO.hpp>
40 #include <CoinPackedMatrix.hpp>
41 
42 
43 #include "CoinError.hpp"
44 #include "CoinHelperFunctions.hpp"
45 
46 #ifdef HAVE_CTIME
47 # include <ctime>
48 #else
49 # ifdef HAVE_TIME_H
50 # include <time.h>
51 # else
52 # error "don't have header file for time"
53 # endif
54 #endif
55 
56 
57 #ifdef HAVE_CMATH
58 # include <cmath>
59 #else
60 # ifdef HAVE_CMATH_H
61 # include <cmath.h>
62 # endif
63 #endif
64 
65 
66 
67 #ifdef HAVE_CSTDIO
68 # include <cstdio>
69 #else
70 # ifdef HAVE_STDIO_H
71 # include <stdio.h>
72 # else
73 # error "don't have header file for stdio"
74 # endif
75 #endif
76 
77 //#ifdef HAVE_WINDOWS_H
78 //#include <windows.h>
79 //#endif
80 
81 using std::cout;
82 using std::endl;
83 using std::ostringstream;
84 
85 //#define MY_DEBUG
86 
87 bool interactiveShell(std::string *schema, std::string *testFileName, std::string *outFileName,
88  bool *compress, bool *addWhiteSpace, bool *verifyObjects, bool *useRandomObjects,
89  unsigned int *seed, int *nrep, double *density, bool *conformant);
90 void printHelp();
91 std::string getUserInput(bool defaultPresent);
92 
93 
94 int main(int argC, char* argV[])
95 {
96  WindowsErrorPopupBlocker();
97 
98  // define the classes
99  FileUtil *fileUtil = NULL;
100  OSiLReader *osilreader = NULL;
101  OSoLReader *osolreader = NULL;
102  OSrLReader *osrlreader = NULL;
103  // end classes
104 
105  std::string testFileName;
106  std::string outFileName;
107  std::string osxl;
108  std::string schema;
109  ostringstream parsingTestResult;
110  ostringstream parsingTestResultFailure;
111 // ostringstream outputString;
112  std::string outputString;
113 
114  bool doOutput = false;
115  bool compress = true;
116  bool addWhiteSpace = true;
117  bool verifyObjects = true;
118  bool useRandomObjects = false;
119 
120  int nrep = 1;
121  unsigned int seed;
122  double density = 0.5;
123  bool conformant = true;
124 
125  seed = time(NULL);
126 
127 // Command line parser and user interface
128 
129  if (argC == 1)
130  {
131  if (interactiveShell(&schema, &testFileName, &outFileName, &compress, &addWhiteSpace, &verifyObjects,
132  &useRandomObjects, &seed, &nrep, &density, &conformant) != true) return 0;
133 
134 #ifdef MY_DEBUG
135  std::cout << "User dialog completed " << std::endl;
136 #endif
137  }
138  else //command line arguments were given
139 /****
140  * command line arguments and default values
141  * -schema=[osil|osol|osrl] used to select the schema
142  * -file=<filename> name of the input file
143  * -random=[YES|no] should random objects be generated?
144  * -replications=<nnn> number of replications of the random test
145  * -seed=<nnn> seed for the random number generator
146  * -density=<x.x> average fraction of child elements
147  * -conformant=[YES|no] should side constraints be enforced?
148  * -outfile=<filename> name of the output file
149  * -compress=[YES|no] use mult and incr to compress output file?
150  * -whitespace=[YES|no] use whitespace between elements?
151  * -verify=[yes|NO] test input and output objects for equality?
152  *
153  * -random is synonymous with -random=yes,
154  * -norandom is synonymous with -random=no, etc.
155  */
156  {
157  int argM = 12; //maximal number of command line arguments including `parsingTest`
158  if( argC > argM)
159  {
160  std::cout << "Too Many Input Parameters" << std::endl;
161  return 1;
162  }
163  if ( (strcmp(argV[1],"--help") == 0) || (strcmp(argV[1],"-h") == 0) || (strcmp(argV[1],"-?") == 0) )
164  {
165  printHelp();
166  return 0;
167  }
168  if ( (strcmp(argV[1],"quit") == 0) || (strcmp(argV[1],"exit") == 0) || (strcmp(argV[1],"stop") == 0) )
169  return 0;
170  /*
171  if (argC < 3 || ((strcmp(argV[1],"osil") != 0) && (strcmp(argV[1],"osol") != 0) && (strcmp(argV[1],"osrl") != 0)))
172  {
173  std::cout << "usage: parsingtest <parser> <filename> [<outputFile> [(no)compress (no)addWhiteSpace (noverify]]" << std::endl;
174  std::cout << "type \"parsingtest --help\" for more information" << std::endl;
175  return 1;
176  }
177  schema = argV[1];
178  testFileName = argV[2];
179  if (argC > 3)
180  {
181  outFileName = argV[3];
182  doOutput = true;
183  }
184  if (argC > 4)
185  compress = (strcmp(argV[4],"nocompress") != 0);
186  if (argC > 5)
187  addWhiteSpace = (strcmp(argV[5],"noaddwhitespace") != 0);
188  if (argC == 7)
189  verifyObjects = (strcmp(argV[6],"verifyobjects") == 0);
190  */
191  size_t epos;
192  std::string argument, option, value;
193  for (int i=1; i<argC; i++)
194  {
195  if (argV[i][0] != '-')
196  throw ErrorClass("usage: -<option>=<value>; try -help for more");
197  argument = std::string(argV[i]);
198  epos = argument.find('=');
199  option = argument.substr(0,epos);
200  if (epos < std::string::npos)
201  value = argument.substr(epos+1);
202  else
203  value = "";
204 
205  std::cout << "option = \"" << option << "\"" << std::endl;
206  std::cout << "value = \"" << value << "\"" << std::endl;
207 
208  if (option == "-schema")
209  {
210  if (value == "")
211  throw ErrorClass("schema option must have a value");
212  schema = value;
213  }
214  else if (option == "-file")
215  {
216  if (value == "")
217  throw ErrorClass("file option must have a value");
218  testFileName = value;
219  useRandomObjects = false;
220  }
221  else if (option == "-replications")
222  {
223  if (value == "")
224  throw ErrorClass("number of replications must be given");
225  nrep = atoi(value.c_str());
226  }
227  else if (option == "-seed")
228  {
229  if (value == "")
230  throw ErrorClass("seed option must have a value");
231  seed = atoi(value.c_str());
232  }
233  else if (option == "-density")
234  {
235  if (value == "")
236  throw ErrorClass("density option must have a value");
237  density = os_strtod(value.c_str(), NULL);
238  }
239  else if (option == "-outfile")
240  {
241  if (value == "")
242  throw ErrorClass("outfile option must have a value");
243  outFileName = value;
244  }
245  else if (option == "-random")
246  {
247  useRandomObjects = (value == "YES" || value == "yes" || value == "Y" || value == "Y" || value == "y" || value == "");
248  testFileName = "";
249  }
250  else if (option == "-conformant")
251  {
252  conformant = (value == "YES" || value == "yes" || value == "Y" || value == "Y" || value == "y" || value == "");
253  }
254  else if (option == "-compress")
255  {
256  compress = (value == "YES" || value == "yes" || value == "Y" || value == "Y" || value == "y" || value == "");
257  }
258  else if (option == "-whitespace")
259  {
260  addWhiteSpace = (value == "YES" || value == "yes" || value == "Y" || value == "Y" || value == "y" || value == "");
261  }
262  else if (option == "-verify")
263  {
264  if (value == "")
265  verifyObjects = true;
266  else
267  verifyObjects = !(value == "NO" || value == "no" || value == "N" || value == "N" || value == "");
268 
269  if (verifyObjects)
270  {
271  if (outFileName == "") outFileName = "junk.tmp";
272  }
273  }
274  else if (option == "-norandom")
275  {
276  useRandomObjects = false;
277  }
278  else if (option == "-noconformant")
279  {
280  conformant = false;
281  }
282  else if (option == "-nocompress")
283  {
284  compress = false;
285  }
286  else if (option == "-nowhitespace")
287  {
288  addWhiteSpace = false;
289  }
290  else if (option == "-noverify")
291  {
292  verifyObjects = false;
293  }
294  else
295  {
296  std::cout << "option \"" << option << "\" not recognized" << std::endl;
297  }
298 
299  }
300  }
301 
302  if (outFileName != "") doOutput = true;
303 
304  fileUtil = new FileUtil();
305 
306  try
307  {
308 
309 /*********************************************************************
310  * Generate and parse random objects
311  *********************************************************************/
312  if (useRandomObjects)
313  {
314  if (schema == "osil")
315  {
316  for (int irep=0; irep < nrep; irep++)
317  {
318 /* steps required:
319  * generate random object
320  * write to string
321  * parse string
322  * if verify, compare
323  */
324  }
325  }
326  else if (schema == "osol")
327  {
328  OSOption *osoption, *osoption2;
329  OSoLWriter *osolwriter;
330  osolwriter = new OSoLWriter();
331  OSoLReader *osolreader;
332 
333  for (int irep=0; irep < nrep; irep++)
334  {
335 std::cout << "use random number seed: " << seed << std::endl;
336 
337  srand(seed);
338 
339 std::cout << "set random osoption" << std::endl;
340  osoption = new OSOption();
341  osoption->setRandom(density, conformant);
342 
343 std::cout << "write to string" << std::endl;
344 
345  osxl = osolwriter->writeOSoL(osoption);
346 
347 std::cout << osxl << std::endl;
348 
349  osolreader = new OSoLReader();
350  osoption2 = osolreader->readOSoL( osxl);
351  if (verifyObjects == true)
352  {
353  if (osoption->IsEqual(osoption2) == false)
354  throw ErrorClass("Two objects are not equal!");
355  }
356  delete osoption;
357  delete osolreader;
358  osoption = NULL;
359  osolreader = NULL;
360 
361  seed = rand();
362  }
363  }
364  else if (schema == "osrl")
365  {
366  OSResult *osresult, *osresult2;
367  OSrLWriter *osrlwriter;
368  osrlwriter = new OSrLWriter();
369  OSrLReader *osrlreader;
370 
371  for (int irep=0; irep < nrep; irep++)
372  {
373 std::cout << "use random number seed: " << seed << std::endl;
374 
375  srand(seed);
376 
377 std::cout << "set random osresult" << std::endl;
378  osresult = new OSResult();
379  osresult->setRandom(density, conformant);
380 
381 std::cout << "write to string" << std::endl;
382 
383  osxl = osrlwriter->writeOSrL(osresult);
384 
385 std::cout << osxl << std::endl;
386 
387  osrlreader = new OSrLReader();
388  osresult2 = osrlreader->readOSrL( osxl);
389  if (verifyObjects == true)
390  {
391  if (osresult->IsEqual(osresult2) == false)
392  throw ErrorClass("Two objects are not equal!");
393  }
394  delete osresult;
395  delete osrlreader;
396  osresult = NULL;
397  osrlreader = NULL;
398 
399  seed = rand();
400  }
401  }
402  }
403  else if (testFileName == "")
404  throw ErrorClass("No filename given. Nothing to parse.");
405  else
406  {
407 #ifdef MY_DEBUG
408  std::cout << "Processing file: " ;
409  std::cout << testFileName << std::endl;
410 #endif
411 
412  osxl = fileUtil->getFileAsString( testFileName.c_str() );
413 
414 #ifdef MY_DEBUG
415  std::cout << "Done reading the file into memory" << std::endl;
416 #endif
417 
418 /*********************************************************************
419  * Parse OSiL file
420  *********************************************************************/
421  if (schema == "osil")
422  {
423  osilreader = new OSiLReader();
425 #ifdef MY_DEBUG
426  std::cout << "Start parsing the file" << std::endl;
427 #endif
428  osinstance = osilreader->readOSiL( osxl);
429 
430 #ifdef MY_DEBUG
431  parsingTestResult << "Parsed file successfully" << std::endl;
432 #endif
433 
434  if (doOutput == true)
435  {
436  OSiLWriter *osilwriter;
437  osilwriter = new OSiLWriter();
438  osilwriter->m_bWriteBase64 = compress;
439  osilwriter->m_bWhiteSpace = addWhiteSpace;
440 #ifdef MY_DEBUG
441  std::cout << "Create output string from in-memory object" << std::endl;
442 #endif
443  outputString = osilwriter->writeOSiL(osinstance);
444 #ifdef MY_DEBUG
445  std::cout << "Created output string from in-memory object" << std::endl;
446 #endif
447  if (fileUtil->writeFileFromString( outFileName.c_str(), outputString) != true)
448  throw ErrorClass(" Error while writing compressed file");
449 
450  if (verifyObjects == true)
451  {
452  osxl = fileUtil->getFileAsString( outFileName.c_str() );
453  OSInstance *osinstance2;
454  osinstance2 = osilreader->readOSiL( osxl);
455  if (osinstance2->IsEqual(osinstance) == false)
456  throw ErrorClass("Two objects are not equal!");
457  }
458 
459  delete osilwriter;
460  osilwriter = NULL;
461  }
462  delete osilreader;
463  osilreader = NULL;
464  }
465 
466 /*********************************************************************
467  * Parse OSoL file
468  *********************************************************************/
469  else if (schema == "osol")
470  {
471  osolreader = new OSoLReader();
473 #ifdef MY_DEBUG
474  std::cout << "Start parsing the file" << std::endl;
475 #endif
476  osoption = osolreader->readOSoL( osxl);
477 
478 #ifdef MY_DEBUG
479  parsingTestResult << "Parsed file successfully" << std::endl;
480 #endif
481 
482  if (doOutput == true)
483  {
484  OSoLWriter *osolwriter;
485  osolwriter = new OSoLWriter();
486  osolwriter->m_bWriteBase64 = compress;
487  osolwriter->m_bWhiteSpace = addWhiteSpace;
488 #ifdef MY_DEBUG
489  std::cout << "Create output string from in-memory object" << std::endl;
490 #endif
491  outputString = osolwriter->writeOSoL(osoption);
492 #ifdef MY_DEBUG
493  std::cout << "Created output string from in-memory object" << std::endl;
494 #endif
495  if (fileUtil->writeFileFromString( outFileName.c_str(), outputString) != true)
496  throw ErrorClass(" Error while writing compressed file");
497 
498  if (verifyObjects == true)
499  {
500  osxl = fileUtil->getFileAsString( outFileName.c_str() );
501  OSoLReader *osolreader2;
502  osolreader2 = new OSoLReader();
503  OSOption *osoption2;
504  osoption2 = osolreader2->readOSoL( osxl);
505 #ifdef MY_DEBUG
506  std::cout << "Compare in-memory objects" << std::endl;
507 #endif
508  if (osoption2->IsEqual(osoption) == false)
509  throw ErrorClass("Two objects are not equal!");
510 #ifdef MY_DEBUG
511  else
512  std::cout << "in-memory objects compare equal" << std::endl;
513 #endif
514  delete osolreader2;
515  osolreader2 = NULL;
516  }
517 
518  delete osolwriter;
519  osolwriter = NULL;
520  }
521  delete osolreader;
522  osolreader = NULL;
523  }
524 
525 /*********************************************************************
526  * Parse OSrL file
527  *********************************************************************/
528  else if (schema == "osrl")
529  {
530  osrlreader = new OSrLReader();
532 #ifdef MY_DEBUG
533  std::cout << "Start parsing the file" << std::endl;
534 #endif
535  osresult = osrlreader->readOSrL( osxl);
536 
537 #ifdef MY_DEBUG
538  parsingTestResult << "Parsed file successfully" << std::endl;
539 #endif
540 
541  if (doOutput == true)
542  {
543  OSrLWriter *osrlwriter;
544  osrlwriter = new OSrLWriter();
545  osrlwriter->m_bWriteBase64 = compress;
546  osrlwriter->m_bWhiteSpace = addWhiteSpace;
547 #ifdef MY_DEBUG
548  std::cout << "Create output string from in-memory object" << std::endl;
549 #endif
550  outputString = osrlwriter->writeOSrL(osresult);
551 #ifdef MY_DEBUG
552  std::cout << "Created output string from in-memory object" << std::endl;
553 #endif
554  if (fileUtil->writeFileFromString( outFileName.c_str(), outputString) != true)
555  throw ErrorClass(" Error while writing compressed file");
556 
557  if (verifyObjects == true)
558  {
559  osxl = fileUtil->getFileAsString( outFileName.c_str() );
560  OSrLReader *osrlreader2;
561  osrlreader2 = new OSrLReader();
562  OSResult *osresult2;
563  osresult2 = osrlreader2->readOSrL( osxl);
564 #ifdef MY_DEBUG
565  std::cout << "Compare in-memory objects" << std::endl;
566 #endif
567  if (osresult2->IsEqual(osresult) == false)
568  throw ErrorClass("Two objects are not equal!");
569 #ifdef MY_DEBUG
570  else
571  std::cout << "in-memory objects compare equal" << std::endl;
572 #endif
573  delete osrlreader2;
574  osrlreader2 = NULL;
575  }
576 
577  delete osrlwriter;
578  osrlwriter = NULL;
579  }
580  delete osrlreader;
581  osrlreader = NULL;
582  }
583  }
584  }
585  catch(const ErrorClass& eclass)
586  {
587  cout << endl << endl << endl;
588  if (osilreader != NULL) delete osilreader;
589 // if (osolreader != NULL) delete osolreader;
590  if (osrlreader != NULL) delete osrlreader;
591  // Problem with the parser
592  parsingTestResultFailure << eclass.errormsg << endl;
593  parsingTestResultFailure << "There was a failure in the " + schema + " parser; ";
594  parsingTestResultFailure << "file " << testFileName << " not processed." << endl;
595  }
596 
597  delete fileUtil;
598  fileUtil = NULL;
599 
600  if (parsingTestResultFailure.str().length() > 0)
601  {
602  cout << "PARSING TEST FAILED ON THE FOLLOWING:" << endl << endl;
603  cout << parsingTestResultFailure.str() << endl << endl;
604  return 1;
605  }
606  else
607  {
608 
609 #ifdef MY_DEBUG
610  std::cout << "PARSING TEST SUCCEEDED" << std::endl;
611 #endif
612 
613  return 0;
614  }
615 }//end main
616 
617 bool interactiveShell(std::string *schema, std::string *testFileName, std::string *outFileName,
618  bool *compress, bool *addWhiteSpace, bool *verifyObjects, bool *useRandomObjects,
619  unsigned int *seed, int *nrep, double *density, bool *conformant)
620 {
621  std::string userInput;
622  bool haveParser = false;
623  std::cout << "Welcome to the parser test, which is part of the Optimization Services suite" << std::endl << std::endl;
624 
625  std::cout << "This program (c) 2011 Horand Gassmann, Jun Ma and Kipp Martin" << std::endl << std::endl;
626 
627  while (haveParser == false)
628  {
629  std::cout << "Input the parser you want to test (osil|osol|osrl)" << std::endl;
630  std::cout << " or \"quit\" to exit the program > ";
631  *schema = getUserInput(false);
632  if (*schema == "osil") break;
633  if (*schema == "osol") break;
634  if (*schema == "osrl") break;
635  if (*schema == "quit") return false;
636  }
637 
638  std::cout << "Input the file you want to parse or press return to generate random problems> ";
639  *testFileName = getUserInput(true);
640 
641  if (*testFileName == "")
642  {
643  std::cout << std::endl << "Random problem generation selected." << std::endl;
644  *useRandomObjects = true;
645 
646  std::cout << std::endl << "Do you want to input a random number seed? [y|N] > ";
647  std::string temp;
648  temp = getUserInput(true);
649  if (temp == "Y" || temp == "y")
650  {
651  std::cout << std::endl << "Input the random number seed (must be nonnegative integer) > ";
652  std::cin >> *seed;
653  }
654 
655  std::cout << " Input number of replications > ";
656  std::cin >> *nrep;
657 
658  std::cout << " Input density (0..1) > ";
659  std::cin >> *density;
660 
661  std::cout << " Enforce side constraints (Y|n) > ";
662  userInput = getUserInput(true);
663  if ( (userInput == "no") || (userInput == "NO") || (userInput == "No") || (userInput == "N") || (userInput == "n") )
664  *conformant = false;
665 
666  std::cout << "Do you want to verify that input and output represents the same object? (yes|NO) > ";
667  userInput = getUserInput(true);
668  if ( (userInput == "yes") || (userInput == "YES") || (userInput == "Yes")|| (userInput == "Y") || (userInput == "y") )
669  *verifyObjects = true;
670  }
671  else
672  {
673  std::cout << std::endl << "The remaining arguments are optional." << std::endl;
674 
675  std::cout << "Name of the output file to which you want to print the object after processing" << std::endl;
676  std::cout << "> ";
677  *outFileName = getUserInput(true);
678 
679  if (*outFileName == "")
680  std::cout << "No output generated; remaining options skipped." << std::endl;
681  else
682  {
683  std::cout << "Do you want to compress the output (using mult and incr attributes where possible)? (YES|no) > ";
684  userInput = getUserInput(true);
685  if ( (userInput == "no") || (userInput == "NO") || (userInput == "No") || (userInput == "N") || (userInput == "n") )
686  *compress = false;
687 
688  std::cout << "Do you want to add whitespace (newline characters) between elements? (YES|no) > ";
689  userInput = getUserInput(true);
690 
691  if ( (userInput == "no") || (userInput == "NO") || (userInput == "No") ) *addWhiteSpace = false;
692 
693  std::cout << "Do you want to verify that input and output represents the same object? (yes|NO) > ";
694  userInput = getUserInput(true);
695  if ( (userInput == "yes") || (userInput == "YES") || (userInput == "Yes")|| (userInput == "Y") || (userInput == "y") )
696  *verifyObjects = true;
697  }
698  }
699 
700  std::cout << std::endl << "echo input parameters" << std::endl;
701  std::cout << "schema: \"" << *schema << "\"" << std::endl;
702  std::cout << "testFileName: \"" << *testFileName << "\"" << std::endl;
703  std::cout << "outFileName: \"" << *outFileName << "\"" << std::endl;
704  std::cout << "compress: \"" << *compress << "\"" << std::endl;
705  std::cout << "addWhiteSpace: \"" << *addWhiteSpace << "\"" << std::endl;
706  std::cout << "verifyObjects: \"" << *verifyObjects << "\"" << std::endl;
707  std::cout << "replications: \"" << *nrep << "\"" << std::endl;
708  std::cout << "random seed: \"" << *seed << "\"" << std::endl;
709  std::cout << "density: \"" << *density << "\"" << std::endl;
710  std::cout << "conformant: \"" << *conformant << "\"" << std::endl;
711 
712  return true;
713 }
714 
715 void printHelp()
716 {
717  std::cout << "usage: parsertest <parser> <filename>" << std::endl;
718  std::cout << " [<outfile> [(no)compress (no)addwhitespace (no)verify]]" << std::endl << std::endl;
719 
720  std::cout << "where <parser> is \'osil\' or \'osol\' or \'osrl\'" << std::endl;
721  std::cout << " <filename> is the (path to the) input file you want to parse" << std::endl;
722  std::cout << " <outfile> is the (path to the) output file to print the object just read" << std::endl;
723  std::cout << " compress|nocompress controls the use of mult and incr attributes" << std::endl;
724  std::cout << " to compress the output file. (The default is compress)" << std::endl;
725  std::cout << " addwhitespace|noaddwhitespace governs the use of whitespace (linefeed" << std::endl;
726  std::cout << " characters between elements. (The default is addwhitespace)" << std::endl;
727  std::cout << " verify|noverify governs checks whether the input and output files " << std::endl;
728  std::cout << " represent the same in-memory object. (The default is noverify)" << std::endl;
729  return;
730 }
731 
732 std::string getUserInput(bool defaultPresent)
733 {
734  std::string lineText;
735 
736  std::string wordSep = " ";
737  std::string optionName = "";
738  std::string optionValue = "";
739  std::string::size_type indexStart;
740  std::string::size_type indexEnd;
741 
742  for (;;)
743  {
744  getline(std::cin, lineText);
745  lineText = " " + lineText + " ";
746  indexStart = lineText.find_first_not_of(wordSep);
747  if (indexStart != std::string::npos)
748  {
749  indexEnd = lineText.find_first_of(wordSep, indexStart + 1);
750  return lineText.substr(indexStart, indexEnd - indexStart);
751  }
752  if (defaultPresent) return "";
753  std::cout << std::endl;
754  std::cout << "You did not enter a valid option. Try again." << std::endl;
755  }
756  return "";
757 }
double os_strtod(const char *s00, char **se)
Definition: OSdtoa.cpp:2541
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
Definition: OSrLWriter.h:69
bool writeFileFromString(char *fname, std::string thestring)
write a file from an input string.
Definition: OSFileUtil.cpp:116
std::string errormsg
errormsg is the error that is causing the exception to be thrown
Definition: OSErrorClass.h:42
bool interactiveShell(std::string *schema, std::string *testFileName, std::string *outFileName, bool *compress, bool *addWhiteSpace, bool *verifyObjects, bool *useRandomObjects, unsigned int *seed, int *nrep, double *density, bool *conformant)
int main(int argc, char *argv[])
Definition: BB_tm.cpp:32
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
Definition: OSrLReader.cpp:97
The Result Class.
Definition: OSResult.h:2548
OSOption * osoption
bool setRandom(double density, bool conformant)
A function to make a random instance of this class.
Definition: OSResult.cpp:9698
bool m_bWriteBase64
m_bWriteBase64 is set to true if we encode the linear constraint coefficients in base64 binary ...
Definition: OSiLWriter.h:64
fint nrep
bool IsEqual(OSInstance *that)
A function to check for the equality of two objects.
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:30
Take an OSOption object and write a string that validates against the OSoL schema.
Definition: OSoLWriter.h:29
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Definition: OSiLReader.cpp:53
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
Definition: OSrLWriter.cpp:45
The Option Class.
Definition: OSOption.h:3564
bool setRandom(double density, bool conformant)
A function to make a random instance of this class.
Definition: OSOption.cpp:12199
Used to read an OSiL string.
Definition: OSiLReader.h:37
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
Definition: OSoLWriter.cpp:45
OSResult * osresult
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Definition: OSoLReader.cpp:76
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
Definition: OSiLWriter.h:68
bool m_bWriteBase64
m_bWriteBase64 is set to true if we encode the linear constraint coefficients in base64 binary ...
Definition: OSoLWriter.h:62
bool IsEqual(OSOption *that)
A function to check for the equality of two objects.
Definition: OSOption.cpp:9614
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
Definition: OSiLWriter.cpp:40
Used to read an OSoL string.
Definition: OSoLReader.h:37
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
Definition: OSFileUtil.cpp:35
The OSrLReader Class.
Definition: OSrLReader.h:42
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
Definition: OSoLWriter.h:66
bool IsEqual(OSResult *that)
A function to check for the equality of two objects.
Definition: OSResult.cpp:7485
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2262
OSInstance * osinstance
class used to make it easy to read and write files.
Definition: OSFileUtil.h:37
used for throwing exceptions.
Definition: OSErrorClass.h:31
bool m_bWriteBase64
m_bWriteBase64 is set to true if we encode the linear constraint coefficients in base64 binary ...
Definition: OSrLWriter.h:65
std::string getUserInput(bool defaultPresent)
void printHelp()
Take an OSInstance object and write a string that validates against the OSiL schema.
Definition: OSiLWriter.h:29