1 // PercentPrinter.h 2 3 #ifndef ZIP7_INC_PERCENT_PRINTER_H 4 #define ZIP7_INC_PERCENT_PRINTER_H 5 6 #include "../../../Common/StdOutStream.h" 7 8 struct CPercentPrinterState 9 { 10 UInt64 Completed; 11 UInt64 Total; 12 13 UInt64 Files; 14 15 AString Command; 16 UString FileName; 17 18 void ClearCurState(); 19 CPercentPrinterStateCPercentPrinterState20 CPercentPrinterState(): 21 Completed(0), 22 Total((UInt64)(Int64)-1), 23 Files(0) 24 {} 25 }; 26 27 class CPercentPrinter: public CPercentPrinterState 28 { 29 public: 30 CStdOutStream *_so; 31 bool DisablePrint; 32 bool NeedFlush; 33 unsigned MaxLen; 34 35 private: 36 UInt32 _tickStep; 37 DWORD _prevTick; 38 39 AString _s; 40 41 AString _printedString; 42 AString _temp; 43 UString _tempU; 44 45 CPercentPrinterState _printedState; 46 AString _printedPercents; 47 48 void GetPercents(); 49 50 public: 51 52 CPercentPrinter(UInt32 tickStep = 200): DisablePrint(false)53 DisablePrint(false), 54 NeedFlush(true), 55 MaxLen(80 - 1), 56 _tickStep(tickStep), 57 _prevTick(0) 58 {} 59 60 ~CPercentPrinter(); 61 62 void ClosePrint(bool needFlush); 63 void Print(); 64 }; 65 66 #endif 67