30{
   33 
   35  string    usr;
   36  string    pwd;
   37  string    cookie;
   38  string    query;
   39  JSelector selection;
   40  string    api;
   41  int       width;
   42  string    csv;
   43  string    key;
   45 
   46  try {
   47 
   48    JParser<> zap(
"Auxiliary program to print data from data base.");
 
   49    
   56    zap[
'A'] = 
make_field(api,        
"API, possible values X.Y.Z[/help] ('apiv2') or \"\" ('streamds')") = 
"";
 
   61 
   62    zap(argc, argv);
   63  }
   64  catch(const exception &error) {
   65    FATAL(error.what() << endl);
 
   66  }
   67 
   68  try {
   69 
   70    JDB::reset(usr, pwd, cookie);
   71 
   72    if (api == "") {
   73 
   75      {
   76        for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
   77          cout << (i != 0 ? csv : "") << setw(width) << left << rs.FieldName(i) << flush;
   78        }
   79        cout << endl;
   80      }
   81      while (rs.Next()) {
   82        for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
   83          cout << (i != 0 ? csv : "") << setw(width) << left << rs.GetString(i) << flush;
   84        }
   85        cout << endl;
   86      }
   87      
   88      rs.Close();
   89 
   90    } else {
   91 
   93 
   94      istringstream is(api);
   95 
   96      if (is >> version) {
   97 
  100 
  101        string buffer;
  102 
  103        if      (is.peek() == EOF)
  104          *(JDB::get()->APIv2Select(version.toString().c_str(), query.c_str(), selection)) >> js;
  105        else if (is.get() == '/' && is >> buffer && buffer == help_t)
  106          *(JDB::get()->APIv2Help(version.toString().c_str(), (query != "" ? query.c_str() : "all/h"))) >> js;
  107        else
  108          FATAL(
"Error reading API version <" << api << 
">." << endl);
 
  109          
  110        printer(cout, js, key);
  111 
  112      } else {
  113 
  114        FATAL(
"Error reading API version <" << api << 
">." << endl);
 
  115      }
  116    }
  117  }
  118  catch(const exception& error) {
  119    FATAL(error.what() << endl);
 
  120  }
  121 
  122  return 0;
  123}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Utility class to parse command line options.
 
ResultSet & getResultSet(const std::string &query)
Get result set.
 
std::vector< JServer > getServernames()
Get list of names of available database servers.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Wrapper class for server name.
 
Auxiliary class for version identifier.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
Auxiliary data structure to print (part of) JSon data.