/* */ #ifndef _D_P_STRING_NUM_LOOP_H_ #define _D_P_STRING_NUM_LOOP_H_ #include "PStringDatum.h" #include "PStringSegment.h" #include "NumberDecorator.h" namespace aria2 { class PStringNumLoop : public PStringDatum { private: unsigned int _startValue; unsigned int _endValue; unsigned int _step; NumberDecoratorHandle _numberDecorator; PStringDatumHandle _next; public: PStringNumLoop(unsigned int startValue, unsigned int endValue, unsigned int step, const NumberDecoratorHandle& nd, const PStringDatumHandle& next): _startValue(startValue), _endValue(endValue), _step(step), _numberDecorator(nd), _next(next) {} PStringNumLoop(unsigned int startValue, unsigned int endValue, unsigned int step, const NumberDecoratorHandle& nd): _startValue(startValue), _endValue(endValue), _step(step), _numberDecorator(nd) {} virtual ~PStringNumLoop() {} virtual void accept(PStringVisitor* visitor) { for(unsigned int i = _startValue; i <= _endValue; i += _step) { PStringSegment(_numberDecorator->decorate(i), _next).accept(visitor); } } PStringDatumHandle getNext() const { return _next; } unsigned int getStartValue() const { return _startValue; } unsigned int getEndValue() const { return _endValue; } unsigned int getStep() const { return _step; } }; typedef SharedHandle PStringNumLoopHandle; } // namespace aria2 #endif // _D_P_STRING_NUM_LOOP_H_