26 const char OPTIONS_SEPARATOR =
',';
54 return (first.name == second.name &&
55 first.value == second.value);
67 inline std::istream&
read(std::istream&
in)
69 return in >> this->value;
81 inline std::ostream&
write(std::ostream& out)
const
83 return out << this->value;
132 return out << (this->value ?
"1" :
"0");
146 return parameter.read(in);
158 inline std::ostream& operator<<(std::ostream& out, const JParameter<T>& parameter)
160 return parameter.write(out);
167 template<
class T = JNullType>
189 __terminate__(false),
199 virtual void terminate(
const int status)
201 __terminate__ =
true;
202 __exit_code__ = status;
232 gexit(__exit_code__);
250 struct JShellParser :
251 public JShellParser<>
253 typedef JShellParser<>::key_type key_type;
261 void evaluate()
const
263 for (
typename data_type::const_iterator i = this->data.begin(); i != this->data.end(); ++i) {
265 std::ostringstream os;
290 struct JEnvironment<std::string> :
291 public JShellParser<std::string>
293 typedef JShellParser<std::string>::key_type key_type;
311 friend inline std::istream&
operator>>(std::istream& in, JEnvironment& environment)
322 if (!has_facet<JEquationFacet>(in.getloc())) {
323 in.imbue(locale(in.getloc(), facet.clone()));
326 if (in >>
c >> key >> equation) {
328 if (
c ==
'-' && !equation.getKey().empty()) {
330 environment.data.push_back(parameter_type(equation.getKey()));
332 parameter_type& parameter = environment.data.back();
334 if (facet.isSeparator(equation.getSeparator())) {
338 istringstream
is(equation.getValue());
342 for (parameter_type buffer(parameter.name);
getline(
is, buffer.value, OPTIONS_SEPARATOR); ) {
344 buffer.value =
trim(buffer.value);
346 possible_values.push_back(buffer);
349 environment[key] =
JPARSER::getOption(parameter, equation.getKey(), possible_values.begin(), possible_values.end());
358 THROW(
JParseError,
"JEnvironment: error parsing " <<
c <<
" <" << equation.getKey() <<
">");
371 struct JEnvironment<bool> :
372 public JShellParser<bool>
374 typedef JShellParser<bool>::key_type key_type;
392 friend inline std::istream&
operator>>(std::istream& in, JEnvironment& environment)
403 if (!has_facet<JEquationFacet>(in.getloc())) {
404 in.imbue(locale(in.getloc(), facet.clone()));
407 if (in >>
c >> key >> equation) {
409 if (
c ==
'-' && !equation.getKey().empty()) {
411 environment.data.push_back(parameter_type(equation.getKey()));
413 parameter_type& parameter = environment.data.back();
415 if (facet.isSeparator(equation.getSeparator()) || equation.getValue() !=
"") {
417 THROW(
JParseError,
"JEnvironment: invalid operation " <<
c <<
" <" << equation.getKey() <<
">");
426 THROW(
JParseError,
"JEnvironment: error parsing " <<
c <<
" <" << equation.getKey() <<
">");
445 int main(
int argc,
char **argv)
452 JEnvironment<bool> boolean;
453 JEnvironment<string> regular;
462 JShellParser<> buffer;
464 buffer.join(
boolean);
465 buffer.join(regular);
472 catch(
const exception& error) {
473 return gexit(2, error.what());
Utility class to parse command line options.
JParameter()
Default constructor.
int main(int argc, char *argv[])
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
void gprint(const std::string &message)
Print method.
JParserTemplateElement< bool > getOption(bool &object, const std::string &name, const std::string &help="")
Auxiliary method for creation of template parser element object.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
std::string trim(const std::string &buffer)
Trim string.
General purpose equation class.
then usage $script[port]< option > nPossible options
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Auxiliary class for no type definition.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Data structure to store command line arguments.
friend bool operator==(const JParameter< T > &first, typename JClass< JNullType >::argument_type second)
Equal operator.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
int gexit(int status, const std::string &message="")
Exit method.
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Utility class to parse command line options.
Exception for parsing value.
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in