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),
197 virtual ~JShellParser()
206 virtual void terminate(
const int status)
208 __terminate__ =
true;
209 __exit_code__ = status;
239 gexit(__exit_code__);
257 struct JShellParser :
258 public JShellParser<>
260 typedef JShellParser<>::key_type key_type;
268 void evaluate()
const
270 for (
typename data_type::const_iterator
i = this->
data.begin();
i != this->
data.end(); ++
i) {
272 std::ostringstream os;
297 struct JEnvironment<std::
string> :
298 public JShellParser<std::string>
300 typedef JShellParser<std::string>::key_type key_type;
318 friend inline std::istream&
operator>>(std::istream& in, JEnvironment& environment)
329 if (!has_facet<JEquationFacet>(in.getloc())) {
330 in.imbue(locale(in.getloc(), facet.clone()));
333 if (in >>
c >> key >> equation) {
335 if (
c ==
'-' && !equation.getKey().empty()) {
337 environment.data.push_back(parameter_type(equation.getKey()));
339 parameter_type& parameter = environment.data.back();
341 if (facet.isSeparator(equation.getSeparator())) {
345 istringstream
is(equation.getValue());
349 for (parameter_type buffer(parameter.name);
getline(
is, buffer.value, OPTIONS_SEPARATOR); ) {
351 buffer.value =
trim(buffer.value);
353 possible_values.push_back(buffer);
356 environment[key] =
JPARSER::getOption(parameter, equation.getKey(), possible_values.begin(), possible_values.end());
365 THROW(
JParseError,
"JEnvironment: error parsing " <<
c <<
" <" << equation.getKey() <<
">");
378 struct JEnvironment<bool> :
379 public JShellParser<bool>
381 typedef JShellParser<bool>::key_type key_type;
399 friend inline std::istream&
operator>>(std::istream& in, JEnvironment& environment)
410 if (!has_facet<JEquationFacet>(in.getloc())) {
411 in.imbue(locale(in.getloc(), facet.clone()));
414 if (in >>
c >> key >> equation) {
416 if (
c ==
'-' && !equation.getKey().empty()) {
418 environment.data.push_back(parameter_type(equation.getKey()));
420 parameter_type& parameter = environment.data.back();
422 if (facet.isSeparator(equation.getSeparator()) || equation.getValue() !=
"") {
424 THROW(
JParseError,
"JEnvironment: invalid operation " <<
c <<
" <" << equation.getKey() <<
">");
433 THROW(
JParseError,
"JEnvironment: error parsing " <<
c <<
" <" << equation.getKey() <<
">");
452 int main(
int argc,
char **argv)
459 JEnvironment<bool> boolean;
460 JEnvironment<string> regular;
469 JShellParser<> buffer;
471 buffer.join(
boolean);
472 buffer.join(regular);
479 catch(
const exception& error) {
480 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::vector< event_type > data_type
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.
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
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.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Exception for parsing value.
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