source: Sophya/trunk/SophyaProg/PrgUtil/scanppf.cc@ 2586

Last change on this file since 2586 was 2467, checked in by ansari, 22 years ago

Adaptation au changement interface PInPersist - Reza 27/11/2003

File size: 3.0 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <typeinfo>
4#include <iostream>
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
16/*!
17 \defgroup PrgUtil PrgUtil module
18 This module contains simple programs to perform various utility tasks:
19 <UL>
20 <LI> scanppf : Check and scan PPF files (scanppf.cc)
21 <LI> scanfits : Check and scan FITS files (scanfits.cc)
22 <LI> runcxx : Compile and run simple C++ code using SOPHYA (runcxx.cc)
23 <LI> prjsmap : Molleweide and sinus projection of sky maps (prjsmap.cc)
24 <LI> map2cl : Computes power spectra (C(l)) on spherical maps (map2cl.cc)
25 <LI> cl2map : generates spherical maps from power spectra (C(l)) (cl2map.cc)
26 </UL>
27*/
28
29/*!
30 \ingroup PrgUtil
31 \file scanppf.cc
32 \brief \b scanppf: Check and scan PPF files
33
34 \verbatim
35
36 csh> scanppf -h
37 SOPHYA Version 1.1 Revision 0 (V_Fev2001) -- Mar 9 2001 15:45:31 cxx
38 Usage: scanppf filename [s/n/a0/a1/a2/a3]
39 s[=default} : Sequential reading of objects
40 n : Object reading at NameTags
41 a0...a3 : Tag List with PInPersist.AnalyseTags(0...3)
42
43 \endverbatim
44*/
45
46int main(int narg, char* arg[])
47{
48
49#ifdef __MWERKS__
50narg = ccommand(&arg);
51#endif
52
53SambaInitiator smbinit;
54
55if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
56 cerr << " Usage: scanppf filename [s/n/a0/a1/a2/a3] \n"
57 << " s[=default} : Sequential reading of objects \n"
58 << " n : Object reading at NameTags \n"
59 << " a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" << endl;
60 exit(0);
61 }
62
63try {
64 string flnm = arg[1];
65 bool seq=true;
66 bool ana=false;
67 int analev = 0;
68 string opt = "s";
69 if (narg > 2) opt = arg[2];
70
71 if (opt == "n") seq = false;
72 else if (opt[0] == 'a') { ana = true; analev = opt[1]-'0'; }
73
74 if (ana) cout << " Analyse PInPersist( " << flnm << ") Level=" << analev << endl;
75 else {
76 if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
77 else cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
78 }
79
80 PPersist* op = NULL;
81 cout << " Opening PPF file " << flnm << endl;
82 PInPersist s(flnm);
83
84 if (ana) s.AnalyseTags(analev); // Analysing all tags in file
85
86 else {
87 cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
88 int nt = s.NbNameTags();
89 cout << " Number of tags in file = " << nt << endl;
90 if ( seq || (nt < 1) ) {
91 while (1) {
92 op = s.ReadObject();
93 cout << " Object Type " << typeid(*op).name() << endl;
94 if (op) delete op;
95 }
96 }
97 for(int i=0; i<nt; i++) {
98 cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
99 s.GotoNameTagNum(i);
100 op = s.ReadObject();
101 cout << " Object Type " << typeid(*op).name() << endl;
102 if (op) delete op;
103 }
104 }
105}
106catch (PThrowable & pex) {
107 cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
108 << " - Msg= " << pex.Msg() << endl;
109}
110
111cout << " ----------- End of scanppf ------------- " << endl;
112}
Note: See TracBrowser for help on using the repository browser.