home *** CD-ROM | disk | FTP | other *** search
- #include "CmdLine.h"
-
- #include <RJS/Convert.h>
-
- void RJS_CmdOpt_int_range::reset()
- {
- lval=0;
- hval=0;
- l_present=RJS_CmdOpt::NotPresent;
- h_present=RJS_CmdOpt::NotPresent;
- RJS_CmdOpt::reset();
- }
-
- RJS_CmdOpt_int_range::RJS_CmdOpt_int_range(const char *k, RJS_CmdOpt::CmdOptFlags f)
- : RJS_CmdOpt(k,f|Value)
- {
- lval=0;
- hval=0;
- l_present=RJS_CmdOpt::NotPresent;
- h_present=RJS_CmdOpt::NotPresent;
- }
-
- RJS_CmdOpt_int_range::RJS_CmdOpt_int_range(const char *k, const RJS_String &df,
- RJS_CmdOpt::CmdOptFlags f) : RJS_CmdOpt(k,df,f)
- {
- lval=0;
- hval=0;
- l_present=RJS_CmdOpt::NotPresent;
- h_present=RJS_CmdOpt::NotPresent;
- }
-
- int RJS_CmdOpt_int_range::set_value()
- {
- RJS_String low,high;
- l_present=RJS_CmdOpt::NotPresent;
- h_present=RJS_CmdOpt::NotPresent;
-
- if (RJS_CmdOpt::val.contains(':')) {
- low=RJS_CmdOpt::val.before(':');
- high=RJS_CmdOpt::val.after(':');
- } else {
- low=RJS_CmdOpt::val;
- high="";
- }
-
- if (low.length()) {
- lval=RJS_Convert::toInt(low);
- if (!RJS_Convert::ok()) return 0;
- l_present=RJS_CmdOpt::Present;
- }
-
- if (high.length()) {
- hval=RJS_Convert::toInt(high);
- if (!RJS_Convert::ok()) return 0;
- h_present=RJS_CmdOpt::Present;
- }
- return 1;
- }
-
- const char *RJS_CmdOpt_int_range::value_type()
- {
- return "integer range";
- }
-
-
- void RJS_CmdOpt_int_range::dump()
- {
- RJS_CmdOpt::dump();
- cout << "int_range: low range ";
- if (low_is_present()) cout << low_value(); else cout << "?";
- cout << " high range ";
- if (high_is_present()) cout << high_value(); else cout << "?";
- cout << endl;
- }
-