source: Sophya/trunk/SophyaLib/NTools/datacards.h@ 220

Last change on this file since 220 was 220, checked in by ansari, 26 years ago

Creation module DPC/NTools Reza 09/04/99

File size: 2.2 KB
RevLine 
[220]1// This may look like C code, but it is really -*- C++ -*-
2//
3// $Id: datacards.h,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
4//
5// Datacards, acquisition EROS II
6//
7//
8// Eric Aubourg, Decembre 95
9// Reza Ansari, Aout 96
10//
11// DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
12
13#ifndef DATACARDS_SEEN
14#define DATACARDS_SEEN
15
16#include <string.h>
17#include <string>
18#include <functional>
19#include <list>
20#include <vector>
21#include <string>
22
23#if defined(__KCC__)
24using std::string ;
25#include <functional.h>
26#include <list.h>
27#include <vector.h>
28#endif
29
30#include "peida.h"
31
32typedef int (*ProcCard)(string const& key, string const& toks);
33
34class DataCards EXC_AWARE {
35public:
36 DataCards();
37 DataCards(string const& fn);
38
39 // nom dans variable d'environnement PEIDA_DATACARDS
40 // par defaut, peida.datacards
41 // Si pas chemin complet, on tente dans repertoire
42 // en cours, puis dans PEIDA_WORK
43
44 virtual ~DataCards() {}
45
46 void AddProcF(ProcCard f, string const& mtch="*");
47
48 void Clear();
49 void ReadFile(string const& fn);
50 void AppendCard(string const& line);
51
52 int NbCards();
53 bool HasKey(string const& key);
54 int NbParam(string const& key);
55 string SParam(string const& key, int numero = 0, string def="");
56 long IParam(string const& key, int numero = 0, long def = 0);
57 double DParam(string const& key, int numero = 0, double def = 0);
58
59 friend ostream& operator << (ostream& s, DataCards c);
60
61public:
62 struct Card {
63 string kw;
64 vector<string> tokens;
65 STRUCTCOMPF(Card,kw)
66 };
67 typedef list<Card> CardList;
68 struct CrdPF {
69 ProcCard pf;
70 string patt;
71 STRUCTCOMPF(CrdPF,pf)
72 };
73 typedef list<CrdPF> CrdPFList;
74protected:
75 CardList cards;
76 CrdPFList cpfs;
77
78 void DoReadFile(string const& fn);
79
80 int ApplyPF(CrdPF & cpf, string const& key, string const& toks);
81 int ApplyPFL(string const& key, string const& toks);
82
83 void RemoveCard(string const& key);
84
85 Card* FindKey(string const& key);
86 struct KeyEq : binary_function<Card, string, bool> {
87 bool operator()(const Card& x, const string& y) const { return x.kw == y; }
88 };
89};
90#endif
Note: See TracBrowser for help on using the repository browser.