diff --git a/uppsrc/Core/Parser.h b/uppsrc/Core/Parser.h index db999fe4c..9fa5ea3f3 100644 --- a/uppsrc/Core/Parser.h +++ b/uppsrc/Core/Parser.h @@ -47,6 +47,7 @@ public: String ReadIdt() throw(Error); bool IsInt(); int ReadInt() throw(Error); + int ReadInt(int min, int max) throw(Error); bool IsNumber() { return IsDigit(*term); } bool IsNumber(int base); uint32 ReadNumber(int base = 10) throw(Error); diff --git a/uppsrc/Core/parser.cpp b/uppsrc/Core/parser.cpp index a3b703666..c92a2f686 100644 --- a/uppsrc/Core/parser.cpp +++ b/uppsrc/Core/parser.cpp @@ -149,6 +149,14 @@ int CParser::ReadInt() throw(Error) { return sign * n; } +int CParser::ReadInt(int min, int max) throw(Error) +{ + int n = ReadInt(); + if(n < min || n > max) + ThrowError("number is out of range"); + return n; +} + bool CParser::IsNumber(int base) { if(IsDigit(*term)) diff --git a/uppsrc/Core/src.tpp/CParser$en-us.tpp b/uppsrc/Core/src.tpp/CParser$en-us.tpp index b0c7a4284..78540c402 100644 --- a/uppsrc/Core/src.tpp/CParser$en-us.tpp +++ b/uppsrc/Core/src.tpp/CParser$en-us.tpp @@ -199,11 +199,17 @@ spaces and digit.&] [s5;:CParser`:`:ReadInt`(`)throw`(CParser`:`:Error`): [@(0.0.255) int]_[* ReadInt]()_[@(0.0.255) t hrow](Error)&] [s2;%% Reads the integer from the current position. If [* IsInt ]is -false, throws an [^topic`:`/`/Core`/src`/CParser`$en`-us`#CParser`:`:Error`:`:struct^ C -Parser`::Error].&] +false, throws an &] [s7;%% [*/ Return value]-|Integer.&] [s3; &] [s4; &] +[s5;:CParser`:`:ReadInt`(int`,int`)throw`(CParser`:`:Error`): [@(0.0.255) int]_[* ReadInt +]([@(0.0.255) int]_[*@3 min], [@(0.0.255) int]_[*@3 max])_[@(0.0.255) throw](Error)&] +[s2;%% Performs ReadInt and then checks the result to be in [%-*@3 min] +<`= result <`= [%-*@3 max]. If not, throws a [^topic`:`/`/Core`/src`/CParser`$en`-us`#CParser`:`:Error`:`:struct^ C +Parser`::Error], otherwise returns it.&] +[s3;%% &] +[s4; &] [s5;:CParser`:`:IsNumber`(`): [@(0.0.255) bool]_[* IsNumber]()&] [s2;%% Tests for sign`-less number at current position `- there must be digit at current position.&] diff --git a/uppsrc/CtrlLib/Progress.h b/uppsrc/CtrlLib/Progress.h index 2729fd66b..039fb30da 100644 --- a/uppsrc/CtrlLib/Progress.h +++ b/uppsrc/CtrlLib/Progress.h @@ -28,6 +28,9 @@ public: int operator++(int) { int i = actual; Set(actual + 1); return i; } int operator+=(int i) { Set(actual + i); return actual; } + int Get() const { return actual; } + int GetTotal() const { return total; } + operator int() { return actual; } static const Style& StyleDefault(); diff --git a/uppsrc/CtrlLib/src.tpp/ProgressInd$en-us.tpp b/uppsrc/CtrlLib/src.tpp/ProgressInd$en-us.tpp index 8d58ae61b..6fb3c2e08 100644 --- a/uppsrc/CtrlLib/src.tpp/ProgressInd$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/ProgressInd$en-us.tpp @@ -68,6 +68,15 @@ nt]_[*@3 i])&] [s2; Adds [%-*@3 i] steps to actual position.&] [s3; &] [s4;%- &] +[s5;:ProgressIndicator`:`:Get`(`)const:%- [@(0.0.255) int]_[* Get]()_[@(0.0.255) const]&] +[s2; Returns the current actual position. &] +[s3;%- &] +[s4;%- &] +[s5;:ProgressIndicator`:`:GetTotal`(`)const:%- [@(0.0.255) int]_[* GetTotal]()_[@(0.0.255) c +onst]&] +[s2; Returns the total number of steps (set by SetTotal).&] +[s3;%- &] +[s4;%- &] [s5;:ProgressIndicator`:`:operator int`(`):%- [* operator_int]()&] [s2; Returns the current actual position. &] [s3; &]