Changeset 2658 in Sophya


Ignore:
Timestamp:
Apr 5, 2005, 5:38:56 PM (20 years ago)
Author:
ansari
Message:

modification programme scanppf: ajout option -lh -lho pour lister les classes PPersist handler . Reza 5/04/2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/PrgUtil/scanppf.cc

    r2636 r2658  
    5757
    5858if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
    59   cerr << " Usage: scanppf filename [s/n/a0/a1/a2/a3] \n"
    60        << "   s[=default} : Sequential reading of objects \n"
    61        << "   n : Object reading at NameTags \n"
    62        << "   a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" << endl;
    63   exit(0);
     59  cout << " Usage: scanppf [flags] filename \n"
     60       << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho \n"
     61       << "   -s[=default} : Sequential reading of objects \n" 
     62       << "   -n : Object reading at NameTags \n"
     63       << "   -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n"
     64       << "   -lh : List PPersist handler classes \n"
     65       << "   -lho : List PPersist handler and dataobj classes \n" << endl;
     66  return(0);
    6467  }
    6568
    6669try {
    67   string flnm = arg[1];
     70  string flnm;
    6871  bool seq=true;
    6972  bool ana=false;
    7073  int analev = 0;
    7174  string opt = "s";
    72   if (narg > 2) opt = arg[2];
    73  
    74   if (opt == "n")  seq = false;
    75   else if (opt[0] == 'a') {  ana = true;  analev = opt[1]-'0'; }
     75  if ((narg >= 2) && (*arg[1] == '-')) {
     76    opt = arg[1];
     77    if (narg > 2) flnm = arg[2];
     78  }
     79  else flnm = arg[1];
    7680
    77   if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl;
    78   else {
    79     if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
    80     else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
     81  if (opt == "-lh")  {
     82    cout << " --- scanppf : List of registered handler classes --- " << endl;
     83    PIOPersist::ListPPHandlers();
    8184  }
    82    
    83   PPersist* op = NULL;
    84   cout << " Opening PPF file " << flnm << endl;
    85   PInPersist s(flnm);
    86 
    87   if (ana) s.AnalyseTags(analev);   // Analysing all tags in file
    88 
     85  else if (opt == "-lho") {
     86    cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
     87    PIOPersist::ListPPHandlers();
     88    PIOPersist::ListDataObjClasses();
     89  }
    8990  else {
    90     cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
    91     int nt = s.NbNameTags();
    92     cout << " Number of tags in file = " << nt << endl;
    93     if ( seq || (nt < 1) ) {
    94       while (1) {
     91    if (opt == "-n")  seq = false;
     92    else if (opt[1] == 'a') {  ana = true;  analev = opt[1]-'0'; }
     93   
     94    if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl;
     95    else {
     96      if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
     97      else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
     98    }
     99    PPersist* op = NULL;
     100    cout << " Opening PPF file " << flnm << endl;
     101    PInPersist s(flnm);
     102   
     103    if (ana) s.AnalyseTags(analev);   // Analysing all tags in file
     104   
     105    else {
     106      cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
     107      int nt = s.NbNameTags();
     108      cout << " Number of tags in file = " << nt << endl;
     109      if ( seq || (nt < 1) ) {
     110        while (1) {
     111          op = s.ReadObject();
     112          cout << " Object Type " << typeid(*op).name() << endl;
     113          if (op) delete op;
     114        }
     115      }
     116      for(int i=0; i<nt; i++) {
     117        cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
     118        s.GotoNameTagNum(i);
    95119        op = s.ReadObject();
    96120        cout << " Object Type " << typeid(*op).name() << endl;
    97121        if (op) delete op;
    98122      }
    99     }
    100     for(int i=0; i<nt; i++) {
    101       cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
    102       s.GotoNameTagNum(i);
    103       op = s.ReadObject();
    104       cout << " Object Type " << typeid(*op).name() << endl;
    105       if (op) delete op;
    106123    }
    107124  }
Note: See TracChangeset for help on using the changeset viewer.