/* */ #ifndef _D_FIXED_WIDTH_NUMBER_DECORATOR_H_ #define _D_FIXED_WIDTH_NUMBER_DECORATOR_H_ #include "NumberDecorator.h" #include "Util.h" namespace aria2 { class FixedWidthNumberDecorator : public NumberDecorator { private: int32_t _width; public: FixedWidthNumberDecorator(int32_t width):_width(width) {} virtual ~FixedWidthNumberDecorator() {} virtual std::string decorate(int32_t number) { std::string s = Util::itos(number); while(s.size() < (size_t)_width) { s.insert(0, "0"); } return s; } }; } // namespace aria2 #endif // _D_FIXED_WIDTH_NUMBER_DECORATOR_H_