My Project
OSCommandLineReader.cpp
Go to the documentation of this file.
1/* $Id: OSCommandLineReader.cpp 4263 2011-09-09 20:19:26Z Gassmann $ */
16#include "OSCommandLineReader.h"
17#include "OSCommandLine.h"
18#include "OSFileUtil.h"
19#include "OSConfig.h"
20#include "OSOutput.h"
21
22
23#include <stdio.h>
24
25using std::endl;
26using std::ostringstream;
27using std::string;
28
29
31YY_BUFFER_STATE osss_scan_string(const char* osss, void* scanner);
32void setyyextra(OSCommandLine *oscommandline, void* scanner);
33int ossslex(void* scanner);
34int ossslex_init(void** ptr);
35int ossslex_destroy(void* scanner);
36
37
42
44{
45 ostringstream outStr;
46 // parse the command line once
47#ifndef NDEBUG
49#endif
50 parseString(osss);
51
52 // if there is a config file, get those options
53 if (m_oscommandline->configFile != "")
54 {
55 FileUtil *fileUtil = NULL;
56#ifndef NDEBUG
57 outStr << "configFile = " << m_oscommandline->configFile << std::endl;
59#endif
60 std::string configFileOptions = fileUtil->getFileAsString(m_oscommandline->configFile.c_str());
61#ifndef NDEBUG
63#endif
64 parseString(configFileOptions);
65
66 // now parse the command line a second time
67#ifndef NDEBUG
68 osoutput->OSPrint(ENUM_OUTPUT_AREA_Command_line_parser, ENUM_OUTPUT_LEVEL_trace, "parse command line again");
69#endif
70 parseString(osss);
71 }
72
73 return m_oscommandline;
74}
75
77{
78 void* scanner;
79 bool scannerActive;
80 std::ostringstream outStr;
81
82 // scan the string for commands
83 scannerActive = true;
86 osss_scan_string(osss.c_str(), scanner);
87#ifndef NDEBUG
89#endif
92 scannerActive = false;
93#ifndef NDEBUG
94 osoutput->OSPrint(ENUM_OUTPUT_AREA_Command_line_parser, ENUM_OUTPUT_LEVEL_trace, "done with call to ossslex");
95#endif
96
97 return m_oscommandline;
98}
99
100
106
int ossslex_destroy(void *scanner)
int ossslex_init(void **ptr)
YY_BUFFER_STATE osss_scan_string(const char *osss, void *scanner)
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
void setyyextra(OSCommandLine *oscommandline, void *scanner)
int ossslex(void *scanner)
struct yy_buffer_state * YY_BUFFER_STATE
int ossslex_destroy(void *scanner)
int ossslex_init(void **ptr)
YY_BUFFER_STATE osss_scan_string(const char *osss, void *scanner)
void setyyextra(OSCommandLine *oscommandline, void *scanner)
int ossslex(void *scanner)
#define scanner
class used to make it easy to read and write files.
Definition OSFileUtil.h:38
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
This class is used to store command line options for the OSSolverService executable and to provide me...
std::string configFile
configFile is the name of the file that holds the configuration options if the OSSolverService reads ...
~OSCommandLineReader()
OSCommandLineReader class destructor.
OSCommandLine * readCommandLine(const std::string &osss)
Get an OSCommandLine object from a command line string.
OSCommandLine * parseString(const std::string &osss)
Parse a string and store it into an OSCommandLine object.
OSCommandLine * m_oscommandline
m_oscommandline is the OSCommandLine object returned by the OSCommandLineReader
OSCommandLineReader()
OSCommandLineReader class constructor.
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_AREA_Command_line_parser