1 /*=========================================================================
3 Module: $RCSfile: bbstdStringToVector.cxx,v $
5 Date: $Date: 2008/10/17 08:18:27 $
6 Version: $Revision: 1.5 $
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 * ------------------------------------------------------------------------ */
32 #include "bbstdStringToVector.h"
33 #include "bbstdPackage.h"
38 //====================================================================
39 BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringToVector,
40 bbtk::AtomicBlackBox);
41 //====================================================================
43 //====================================================================
44 // Template specialization of decode_item
45 template <> int8_t StringToVector<int8_t> ::decode_item(const std::string& s)
47 return (int8_t)atoi ( s.c_str() );
50 template <> uint8_t StringToVector<uint8_t> ::decode_item(const std::string& s)
52 return (uint8_t)atoi ( s.c_str() );
55 template <> int16_t StringToVector<int16_t> ::decode_item(const std::string& s)
57 return (int16_t)atoi ( s.c_str() );
60 template <> uint16_t StringToVector<uint16_t> ::decode_item(const std::string& s)
62 return (uint16_t)atoi ( s.c_str() );
65 template <> int32_t StringToVector<int32_t> ::decode_item(const std::string& s)
67 return (int32_t)atoi ( s.c_str() );
70 template <> uint32_t StringToVector<uint32_t> ::decode_item(const std::string& s)
72 return (uint32_t)atoi ( s.c_str() );
75 template <> long StringToVector<long> ::decode_item(const std::string& s)
77 // std::cout << bbGetFullName() << " v="<<s<<std::endl;
78 return (long)atoi ( s.c_str() );
81 template <> float StringToVector<float> ::decode_item(const std::string& s)
83 return (float)atof ( s.c_str() );
86 template <> double StringToVector<double> ::decode_item(const std::string& s)
88 return atof ( s.c_str() );
91 template <> std::string StringToVector<std::string> ::decode_item(const std::string& s)
96 //====================================================================
98 //====================================================================
99 // Add the specialized adaptors to the package
101 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,int8_t);
102 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,uint8_t);
103 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,int16_t);
104 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,uint16_t);
105 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,int32_t);
106 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,uint32_t);
107 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,long);
108 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,float);
109 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,double);
110 typedef std::string string;
111 BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,StringToVector,string);
112 //====================================================================