00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "cmdline.h"
00036
00037 CmdLine::CmdLine(ISTREAM_TYPE _query_istream_type,
00038 ISTREAM_TYPE _xml_istream_type,
00039 OSTREAM_TYPE _eout_ostream_type,
00040 OSTREAM_TYPE _dout_ostream_type, const char *_query_arg,
00041 const char *_xml_arg, const char *_eout_arg,
00042 const char *_dout_arg, bool _debug,
00043 bool _preprocess_stream_debug,
00044 bool
00045 _preprocess_stream_no_debug):query_istream_type
00046 (_query_istream_type),
00047 xml_istream_type(_xml_istream_type),
00048 eout_ostream_type(_eout_ostream_type),
00049 dout_ostream_type(_dout_ostream_type),
00050 query_arg(_query_arg),
00051 xml_arg(_xml_arg),
00052 eout_arg(_eout_arg),
00053 dout_arg(_dout_arg),
00054 debug(_debug),
00055 preprocess_stream_debug(_preprocess_stream_debug),
00056 preprocess_stream_no_debug(_preprocess_stream_no_debug) {
00057 }
00058
00059 CmdLine::~CmdLine() {
00060
00061
00062
00063
00064 }
00065
00066
00067 void CmdLine::checkIntegrity() {
00068 bool error = false;
00069 bool require_arg = true;
00070 bool require_endl = false;
00071
00072 std::ostringstream o;
00073 switch (query_istream_type) {
00074 case it_file:
00075 break;
00076 case it_null:
00077 require_arg = false;
00078 break;
00079 case it_socket:
00080 break;
00081 case it_stdin:
00082 require_arg = false;
00083 break;
00084 }
00085 if (require_arg && !query_arg) {
00086 error = true;
00087 if (require_endl) {
00088 o << endl;
00089 }
00090 o << "Query Input Stream Requires Argument And Parameter \"--query <query stream>\"";
00091 require_endl = true;
00092 }
00093 require_arg = true;
00094 switch (eout_ostream_type) {
00095 case ot_file:
00096 break;
00097 case ot_null:
00098 require_arg = false;
00099 break;
00100 case ot_socket:
00101 break;
00102 case ot_stdout:
00103 require_arg = false;
00104 break;
00105 }
00106 if (require_arg && !eout_arg) {
00107 error = true;
00108 if (require_endl) {
00109 o << endl;
00110 }
00111 o << "Result Output Stream Requires Argument And Parameter \"--eout <eval stream>\"";
00112 require_endl = true;
00113 }
00114 require_arg = true;
00115 switch (dout_ostream_type) {
00116 case ot_file:
00117 break;
00118 case ot_null:
00119 require_arg = false;
00120 break;
00121 case ot_socket:
00122 break;
00123 case ot_stdout:
00124 require_arg = false;
00125 break;
00126 }
00127 if (require_arg && !dout_arg) {
00128 error = true;
00129 if (require_endl) {
00130 o << endl;
00131 }
00132 o << "Debug Output Stream Requires Argument And Parameter \"--dout <debug stream>\"";
00133 require_endl = true;
00134 }
00135 if (xml_istream_type == it_stdin && query_istream_type == it_stdin) {
00136 error = true;
00137 if (require_endl) {
00138 o << endl;
00139 }
00140 o << "Cannot Read Both XML File and Query From STDIN In Parallel";
00141 require_endl = true;
00142 }
00143 if (query_istream_type == it_null) {
00144 error = true;
00145 if (require_endl) {
00146 o << endl;
00147 }
00148 o << "Invalid Query Input Stream (Query Cannot Be Read From Null Stream)";
00149 require_endl = true;
00150 }
00151 if (error) {
00152 throw InvalidArgumentException(o.str().c_str());
00153 }
00154 }