| Last change
 on this file since 1018 was             807, checked in by ansari, 26 years ago | 
        
          | 
Amelioration tests - Adaptation modifs TArray<T>,PPersist - Reza 03/04/2000
 | 
        
          | File size:
            2.0 KB | 
      
      
| Line |  | 
|---|
| 1 | #include <stdio.h> | 
|---|
| 2 | #include <stdlib.h> | 
|---|
| 3 | #include <typeinfo> | 
|---|
| 4 | #include <iostream.h> | 
|---|
| 5 | #include <string> | 
|---|
| 6 |  | 
|---|
| 7 | #include "ppersist.h" | 
|---|
| 8 | #include "anydataobj.h" | 
|---|
| 9 | #include "sambainit.h" | 
|---|
| 10 |  | 
|---|
| 11 | #ifdef __MWERKS__ | 
|---|
| 12 | #include <console.h> | 
|---|
| 13 | #endif | 
|---|
| 14 |  | 
|---|
| 15 | int main(int narg, char* arg[]) | 
|---|
| 16 | { | 
|---|
| 17 |  | 
|---|
| 18 | #ifdef __MWERKS__ | 
|---|
| 19 | narg = ccommand(&arg); | 
|---|
| 20 | #endif | 
|---|
| 21 |  | 
|---|
| 22 | SambaInitiator smbinit; | 
|---|
| 23 |  | 
|---|
| 24 | if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) { | 
|---|
| 25 | cerr << " Usage: scanppf filename [s/n/a0/a1/a2/a3] \n" | 
|---|
| 26 | << "   s[=default} : Sequential reading of objects \n" | 
|---|
| 27 | << "   n : Object reading at NameTags \n" | 
|---|
| 28 | << "   a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" << endl; | 
|---|
| 29 | exit(0); | 
|---|
| 30 | } | 
|---|
| 31 |  | 
|---|
| 32 | try { | 
|---|
| 33 | string flnm = arg[1]; | 
|---|
| 34 | bool seq=true; | 
|---|
| 35 | bool ana=false; | 
|---|
| 36 | int analev = 0; | 
|---|
| 37 | string opt = "s"; | 
|---|
| 38 | if (narg > 2) opt = arg[2]; | 
|---|
| 39 |  | 
|---|
| 40 | if (opt == "n")  seq = false; | 
|---|
| 41 | else if (opt[0] == 'a') {  ana = true;  analev = opt[1]-'0'; } | 
|---|
| 42 |  | 
|---|
| 43 | if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl; | 
|---|
| 44 | else { | 
|---|
| 45 | if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl; | 
|---|
| 46 | else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | PPersist* op = NULL; | 
|---|
| 50 | cout << " Opening PPF file " << flnm << endl; | 
|---|
| 51 | PInPersist s(flnm); | 
|---|
| 52 |  | 
|---|
| 53 | if (ana) s.AnalyseTags(analev);   // Analysing all tags in file | 
|---|
| 54 |  | 
|---|
| 55 | else { | 
|---|
| 56 | cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl; | 
|---|
| 57 | int nt = s.NbTags(); | 
|---|
| 58 | cout << " Number of tags in file = " << nt << endl; | 
|---|
| 59 | if ( seq || (nt < 1) ) { | 
|---|
| 60 | while (1) { | 
|---|
| 61 | op = s.ReadObject(); | 
|---|
| 62 | cout << " Object Type " << typeid(*op).name() << endl; | 
|---|
| 63 | if (op) delete op; | 
|---|
| 64 | } | 
|---|
| 65 | } | 
|---|
| 66 | for(int i=0; i<nt; i++) { | 
|---|
| 67 | cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl; | 
|---|
| 68 | s.GotoTagNum(i); | 
|---|
| 69 | op = s.ReadObject(); | 
|---|
| 70 | cout << " Object Type " << typeid(*op).name() << endl; | 
|---|
| 71 | if (op) delete op; | 
|---|
| 72 | } | 
|---|
| 73 | } | 
|---|
| 74 | } | 
|---|
| 75 | catch (PThrowable pex) { | 
|---|
| 76 | cerr << " scanppf/Error - Exception catched " << pex.Msg() << endl; | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | cout << " ----------- End of scanppf ------------- " << endl; | 
|---|
| 80 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.