Changeset 895 in Sophya for trunk/SophyaLib/BaseTools/dvlist.cc
- Timestamp:
- Apr 12, 2000, 7:49:54 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/dvlist.cc
r827 r895 12 12 //++ 13 13 // Class DVList 14 // Lib Outils++14 // Lib SysTools 15 15 // include dvlist.h 16 16 // … … 42 42 static MuTyV ddvdum(-9.e19); 43 43 44 /*! 45 \class SOPHYA::DVList 46 This class can be used to construct list of values associated with names. 47 Variables names should not contain space characters and is limited to 64 48 characters. The DVList class uses \b SOPHYA::MuTyV objects to hold values 49 of type string, integer (\b int_8) or float (\b r_8). A comment string 50 can be associated with each variable name. A global comment string 51 can be attached to the DVList object. DVList objects can conveniently be 52 used to represent FITS headers. The class \b SOPHYA::ObjFileIO<DVList> 53 handles serialisation for DVList. (See SOPHYA::PPersist ). 54 An 55 \code 56 // ------- Using MuTyV objects ------- 57 MuTyV mvu; // MuTyV variable declaration 58 mvu = 60; // mvu contains the integer value 60 59 mvu = 66.6; // and now the double value 66.6 60 string ds = mvu; // ds contains the string "66.6" 61 MuTyV mvi(14); // New MuTyV variable containing integer value 14 62 r_4 x = mvi; // x has the value 14.0 63 MuTyV mvs("Bonjour !"); // mvs contains the string "Bonjour !" 64 string s = mvs; // s vaut "Bonjour, Ca va ?" 65 // ------- Using DVList objects ------ 66 DVList dvl; 67 dvl("toto") = 14; // Integer type value (=14) named toto 68 dvl("titi") = 25.5; // float type value (=25.5) named titi 69 dvl("tata") = "Bonjour !"; // string type value (="Bonjour !") named tata 70 // Upper and lower case letters are distinguished 71 dvl("hello") = 88; 72 dvl("Hello") = 77.77; 73 dvl.Comment() = "DVList test object, with values named hello, Hello "; 74 // Saving the dvl object into a PPF file 75 POutStream os("dvl.ppf"); 76 os << dvl; 77 // later on ... 78 DVList dvlr; 79 PInStream is("dvl.ppf"); 80 is << dvlr; 81 int k = dvlr["toto"] ; // k = 14 82 r_8 b = dvlr["titi"] ; // b = 25.5 83 string s = dvlr["tata"] ; // s = "Bonjour !" 84 int m = dvlr["hello"] ; // m = 88 85 86 \endcode 87 */ 44 88 45 89 //++ … … 58 102 59 103 /* --Methode-- */ 104 /*! Default constructor */ 60 105 DVList::DVList() 61 106 { … … 64 109 65 110 /* --Methode-- */ 111 /*! copy constructor */ 66 112 DVList::DVList(const DVList& dvl) 67 113 { … … 70 116 71 117 /* --Methode-- */ 118 /*! Copy constructor - Object initialized using the PPF file \b flnm */ 72 119 DVList::DVList(char *flnm) 73 120 { … … 97 144 98 145 /* --Methode-- */ 146 /*! Copy operator - Replaces the variables list with the list from \b dvl */ 99 147 DVList& DVList::operator= (const DVList& dvl) 100 148 { … … 105 153 106 154 /* --Methode-- */ 155 /*! Resets the object and clears the variable list and global comment */ 107 156 void DVList::Clear() 108 157 { … … 112 161 113 162 /* --Methode-- */ 163 /*! Appends the values from the object \b dvl to the objects list */ 114 164 DVList& DVList::Merge(const DVList& dvl) 115 165 { … … 149 199 150 200 /* --Methode-- */ 201 /*! Returns the value corresponding to name \b key, converted to integer 202 Default value \b def is returned if name \b key not found */ 151 203 int_8 DVList::GetI(string const& key, int_8 def) 152 204 { … … 158 210 159 211 /* --Methode-- */ 212 /*! Returns the value corresponding to name \b key, converted to double 213 Default value \b def is returned if name \b key not found */ 160 214 r_8 DVList::GetD(string const& key, r_8 def) 161 215 { … … 167 221 168 222 /* --Methode-- */ 223 /*! Returns the value corresponding to name \b key, converted to string 224 Default value \b def is returned if name \b key not found */ 169 225 string DVList::GetS(string const& key, char* def) 170 226 { … … 176 232 177 233 /* --Methode-- */ 234 /*! Returns the comment associated with name \b key */ 178 235 string DVList::GetComment(string const& key) 179 236 { … … 200 257 201 258 /* --Methode-- */ 259 /*! Appends or sets the integer value \b val in the list with name \b key */ 202 260 void DVList::SetI(string const& key, int_8 val) 203 261 { … … 207 265 /* --Methode-- */ 208 266 void DVList::SetD(string const& key, r_8 val) 267 /*! Appends or sets the double value \b val in the list with name \b key */ 209 268 { 210 269 Get(key) = (r_8)val; … … 212 271 213 272 /* --Methode-- */ 273 /*! Appends or sets the string value \b val in the list with name \b key */ 214 274 void DVList::SetS(string const& key, char const* val) 215 275 { … … 219 279 220 280 /* --Methode-- */ 281 /*! Appends or sets the string value \b val in the list with name \b key */ 221 282 void DVList::SetS(string const& key, string val) 222 283 { … … 226 287 227 288 /* --Methode-- */ 289 /*! Assigns the comment \b comm with the name \b key . 290 Does nothing if the entry with name is not present in the list */ 228 291 void DVList::SetComment(string const& key, string const& comm) 229 292 { … … 246 309 247 310 /* --Methode-- */ 311 /*! Return the MuTyV value associated with name \b key . 312 Adds an entry of type integer in the list if \b key is not present in the list */ 248 313 MuTyV& DVList::Get(string const& key) 249 314 { … … 272 337 //-- 273 338 274 275 /* --Methode-- */ 339 /* --Methode-- */ 340 /*! Prints a brief description of object on on the output stream \b os */ 341 void DVList::Show(ostream& os) const 342 { 343 os << "DVList::Show() - NVar= " << (int)mvlist.size() << "\n"; 344 os << comment << endl; 345 } 346 347 /* --Methode-- */ 348 /*! Prints the list of variables on the output stream \b os */ 276 349 void DVList::Print(ostream& os) const 277 350 {
Note:
See TracChangeset
for help on using the changeset viewer.