]> Creatis software - clitk.git/blob - common/clitkListOfPair.txx
Debug RTStruct conversion with empty struc
[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://www.centreleonberard.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 {
35   std::ifstream is;
36   clitk::openFileForReading(is, filename);
37   clitk::skipComment(is);
38   typedef typename MapType::key_type KType;
39   KType v1;
40   typedef typename MapType::mapped_type MType;
41   MType v2;
42   while (is) {
43     is >> v1;
44     is >> v2;
45     if (is) {
46       if (!inverse) list.insert(std::pair<KType, MType>(v1,v2));
47       else list.insert(std::pair<KType, MType>(v2,v1));
48     }
49     clitk::skipComment(is);
50   }
51   is.close();
52 }
53 //====================================================================
54
55 #endif /* end #define CLITKLISTOFPAIR_TXX */
56