1 #ifndef __bbstdVectorToString_INCLUDED_h__
2 #define __bbstdVectorToString_INCLUDED_h__
4 #include "bbtkUserBlackBox.h"
9 //=================================================================
10 // UserBlackBox declaration
12 class VectorToString : public bbtk::UserBlackBox
14 BBTK_USER_BLACK_BOX_INTERFACE(VectorToString,bbtk::UserBlackBox);
15 BBTK_DECLARE_INPUT(In,std::vector<T>);
16 BBTK_DECLARE_INPUT(Separator,std::string);
17 BBTK_DECLARE_OUTPUT(Out,std::string);
20 virtual void bbUserConstructor();
22 //=================================================================
26 //=================================================================
27 // UserBlackBox description
28 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
29 BBTK_NAME(bbtk::TypeName<std::vector<T> >()+"ToString");
30 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
31 BBTK_DEFAULT_ADAPTOR();
32 BBTK_DESCRIPTION("Converts the content of the input vector ("+bbtk::TypeName<std::vector<T> >()+") to a string in which each item is separated by the value of the input 'Separator'");
33 typedef std::vector<T> Tvector;
34 BBTK_TEMPLATE_INPUT(VectorToString, In,"Input",Tvector);
35 BBTK_TEMPLATE_INPUT(VectorToString, Separator,"Separator of item in the output string. Default is whitespace.",std::string);
36 BBTK_TEMPLATE_OUTPUT(VectorToString, Out,"Output",std::string);
37 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
38 //=================================================================
42 //=================================================================
44 void VectorToString<T>::DoIt()
47 typename std::vector<T>::const_iterator i;
48 for (i=bbmInputIn.begin();i!=bbmInputIn.end();++i)
50 if (i!=bbmInputIn.begin()) out += bbGetInputSeparator();
57 //=================================================================
59 //=================================================================
61 void VectorToString<T>::bbUserConstructor()
63 bbSetInputSeparator(" ");
65 //=================================================================
69 #endif //__bbstdVectorToString_INCLUDED_h__