tool/Command.cpp
changeset 1142 59be91dfcbe1
child 1144 7dbfdd61812c
equal deleted inserted replaced
1141:7ffbca63fc72 1142:59be91dfcbe1
       
     1 /*****************************************************************************
       
     2  *
       
     3  * $Id$
       
     4  *
       
     5  ****************************************************************************/
       
     6 
       
     7 #include "Command.h"
       
     8 
       
     9 /*****************************************************************************/
       
    10 
       
    11 Command::Command(const string &name, const string &briefDesc):
       
    12     name(name),
       
    13     briefDesc(briefDesc),
       
    14     verbosity(Normal)
       
    15 {
       
    16 }
       
    17 
       
    18 /*****************************************************************************/
       
    19 
       
    20 Command::~Command()
       
    21 {
       
    22 }
       
    23 
       
    24 /*****************************************************************************/
       
    25 
       
    26 void Command::setVerbosity(Verbosity v)
       
    27 {
       
    28 	verbosity = v;
       
    29 };
       
    30 
       
    31 /****************************************************************************/
       
    32 
       
    33 bool Command::matchesSubstr(const string &cmd) const
       
    34 {
       
    35     return name.substr(0, cmd.length()) == cmd;
       
    36 }
       
    37     
       
    38 /****************************************************************************/
       
    39 
       
    40 bool Command::matchesAbbrev(const string &abb) const
       
    41 {
       
    42     unsigned int i;
       
    43     size_t pos = 0;
       
    44 
       
    45     for (i = 0; i < abb.length(); i++) {
       
    46         pos = name.find(abb[i], pos);
       
    47         if (pos == string::npos)
       
    48             return false;
       
    49     }
       
    50 
       
    51     return true;
       
    52 }
       
    53     
       
    54 /*****************************************************************************/
       
    55 
       
    56 void Command::throwInvalidUsageException(const stringstream &s)
       
    57 {
       
    58     throw InvalidUsageException(s);
       
    59 }
       
    60 
       
    61 /*****************************************************************************/
       
    62 
       
    63 void Command::throwCommandException(const stringstream &s)
       
    64 {
       
    65     throw CommandException(s);
       
    66 }
       
    67 
       
    68 /*****************************************************************************/
       
    69 
       
    70 string Command::numericInfo()
       
    71 {
       
    72     stringstream str;
       
    73 
       
    74     str << "Numerical values can be specified either with decimal (no" << endl
       
    75         << "prefix), octal (prefix '0') or hexadecimal (prefix '0x') base."
       
    76         << endl;
       
    77 
       
    78     return str.str();
       
    79 }
       
    80 
       
    81 /****************************************************************************/