X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fstd%2Fsrc%2FbbstdStringToVector.h;h=bd5d9f2ce0bcd8f171798874b8e5cf5d8a2df58f;hb=3924782985e3d7c795af6bb46c602157cfad59f0;hp=cd39769bf02bb28ca0165b5b7f1807dccaca84ee;hpb=e27f49d94042bf18dc5067807594325eea8b6d56;p=bbtk.git diff --git a/packages/std/src/bbstdStringToVector.h b/packages/std/src/bbstdStringToVector.h index cd39769..bd5d9f2 100644 --- a/packages/std/src/bbstdStringToVector.h +++ b/packages/std/src/bbstdStringToVector.h @@ -1,74 +1,70 @@ #ifndef __bbstdStringToVector_INCLUDED_h__ #define __bbstdStringToVector_INCLUDED_h__ -#include "bbtkUserBlackBox.h" +#include "bbtkAtomicBlackBox.h" namespace bbstd { + //================================================================= + // BlackBox declaration + template + class StringToVector : public bbtk::AtomicBlackBox + { + BBTK_USER_BLACK_BOX_INTERFACE(StringToVector,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In,std::string); + BBTK_DECLARE_OUTPUT(Out,std::vector); + BBTK_PROCESS(DoIt); + void DoIt(); + T decode_item(const std::string&); + }; + //================================================================= -//================================================================= -// UserBlackBox declaration -template -class StringToVector : public bbtk::UserBlackBox -{ - BBTK_USER_BLACK_BOX_INTERFACE(StringToVector,bbtk::UserBlackBox); - BBTK_DECLARE_INPUT(In,std::string); - BBTK_DECLARE_OUTPUT(Out,std::vector); - BBTK_PROCESS(DoIt); - void DoIt(); - T decode_item(const std::string&); -}; -//================================================================= - - - -//================================================================= -// UserBlackBox description -BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector); -BBTK_NAME("StringTo"+bbtk::TypeName >()); -BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); -BBTK_DEFAULT_ADAPTOR(); -BBTK_DESCRIPTION("Converts the content of the input string to a "+bbtk::TypeName >()); -BBTK_TEMPLATE_INPUT(StringToVector, In,"Input",std::string); -typedef std::vector Tvector; -BBTK_TEMPLATE_OUTPUT(StringToVector, Out,"Output",Tvector); -BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector); -//================================================================= - - - -//================================================================= -template -void StringToVector::DoIt() -{ - // std::cout << "StringToVector<"<()<<">::DoIt()"<decode_item( str.substr(lastPos, pos - lastPos) ) ); - // std::cout << this->bbGetOutputOut().back() << std::endl; - // Skip delimiters. Note the "not_of" - lastPos = str.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = str.find_first_of(delimiters, lastPos); - } - // std::cout << "s=" << this->bbGetOutputOut().size() << std::endl; -} -//================================================================= - - + //================================================================= + // BlackBox description + BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector); + BBTK_NAME("StringTo"+bbtk::HumanTypeName >()); + BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); + BBTK_DEFAULT_ADAPTOR(); + BBTK_DESCRIPTION("Converts the content of the input string to a " + +bbtk::HumanTypeName >() + +" ("+bbtk::TypeName >()+")"); + BBTK_TEMPLATE_INPUT(StringToVector, In,"Input",std::string); + typedef std::vector Tvector; + BBTK_TEMPLATE_OUTPUT(StringToVector, Out,"Output",Tvector); + BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector); + //================================================================= + + //================================================================= + template + void StringToVector::DoIt() + { + // std::cout << "StringToVector<"<()<<">::DoIt()"<decode_item( str.substr(lastPos, pos - lastPos) ) ); + // std::cout << this->bbGetOutputOut().back() << std::endl; + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = str.find_first_of(delimiters, lastPos); + } + // std::cout << "s=" << this->bbGetOutputOut().size() << std::endl; + } + //================================================================= + + } // namespace bbstd #endif //__bbstdStringToVector_INCLUDED_h__ -