Changeset 1157 in Sophya


Ignore:
Timestamp:
Aug 29, 2000, 6:11:42 PM (25 years ago)
Author:
ansari
Message:

Declaration sa_size_t ds machdefs.h - Amelioration/correction DVList et MuTyV - Reza 29/8/2000

Location:
trunk/SophyaLib/BaseTools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/dvlist.cc

    r1080 r1157  
    195195/*! Returns the value corresponding to name \b key, converted to integer
    196196    Default value \b def is returned if name \b key not found */
    197 int_8       DVList::GetI(string const& key, int_8 def)
    198 {
    199 ValList::iterator it = mvlist.find(key);
     197int_8       DVList::GetI(string const& key, int_8 def) const
     198{
     199ValList::const_iterator it = mvlist.find(key);
    200200if (it == mvlist.end())  return(def);
    201201return((*it).second.elval.iv);
     
    205205/*! Returns the value corresponding to name \b key, converted to double
    206206    Default value \b def is returned if name \b key not found */
    207 r_8      DVList::GetD(string const& key, r_8 def)
    208 {
    209 ValList::iterator it = mvlist.find(key);
     207r_8      DVList::GetD(string const& key, r_8 def) const
     208{
     209ValList::const_iterator it = mvlist.find(key);
    210210if (it == mvlist.end())  return(def);
    211211return((*it).second.elval.dv);
     
    215215/*! Returns the value corresponding to name \b key, converted to complex
    216216    Default value \b def is returned if name \b key not found */
    217 complex<r_8>       DVList::GetZ(string const& key, complex<r_8> def)
    218 {
    219 ValList::iterator it = mvlist.find(key);
     217complex<r_8>       DVList::GetZ(string const& key, complex<r_8> def) const
     218{
     219ValList::const_iterator it = mvlist.find(key);
    220220if (it == mvlist.end())  return(def);
    221221return((*it).second.elval.dv);
     
    225225/*! Returns the value corresponding to name \b key, converted to string
    226226    Default value \b def is returned if name \b key not found */
    227 string      DVList::GetS(string const& key, char* def)
    228 {
    229 ValList::iterator it = mvlist.find(key);
     227string      DVList::GetS(string const& key, char* def) const
     228{
     229ValList::const_iterator it = mvlist.find(key);
    230230if (it == mvlist.end())  return(def);
    231231return(*((*it).second.elval.strv));
     
    234234/* --Methode-- */
    235235/*! Returns the comment associated with name \b key */
    236 string      DVList::GetComment(string const& key)
    237 {
    238 ValList::iterator it = mvlist.find(key);
     236string      DVList::GetComment(string const& key) const
     237{
     238ValList::const_iterator it = mvlist.find(key);
    239239if (it == mvlist.end())  return("");
    240240return((*it).second.elcomm);
     
    259259
    260260/* --Methode-- */
     261/*! Removes the definition and value associated with the name \b key.
     262  Return \c true if the \b key is found in the list, \c false otherwise. */
     263bool        DVList::DeleteKey(string const& key)
     264{
     265ValList::iterator it = mvlist.find(key);
     266if (it == mvlist.end())  return(false);
     267mvlist.erase(it);
     268return(true);
     269}
     270
     271/* --Methode-- */
     272/*!  Return \c true if the \b key is found in the list, \c false otherwise. */
     273bool        DVList::HasKey(string const& key) const
     274{
     275ValList::const_iterator it = mvlist.find(key);
     276if (it == mvlist.end())  return(false);
     277return(true);
     278}
     279
     280
     281/* --Methode-- */
    261282/*! Appends or sets the integer value \b val in the list with name \b key */
    262283void        DVList::SetI(string const& key, int_8 val)
     
    316337//      Renvoie une référence sur le champ commentaire de l'objet.
    317338//--
     339
     340/* --Methode-- */
     341/*!  Return the MuTyV value associated with name \b key .
     342     Integer 0 is returned if \b key is not present in the list   */
     343MuTyV       DVList::Get(string const& key) const
     344{
     345ValList::const_iterator it = mvlist.find(key);
     346if (it == mvlist.end()) return(MuTyV(0));
     347else return((*it).second.elval);
     348}
    318349
    319350/* --Methode-- */
  • trunk/SophyaLib/BaseTools/dvlist.h

    r1080 r1157  
    3434  DVList&           Merge(const DVList&);
    3535
    36   int_8             GetI(string const& key, int_8 def=-1);
    37   r_8               GetD(string const& key, r_8 def=-9.e19);
    38   complex<r_8>      GetZ(string const& key, complex<r_8> def=-9.e19);
    39   string            GetS(string const& key, char* def="");
    40   string            GetComment(string const& key);
     36  int_8             GetI(string const& key, int_8 def=-1) const;
     37  r_8               GetD(string const& key, r_8 def=-9.e19) const;
     38  complex<r_8>      GetZ(string const& key, complex<r_8> def=-9.e19) const;
     39  string            GetS(string const& key, char* def="") const;
     40  string            GetComment(string const& key) const;
     41
     42  bool              DeleteKey(string const& key);
     43  bool              HasKey(string const& key) const;
    4144
    4245  void              SetI(string const& key, int_8 val);
     
    4750  void              SetComment(string const& key, string const& comm);
    4851
     52  MuTyV             Get(string const& key) const ;
    4953  MuTyV&            Get(string const& key);
     54/*! Returns the value associated with the name \b key */
     55  inline MuTyV      operator()  (string const& key) const { return Get(key); }
     56/*! Returns the value associated with the name \b key */
     57  inline MuTyV      operator[]  (string const& key) const { return Get(key); }
     58/*! Returns the global comment string associated with the object */
     59  inline string     Comment() const { return(comment); }
    5060/*! Returns the value associated with the name \b key */
    5161  inline MuTyV&     operator()  (string const& key)  { return Get(key); }
  • trunk/SophyaLib/BaseTools/machdefs.h

    r1084 r1157  
    356356#endif
    357357
     358/* ---- La taille et les index des tableaux ---- */
     359typedef int_4 sa_size_t ;
     360
     361
    358362/* Compatibilite, avant de migrer tout le code en "PLANCK" */
    359363
  • trunk/SophyaLib/BaseTools/mutyv.cc

    r1080 r1157  
    3232
    3333
     34static void mutyv_decodestr(const char * si, double& r, double& im);
     35
    3436/* --Methode-- */
    3537MuTyV::MuTyV(MuTyV const & a)
     
    5153  typ = 'S';
    5254  strv = new string(s);
    53   dv = dv_im = 0.;
    54   sscanf(s, "%lg %lg", &dv, &dv_im);
     55  mutyv_decodestr(s, dv, dv_im);
    5556  iv = (int_8)dv;
    5657}
     
    6162  typ = 'S';
    6263  strv = new string(s);
    63   dv = dv_im = 0.;
    64   sscanf(s.c_str(), "%lg %lg", &dv, &dv_im);
     64  mutyv_decodestr(s.c_str(), dv, dv_im);
    6565  iv = (int_8)dv;
    6666}
     
    8080  typ = 'S';
    8181  strv = new string(s);
    82   dv = dv_im = 0.;
    83   sscanf(s, "%lg %lg", &dv, &dv_im);
     82  mutyv_decodestr(s, dv, dv_im);
    8483  iv = (int_8)dv;
    8584  return(s);
     
    9190  typ = 'S';
    9291  strv = new string(s);
    93   dv = dv_im = 0.;
    94   sscanf(s.c_str(), "%lg %lg", &dv, &dv_im);
     92  mutyv_decodestr(s.c_str(), dv, dv_im);
    9593  iv = (int_8)dv;
    9694  return(s);
     
    105103    if (typ == 'I')  sprintf(buff,"%ld", (long)iv);
    106104    else if (typ == 'D') sprintf(buff,"%.20g", dv);
    107     else if (typ == 'Z') sprintf(buff,"%.20g %.20g i", dv, dv_im);
     105    else if (typ == 'Z') sprintf(buff,"(%.20g , %.20g)", dv, dv_im);
    108106    else buff[0] = '\0';
    109107    return(string(buff));
     
    112110
    113111
     112static void mutyv_decodestr(const char * si, double& r, double& im)
     113  // decodage d'une chaine contenant une ou deux valeurs
     114{
     115  r = im = 0.;
     116  string s = si;
     117  size_t l = s.length();
     118  size_t p = s.find_first_not_of(" ()\t",0);
     119  if (p >= l) return;
     120  size_t q = s.find_first_of(" ()\t",p+1);
     121 
     122 
     123  if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') )
     124    return;
     125  r = atof(s.substr(p,q-p).c_str());
     126
     127  p = s.find_first_not_of(" ()\t",q+1);
     128  if (p >= l) return;
     129  q = s.find_first_of(" ()\t",p+1);
     130  if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') )
     131    return;
     132  im = atof(s.substr(p,q-p).c_str());
     133}
    114134
    115135
    116136
     137
  • trunk/SophyaLib/BaseTools/sophyainit.cc

    r913 r1157  
    144144return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
    145145}
     146
     147double SOPHYA::SophyaVersion()
     148{
     149return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
     150}
    146151 
    147152// On met un objet initiator en statique, pour les loaders qui savent
  • trunk/SophyaLib/BaseTools/sversion.h

    r1130 r1157  
    33
    44#define SOPHYA_VERSION   0.9
    5 #define SOPHYA_REVISION  85
    6 #define SOPHYA_TAG       "V_Jul2000"
     5#define SOPHYA_REVISION  90
     6#define SOPHYA_TAG       "V_Aou2000"
    77
    88#endif
Note: See TracChangeset for help on using the changeset viewer.