Changeset 718 in Sophya for trunk/SophyaLib/NTools/dvlist.h


Ignore:
Timestamp:
Feb 6, 2000, 4:05:44 PM (26 years ago)
Author:
ansari
Message:

Ajout commentaire/variable ds DVList - Remplacement float/double par r_4 r_8
Ajout classe XNTuple (importe/adapte depuis PEIDA) - Reza 7 Fev 2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/dvlist.h

    r552 r718  
    2323public:
    2424  union {
    25   int_4 iv;
    26   double dv;
     25  int_8 iv;
     26  r_8 dv;
    2727  char strv[31];
    2828  } mtv;
     
    3232
    3333  inline MuTyV() { typ = 'I'; mtv.iv = 0;  mtv.dv = 0.;  mtv.strv[0] ='\0'; }
    34   inline MuTyV(int_4 i) { typ = 'I'; mtv.iv = i; mtv.dv = 0.;  mtv.strv[0] ='\0'; }
    35   inline MuTyV(float f) { typ = 'D'; mtv.dv = (double)f;  mtv.iv = 0;  mtv.strv[0] ='\0'; }
    36   inline MuTyV(double d) { typ = 'D'; mtv.dv = d; mtv.iv = 0;  mtv.strv[0] ='\0'; }
     34  inline MuTyV(int_4 i) { typ = 'I'; mtv.iv = (int_8)i; mtv.dv = 0.;  mtv.strv[0] ='\0'; }
     35  inline MuTyV(int_8 i) { typ = 'I'; mtv.iv = i; mtv.dv = 0.;  mtv.strv[0] ='\0'; }
     36  inline MuTyV(r_4 f) { typ = 'D'; mtv.dv = (r_8)f;  mtv.iv = 0;  mtv.strv[0] ='\0'; }
     37  inline MuTyV(r_8 d) { typ = 'D'; mtv.dv = d; mtv.iv = 0;  mtv.strv[0] ='\0'; }
    3738  inline MuTyV(char const* s)  { typ = 'S'; strncpy(mtv.strv, s, 31); mtv.strv[30] = '\0'; }
    3839  inline MuTyV(string const& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 31); mtv.strv[30] = '\0'; }
    39   inline int_4  operator= (int_4 v)  { typ = 'I'; mtv.iv = v; return(v); }
    40   inline float  operator= (float v)  { typ = 'D'; mtv.dv = (double)v; return(v); }
    41   inline double operator= (double v) { typ = 'D'; mtv.dv = v; return(v); }
     40  inline int_4  operator= (int_4 v)  { typ = 'I'; mtv.iv = (int_8)v; return(v); }
     41  inline int_8  operator= (int_8 v)  { typ = 'I'; mtv.iv = v; return(v); }
     42  inline r_4  operator= (r_4 v)  { typ = 'D'; mtv.dv = (r_8)v; return(v); }
     43  inline r_8 operator= (r_8 v) { typ = 'D'; mtv.dv = v; return(v); }
    4244  inline char*  operator= (char* s)  { typ = 'S'; strncpy(mtv.strv, s, 31);
    4345                                       mtv.strv[30] = '\0';  return(s); }
     
    4547                                            mtv.strv[30] = '\0'; return(s); }
    4648
    47   inline operator int_4() { if (typ == 'I')  return(mtv.iv);
     49  inline operator int_4() { if (typ == 'I')  return((int_4)mtv.iv);
    4850                            else if (typ == 'D') return((int_4)mtv.dv);
    4951                            else return(atol(mtv.strv)); }
    50   inline operator float() { if (typ == 'I')  return((float)mtv.iv);
    51                             else if (typ == 'D') return((float)mtv.dv);
    52                             else return((float)atof(mtv.strv)); }
    53   inline operator double() { if (typ == 'I')  return((double)mtv.iv);
     52  inline operator int_8() { if (typ == 'I')  return((int_8)mtv.iv);
     53                            else if (typ == 'D') return((int_8)mtv.dv);
     54                            else return(atol(mtv.strv)); }
     55  inline operator r_4() { if (typ == 'I')  return((r_4)mtv.iv);
     56                            else if (typ == 'D') return((r_4)mtv.dv);
     57                            else return((r_4)atof(mtv.strv)); }
     58  inline operator r_8() { if (typ == 'I')  return((r_8)mtv.iv);
    5459                            else if (typ == 'D') return(mtv.dv);
    5560                            else return(atof(mtv.strv)); }
     
    7883  DVList&           Merge(const DVList&);
    7984
    80   int_4             GetI(string const& key, int_4 def=-1);
    81   double            GetD(string const& key, double def=-9.e19);
     85  int_8             GetI(string const& key, int_8 def=-1);
     86  r_8               GetD(string const& key, r_8 def=-9.e19);
    8287  string            GetS(string const& key, char* def="");
     88  string            GetComment(string const& key);
    8389
    84   void              SetI(string const& key, int_4 val);
    85   void              SetD(string const& key, double val);
     90  void              SetI(string const& key, int_8 val);
     91  void              SetD(string const& key, r_8 val);
    8692  void              SetS(string const& key, char const*  val);
    8793  void              SetS(string const& key, string val);
     94  void              SetComment(string const& key, string const& comm);
    8895
    8996  MuTyV&            Get(string const& key);
     
    95102  virtual void      Print(ostream& os)  const;
    96103
    97   typedef map<string, MuTyV, less<string> >  ValList;
     104// Chaque element dans un DVList est constitue desormais d'un MuTyV
     105// et d'une chaine de caracteres (commentaire) regroupe dans la structure
     106// dvlElement. Ces elements sont associes aux noms de variables dans un
     107// map<...> ValList.            Reza 02/2000
     108
     109  struct dvlElement {MuTyV elval; string elcomm; } ;
     110  typedef map<string, dvlElement, less<string> >  ValList;
    98111  inline ValList::const_iterator Begin() { return(mvlist.begin()); }
    99112  inline ValList::const_iterator End() { return(mvlist.end()); }
    100113 
    101 //  int_4             ClassId() const        { return classId; }
    102 //  static PPersist*  Create()               { return new DVList;}
    103 
    104 //  virtual void      WriteSelf(POutPersist&) const;
    105 //  virtual void      ReadSelf(PInPersist&);
    106114
    107115private:
Note: See TracChangeset for help on using the changeset viewer.