1 #ifndef __JEEP__JPARSER__ 
    2 #define __JEEP__JPARSER__ 
   52   using JLANG::JComparisonAvailable;
 
   98     return in.bad() || (in.fail() && !in.eof());
 
  142     operator const T&() 
const 
  186       object.__status = 
true;
 
  206         out << 
object.__value;
 
  264     inline bool less(
const int value)
 const 
  276     inline bool more(
const int value)
 const 
  335       out << 
object.counter;
 
  360                             const std::string& help = 
"") :
 
  419     virtual void print(std::ostream& out)
 const  
  423       out << 
"<" << 
getName() << 
">"; 
 
  430           out << setw(width) << 
" ";
 
  439         out << 
" \"" << 
getHelp() << 
"\""; 
 
  465   template<class JType_t, bool has_eq = JComparisonAvailable<JType_t>::has_eq>
 
  472   template<
class JType_t>
 
  504       __element.possibleValues.push_back(value);
 
  516     template<
template<
class, 
class> 
class JContainer_t, 
class JAllocator_t>
 
  519       for (
typename JContainer_t<JType_t, JAllocator_t>::const_iterator i = values.begin(); i != values.end(); ++i) {
 
  520         __element.possibleValues.push_back(*i);
 
  533     template<
template<
class, 
class, 
class> 
class JContainer_t, 
class JCompare_t, 
class JAllocator_t>
 
  536       for (
typename JContainer_t<JType_t, JCompare_t, JAllocator_t>::const_iterator i = values.begin(); i != values.end(); ++i) {
 
  537         __element.possibleValues.push_back(*i);
 
  551   template<
class JType_t>
 
  564                            const std::string& 
name   = 
"arg",
 
  565                            const std::string& help   = 
"") :
 
  568       is_initialised(false)
 
  634       return is_initialised;
 
  645       is_initialised = value;
 
  655     virtual std::istream& 
read(std::istream& 
in)
 override  
  657       if (in.peek() == EOF) {
 
  667       while (isspace(in.peek())) {
 
  671       if (in.peek() != EOF) {
 
  687     virtual std::ostream& 
write(std::ostream& out)
 const override  
  713     if (in.peek() != EOF) {
 
  740   template<bool option = JLANG::JResolve<TString>::value>
 
  758     static inline std::istream& 
read(std::istream& 
in, 
T& 
object)
 
  792     static inline std::istream& 
read(std::istream& 
in, 
T& 
object)
 
  794       return object.ReadLine(in);
 
  807       for (std::string buffer; in >> buffer; ) {
 
  808         object.push_back(TString(buffer.c_str()));
 
  853   template<
class JType_t>
 
  869                            const std::string& 
name   = 
"arg",
 
  870                            const std::string& help   = 
"") :
 
  885                            const std::string& 
name,
 
  890       setPossibleValues(__begin, __end);
 
  905                            const std::string& 
name,
 
  906                            const std::string& help,
 
  911       setPossibleValues(__begin, __end);
 
  951       this->
object = value;
 
  955       possibleValues.push_back(value);
 
  967     template<
template<
class, 
class> 
class JContainer_t, 
class JAllocator_t>
 
  970       setPossibleValues(values.begin(), values.end());
 
  982     template<
template<
class, 
class, 
class> 
class JContainer_t, 
class JCompare_t, 
class JAllocator_t>
 
  985       setPossibleValues(values.begin(), values.end());
 
 1002       if (possibleValues.size() > 1) {
 
 1005           if (this->
object == *i) {
 
 1025     virtual void print(std::ostream& out)
 const override  
 1030         writeArray(out, 
" [", 
"]", 
", ", possibleValues.begin(), possibleValues.end());
 
 1044       if (__begin != __end) {
 
 1046         this->
object = *__begin;
 
 1050         for (
T i = __begin; i != __end; ++i) {
 
 1051           possibleValues.push_back(*i);
 
 1084       this->
object = 
false;
 
 1095     virtual std::istream& 
read(std::istream& 
in)
 override  
 1097       this->
object = 
true;
 
 1109     virtual std::ostream& 
write(std::ostream& out)
 const override  
 1111       return out << object;
 
 1198     virtual std::istream& 
read(std::istream& 
in)
 override  
 1200       return in >> object;
 
 1210     virtual std::ostream& 
write(std::ostream& out)
 const override  
 1212       return out << object;
 
 1301       JSharedPointer_t::operator=(static_cast<JSharedPointer_t&>(value));
 
 1313     template<
class JType_t>
 
 1330     template<
class JType_t>
 
 1347     template<
class JType_t>
 
 1369         (*this)->setInitialiationStatus(
true);
 
 1383       (*this)->setInitialiationStatus(
false);
 
 1399         return value->read(in);
 
 1415         return value->write(out);
 
 1430         return get()->
print(out);
 
 1499   template<
class JKey_t = 
char>
 
 1501     public std::map<JKey_t, JParserElement>,
 
 1535             const int debug = 0) :
 
 1550       this->insert(parser.begin(), parser.end());
 
 1564       using namespace std;
 
 1565       using namespace JPP;
 
 1568         out << help << endl;
 
 1583         i->second.print(out);
 
 1614       return (*
this)(
JArgs(argc, argv));
 
 1626       using namespace std;
 
 1627       using namespace JLANG;
 
 1628       using namespace JEEP;
 
 1636       for (JArgs::const_iterator i = args.begin(); i != args.end(); ++i) {
 
 1638         DEBUG(
"Processing option <" << *i << 
">" << endl);
 
 1643         for (
int c; (c = 
is.get()) != EOF; ) {
 
 1647             if        (
is.peek() == EOF) {                      
 
 1651             } 
else if (isspace(
is.peek())) {                    
 
 1656             while (
is.peek() != EOF) {                          
 
 1664                 if (
is.peek() != EOF) {
 
 1684                 cout << 
"source:    " << 
getSource()     << endl;
 
 1698                 if (
is.peek() != EOF) {
 
 1710                     if (
is.peek() == EOF && i + 1 != args.end()) {
 
 1719                     ofstream out(file_name.c_str());
 
 1721                     out << getpid() << endl;
 
 1737                 return JArgs(pid, ++i, args.end());
 
 1747                 DEBUG(
"Processing option <" << option << 
"> " << (p != this->end()) << endl);
 
 1749                 if (p != this->end()) {
 
 1751                   if (p->second->gcount()) {
 
 1753                     if (
is.peek() == EOF && i + 1 != args.end()) {
 
 1762                   catch(
const exception& error) {
 
 1798     int read(
const int argc, 
const char* 
const argv[])
 
 1800       (*this)(argc, argv);
 
 1827     std::ostream& 
write(std::ostream& out)
 const 
 1830         out << i->second->getName() << 
'=' << i->second << std::endl;
 
 1844     friend inline std::ostream& operator<<(std::ostream& out, const JParser<key_type>& parser)
 
 1846       return parser.write(out); 
 
 1859         if (!p->second->getInitialisationStatus()) {
 
 1863         if (!p->second->getStatus()) {
 
 1910   template<
class JType_t>
 
 1927   template<
class JType_t, 
class T>
 
 1929                                                    const std::string& 
name,
 
 1930                                                    const std::string& help,
 
 1947   template<
class JType_t, 
class T>
 
 1949                                                    const std::string& 
name,
 
 1953     return getOption(
object, name, 
"", __begin, __end);
 
 1961 #define make_field(A, ...)   JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, "")) 
 1967 #define make_option(A, ...)  JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, "")) 
JArgs operator()(const JArgs &args)
Parse the program's command line options. 
 
Utility class to parse command line options. 
 
Auxiliary data structure for alignment of data. 
 
virtual std::istream & read(std::istream &in) override
Stream input. 
 
JParser(const int debug=0)
Default constructor. 
 
static char PID_OPTION
print PID to file 
 
JParserTemplateElement< JType_t > & operator=(const JParserTemplateElement< JType_t > &value)
Assignment operator. 
 
virtual bool getStatus() const =0
Get status of parameter. 
 
const JParserElement & operator=(const initialised &value)
Set initialised status to true. 
 
virtual bool getInitialisationStatus() const override
Get initialisation status of parameter. 
 
const char * getGITCommit()
Get GIT commit. 
 
Template specialisation of JPARSER::JParserTemplateElement for data type with equal operator ==...
 
static char PRINT_OPTION
print option 
 
virtual void setInitialiationStatus(const bool value) override
Set initialisation status of parameter. 
 
const char * getGITDate()
Get GIT date. 
 
std::string double_quote(const std::string &value)
Quote string. 
 
std::ostream & write(std::ostream &out) const 
Print the current parameter values. 
 
std::string help
help message 
 
virtual bool getStatus() const override
Status of object. 
 
friend std::istream & operator>>(std::istream &in, JParserElement &value)
Stream input. 
 
virtual std::ostream & write(std::ostream &out) const override
Stream output. 
 
const JOption< T > & operator=(const T &value)
Assignment to a value. 
 
Template specialisation of JPARSER::JParserTemplateElement for data type without equal operator ==...
 
JParserTemplateElement< JType_t > & operator=(JType_t &value)
Assignment operator. 
 
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream. 
 
JParserTemplateElement< bool > getOption(bool &object, const std::string &name, const std::string &help="")
Auxiliary method for creation of template parser element object. 
 
JParserTemplateElement(JType_t &object, const std::string &name="arg", const std::string &help="")
Constructor. 
 
#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
 
Auxiliary class to handle pointer to JPARSER::JParserElementInterface. 
 
static std::istream & read(std::istream &in, std::vector< T > &object)
Read std::vector of objects from input stream. 
 
Auxiliary class for handling I/O of TString depending on its existence. 
 
Jpp environment information. 
 
const JParserTemplateElement< JType_t, true > & operator=(const not_initialised &value)
Set initialised status to false. 
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
virtual bool gcount() const override
Read counter. 
 
Auxiliary class to handle optional I/O. 
 
virtual void setInitialiationStatus(const bool value) override
Set initialisation status of parameter. 
 
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR. 
 
bool is_valid() const 
Check validity of pointer. 
 
JParser(const std::string &message, const int debug=0)
Constructor. 
 
JParserElement()
Default constructor. 
 
JSharedPointer< JParserElementInterface > JSharedPointer_t
 
const std::string & getName() const 
Get name of parameter. 
 
virtual void print(std::ostream &out) const 
Print. 
 
JParserTemplateElement< JType_t > & __element
 
std::istream & readObject(std::istream &in, T &object)
Stream input of object. 
 
virtual bool getStatus() const override
Status of object. 
 
virtual bool getInitialisationStatus() const =0
Get initialisation status of parameter. 
 
const JCounter & operator=(const bool value)
Set value. 
 
virtual void setInitialiationStatus(const bool value)=0
Set initialisation status of parameter. 
 
static char REVISION_OPTION
revision option 
 
JParserElement(const JParserElement &value)
Copy constructor. 
 
bool more(const int value) const 
Compare value. 
 
void setPossibleValues(T __begin, T __end)
Set possible values. 
 
std::ostream & write(std::ostream &out) const
 
void print(std::ostream &out) const 
Print the possible command line options. 
 
JParserTemplateElement(JType_t &object, const std::string &name, T __begin, T __end)
Constructor. 
 
JCSV & operator,(JType_t value)
Parsing of additional possible values. 
 
I/O formatting auxiliaries. 
 
std::string getGITVersion(const std::string &tag)
Get GIT version for given GIT tag. 
 
Auxiliary template class for type bool. 
 
The template JSharedPointer class can be used to share a pointer to an object. 
 
JCSV(JParserTemplateElement< JType_t > &element)
Constructor. 
 
map_type::iterator iterator
 
JParserElement & operator=(JParserElement &value)
Assignment operator. 
 
const JParserTemplateElement< JType_t, false > & operator=(const initialised &value)
Set initialised status to true. 
 
Interface for I/O of parser element. 
 
JCounter()
Default constructor. 
 
virtual bool getInitialisationStatus() const override
Get initialisation status of parameter. 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
int read(const JArgs &args)
Parse the program's command line options. 
 
bool getLongprint(std::ostream &out)
Get long print option. 
 
bool is_valid(const json &js)
Check validity of JSon data. 
 
virtual std::ostream & write(std::ostream &out) const override
Stream output. 
 
std::string getURL()
Get URL of document pages. 
 
friend std::istream & operator>>(std::istream &in, JOption &object)
Read option from input. 
 
int getCounter() const 
Get counter. 
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line. 
 
friend std::istream & operator>>(std::istream &in, JCounter &object)
Read option from input. 
 
virtual bool getStatus() const override
Get status of object. 
 
JOption(const T &value)
Constructor. 
 
virtual std::ostream & write(std::ostream &out) const override
Stream output. 
 
void check_status() const 
Check if all required options have been set. 
 
Data structure to store command line arguments. 
 
Exception when parsing a value. 
 
JParserTemplateElement(JType_t &object, const std::string &name, const std::string &help, T __begin, T __end)
Constructor. 
 
const JParserTemplateElement< JType_t, true > & operator=(const initialised &value)
Set initialised status to true. 
 
Template definition of auxiliary base class for comparison of data structures. 
 
General purpose messaging. 
 
JLANG::JParserException JParserException
 
bool fail(std::istream &in)
Check for stream state. 
 
virtual std::ostream & write(std::ostream &out) const =0
Stream output. 
 
JParserTemplateElement(bool &object, const std::string &name="arg", const std::string &help="")
Constructor. 
 
JCSV< JType_t > operator=(const JContainer_t< JType_t, JAllocator_t > &values)
Assignment to a default value and possible other values. 
 
virtual bool getStatus() const override
Get status of object. 
 
Empty structure for specification of parser element that is not initialised (i.e. does require input)...
 
virtual std::istream & read(std::istream &in) override
Stream input. 
 
virtual void terminate(const int status)
Terminate. 
 
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor. 
 
std::map< key_type, JParserElement > map_type
 
Template specialisation of JPARSER::JParserTemplateElement for type bool. 
 
std::ostream & writeArray(std::ostream &out, const char *left, const char *right, const char *sep, T __begin, T __end)
Write array of objects. 
 
JParserTemplateElement(JType_t &object, const std::string &name="arg", const std::string &help="")
Constructor. 
 
virtual const char * what() const override
Get error message. 
 
Interface for ASCII output using standard streams. 
 
int read(const int argc, const char *const argv[])
Parse the program's command line options. 
 
JCSV & operator,(const JContainer_t< JType_t, JAllocator_t > &values)
Parsing of additional possible values. 
 
std::vector< JType_t > possibleValues
 
void setPrintOption(std::ostream &out, const int option)
Set print option. 
 
bool less(const int value) const 
Compare value. 
 
virtual void print(std::ostream &out) const override
Print. 
 
virtual std::istream & read(std::istream &in) override
Stream input. 
 
JCSV< JType_t > operator=(const JCSV< JType_t > &value)
Assignment operator. 
 
const char * getSource()
Get source. 
 
static char END_OF_OPTIONS
end of all options 
 
const JParserTemplateElement< JType_t, false > & operator=(const not_initialised &value)
Set initialised status to false. 
 
Auxiliary class to assign the remainder of a sequence of Comma Separated Values. 
 
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
 
JCSV< JType_t > operator=(const JType_t &value)
Assignment to a default value and possible other values. 
 
Template specialisation of JPARSER::JParserTemplateElement for type JCounter. 
 
Auxiliary class to handle multiple boolean-like I/O. 
 
static std::istream & read(std::istream &in, T &object)
Read object from input stream. 
 
Interface for status of object. 
 
static std::istream & read(std::istream &in, std::vector< T > &object)
Read std::vector of objects from input stream. 
 
virtual bool getStatus() const override
Get status of this counter. 
 
static int NORMAL_EXIT_CODE
exit code of normal end 
 
const JParserTemplateElement< JType_t, false > & operator=(const JType_t &value)
Assignment to a default value. 
 
bool getShortprint(std::ostream &out)
Get short print option. 
 
static char START_OF_OPTION
Parser options. 
 
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any. 
 
map_type::const_iterator const_iterator
 
const JParserElement & operator=(const not_initialised &value)
Set initialised status to false. 
 
void print(std::ostream &out) const 
Print. 
 
virtual bool gcount() const 
Read counter. 
 
JArgs operator()(const int argc, const char *const argv[])
Parse the program's command line options. 
 
T * clone() const 
Get clone of this object. 
 
std::string pid
process name 
 
virtual bool gcount() const override
Read counter. 
 
Template class holder for I/O of parser element. 
 
JParser & join(const JParser &parser)
Join parser. 
 
virtual void setInitialiationStatus(const bool value) override
Set initialisation status of parameter. 
 
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
 
friend std::ostream & operator<<(std::ostream &out, const JParserElement &value)
Stream output. 
 
JParserTemplateElement(JCounter &object, const std::string &name, const std::string &help="")
Constructor. 
 
bool getStatus() const 
Get status. 
 
const std::string & getHelp() const 
Get help of parameter. 
 
JOption()
Default constructor. 
 
bool less(const JCounter &value) const 
Compare value. 
 
std::istream & read(std::istream &in)
 
friend std::ostream & operator<<(std::ostream &out, const JOption &object)
Write options to output. 
 
virtual bool getInitialisationStatus() const override
Get initialisation status of parameter. 
 
JCSV & operator,(const JContainer_t< JType_t, JCompare_t, JAllocator_t > &values)
Parsing of additional possible values. 
 
JCSV< JType_t > operator=(const JContainer_t< JType_t, JCompare_t, JAllocator_t > &values)
Assignment to a default value and possible other values. 
 
static std::istream & read(std::istream &in, T &object)
Read object from input stream. 
 
friend std::ostream & operator<<(std::ostream &out, const JCounter &object)
Write options to output. 
 
Auxiliary class for handling debug parameter within a class. 
 
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object. 
 
static char HELP_OPTION
help option