1 #ifndef __bbstdVectorToString_INCLUDED_h__
2 #define __bbstdVectorToString_INCLUDED_h__
4 #include "bbtkAtomicBlackBox.h"
8 //=================================================================
9 // BlackBox declaration
11 class VectorToString : public bbtk::AtomicBlackBox
13 BBTK_USER_BLACK_BOX_INTERFACE(VectorToString,bbtk::AtomicBlackBox);
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();
21 //=================================================================
23 //=================================================================
24 // BlackBox description
25 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
26 BBTK_NAME(bbtk::HumanTypeName<std::vector<T> >()+"ToString");
27 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
28 BBTK_DEFAULT_ADAPTOR();
29 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'");
30 typedef std::vector<T> Tvector;
31 BBTK_TEMPLATE_INPUT(VectorToString, In,"Input",Tvector);
32 BBTK_TEMPLATE_INPUT(VectorToString, Separator,"Separator of item in the output string. Default is whitespace.",std::string);
33 BBTK_TEMPLATE_OUTPUT(VectorToString, Out,"Output",std::string);
34 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
35 //=================================================================
37 //=================================================================
39 void VectorToString<T>::DoIt()
42 typename std::vector<T>::const_iterator i;
43 for (i=bbmInputIn.begin();i!=bbmInputIn.end();++i)
45 if (i!=bbmInputIn.begin())
46 out += bbGetInputSeparator();
53 //=================================================================
55 //=================================================================
57 void VectorToString<T>::bbUserConstructor()
59 bbSetInputSeparator(" ");
61 //=================================================================
65 #endif //__bbstdVectorToString_INCLUDED_h__