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