1 /*=========================================================================
3 Module: $RCSfile: bbstdStringVectorToNumericalVector.cxx,v $
5 Date: $Date: 2011/02/28 14:07:09 $
6 Version: $Revision: 1.1 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
31 #include "bbstdStringVectorToNumericalVector.h"
32 #include "bbstdPackage.h"
36 //====================================================================
37 BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringVectorToNumericalVector,
38 bbtk::AtomicBlackBox);
39 //====================================================================
41 //====================================================================
42 // Template specialization of decode_item
43 template <> int8_t StringVectorToNumericalVector<int8_t> ::decode_item(const std::string& s)
45 return (int8_t)atoi ( s.c_str() );
48 template <> uint8_t StringVectorToNumericalVector<uint8_t> ::decode_item(const std::string& s)
50 return (uint8_t)atoi ( s.c_str() );
53 template <> int16_t StringVectorToNumericalVector<int16_t> ::decode_item(const std::string& s)
55 return (int16_t)atoi ( s.c_str() );
58 template <> uint16_t StringVectorToNumericalVector<uint16_t> ::decode_item(const std::string& s)
60 return (uint16_t)atoi ( s.c_str() );
63 template <> int32_t StringVectorToNumericalVector<int32_t> ::decode_item(const std::string& s)
65 return (int32_t)atoi ( s.c_str() );
68 template <> uint32_t StringVectorToNumericalVector<uint32_t> ::decode_item(const std::string& s)
70 return (uint32_t)atoi ( s.c_str() );
73 template <> long StringVectorToNumericalVector<long> ::decode_item(const std::string& s)
75 return (long)atoi ( s.c_str() );
78 template <> float StringVectorToNumericalVector<float> ::decode_item(const std::string& s)
80 return (float)atof ( s.c_str() );
83 template <> double StringVectorToNumericalVector<double> ::decode_item(const std::string& s)
85 return atof ( s.c_str() );
88 template <> std::string StringVectorToNumericalVector<std::string> ::decode_item(const std::string& s)
93 //====================================================================
95 //====================================================================
96 // Add the specialized adaptors to the package
98 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,int8_t);
99 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,uint8_t);
100 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,int16_t);
101 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,uint16_t);
102 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,int32_t);
103 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,uint32_t);
104 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,long);
105 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,float);
106 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,double);
107 typedef std::string string;
108 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringVectorToNumericalVector,string);
109 //====================================================================