fp@1142: /***************************************************************************** fp@1142: * fp@1142: * $Id$ fp@1142: * fp@1142: ****************************************************************************/ fp@1142: fp@1142: #include "Command.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: Command::Command(const string &name, const string &briefDesc): fp@1142: name(name), fp@1142: briefDesc(briefDesc), fp@1142: verbosity(Normal) fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: Command::~Command() fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: void Command::setVerbosity(Verbosity v) fp@1142: { fp@1142: verbosity = v; fp@1142: }; fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: bool Command::matchesSubstr(const string &cmd) const fp@1142: { fp@1142: return name.substr(0, cmd.length()) == cmd; fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: bool Command::matchesAbbrev(const string &abb) const fp@1142: { fp@1142: unsigned int i; fp@1142: size_t pos = 0; fp@1142: fp@1142: for (i = 0; i < abb.length(); i++) { fp@1142: pos = name.find(abb[i], pos); fp@1142: if (pos == string::npos) fp@1142: return false; fp@1142: } fp@1142: fp@1142: return true; fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1144: string Command::numericInfo() fp@1144: { fp@1144: stringstream str; fp@1144: fp@1144: str << "Numerical values can be specified either with decimal (no" << endl fp@1144: << "prefix), octal (prefix '0') or hexadecimal (prefix '0x') base." fp@1144: << endl; fp@1144: fp@1144: return str.str(); fp@1144: } fp@1144: fp@1144: /*****************************************************************************/ fp@1144: fp@1142: void Command::throwInvalidUsageException(const stringstream &s) fp@1142: { fp@1142: throw InvalidUsageException(s); fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: void Command::throwCommandException(const stringstream &s) fp@1142: { fp@1142: throw CommandException(s); fp@1142: } fp@1142: fp@1142: /****************************************************************************/