]> Creatis software - clitk.git/blob - common/clitkListOfPair.txx
5e3a84369349f927362cd267566c0473eb87285c
[clitk.git] / common / clitkListOfPair.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKLISTOFPAIR_TXX
19 #define CLITKLISTOFPAIR_TXX
20 /**
21  =================================================
22  * @file   clitkListOfPair.txx
23  * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
24  * @date   27 Feb 2007 09:44:48
25  * 
26  * @brief  
27  * 
28  * 
29  =================================================*/
30
31 //====================================================================
32 template<class MapType>
33 void ReadMap(const std::string & filename, MapType & list, bool inverse) {
34   std::ifstream is;
35   clitk::openFileForReading(is, filename);
36   clitk::skipComment(is);
37   typedef typename MapType::key_type KType;
38   KType v1;
39   typedef typename MapType::mapped_type MType;
40   MType v2;
41   while (is) {
42         is >> v1;
43         is >> v2;
44         if (is) {
45           if (!inverse) list.insert(std::pair<KType, MType>(v1,v2));
46           else list.insert(std::pair<KType, MType>(v2,v1));       
47         }
48         clitk::skipComment(is);
49   }
50   is.close();
51 }
52 //====================================================================
53
54 #endif /* end #define CLITKLISTOFPAIR_TXX */
55