]> Creatis software - clitk.git/blob - common/clitkListOfPair.txx
b1b19dd18d862a3fac5bd2dbb46016ca44c37e97
[clitk.git] / common / clitkListOfPair.txx
1 #ifndef CLITKLISTOFPAIR_TXX
2 #define CLITKLISTOFPAIR_TXX
3 /**
4  =================================================
5  * @file   clitkListOfPair.txx
6  * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
7  * @date   27 Feb 2007 09:44:48
8  * 
9  * @brief  
10  * 
11  * 
12  =================================================*/
13
14 //====================================================================
15 template<class MapType>
16 void ReadMap(const std::string & filename, MapType & list, bool inverse) {
17   std::ifstream is;
18   clitk::openFileForReading(is, filename);
19   clitk::skipComment(is);
20   typedef typename MapType::key_type KType;
21   KType v1;
22   typedef typename MapType::mapped_type MType;
23   MType v2;
24   while (is) {
25         is >> v1;
26         is >> v2;
27         if (is) {
28           if (!inverse) list.insert(std::pair<KType, MType>(v1,v2));
29           else list.insert(std::pair<KType, MType>(v2,v1));       
30         }
31         clitk::skipComment(is);
32   }
33   is.close();
34 }
35 //====================================================================
36
37 #endif /* end #define CLITKLISTOFPAIR_TXX */
38