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

Last change on this file since 2615 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

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