1 #ifndef __bbstdVectorToString_INCLUDED_h__
2 #define __bbstdVectorToString_INCLUDED_h__
4 #include "bbtkUserBlackBox.h"
8 //=================================================================
9 // UserBlackBox declaration
11 class VectorToString : public bbtk::UserBlackBox
13 BBTK_USER_BLACK_BOX_INTERFACE(VectorToString,bbtk::UserBlackBox);
14 BBTK_DECLARE_INPUT(In,std::vector<T>);
15 BBTK_DECLARE_INPUT(Separator,std::string);
16 BBTK_DECLARE_OUTPUT(Out,std::string);
19 virtual void bbUserConstructor();
22 //=================================================================
24 // UserBlackBox description
25 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
26 BBTK_NAME(bbtk::TypeName<std::vector<T> >()+"ToString");
27 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
28 BBTK_CATEGORY("adaptor");
29 BBTK_DEFAULT_ADAPTOR();
30 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'");
31 typedef std::vector<T> Tvector;
32 BBTK_TEMPLATE_INPUT(VectorToString, In,"Input",Tvector);
33 BBTK_TEMPLATE_INPUT(VectorToString, Separator,"Separator of item in the output string. Default is whitespace.",std::string);
34 BBTK_TEMPLATE_OUTPUT(VectorToString, Out,"Output",std::string);
35 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
37 //=================================================================
40 void VectorToString<T>::DoIt()
43 typename std::vector<T>::const_iterator i;
44 for (i=bbmInputIn.begin();i!=bbmInputIn.end();++i)
46 if (i!=bbmInputIn.begin())
47 out += bbGetInputSeparator();
55 //=================================================================
58 void VectorToString<T>::bbUserConstructor()
60 bbSetInputSeparator(" ");
62 //=================================================================
66 #endif //__bbstdVectorToString_INCLUDED_h__