1 //===-- MICmdArgValOptionShort.cpp ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "MICmdArgValOptionShort.h"
12 #include "MICmdArgContext.h"
15 //------------------------------------------------------------------------------------
16 // Details: CMICmdArgValOptionShort constructor.
22 CMICmdArgValOptionShort::CMICmdArgValOptionShort() {}
25 //------------------------------------------------------------------------------------
26 // Details: CMICmdArgValOptionShort constructor.
28 // Args: vrArgName - (R) Argument's name to search by.
29 // vbMandatory - (R) True = Yes must be present, false = optional
31 // vbHandleByCmd - (R) True = Command processes *this option, false =
36 CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
37 const bool vbMandatory,
38 const bool vbHandleByCmd)
39 : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd) {}
42 //------------------------------------------------------------------------------------
43 // Details: CMICmdArgValOptionLong constructor.
45 // Args: vrArgName - (R) Argument's name to search by.
46 // vbMandatory - (R) True = Yes must be present, false =
48 // vbHandleByCmd - (R) True = Command processes *this option,
49 // false = not handled.
50 // veType - (R) The type of argument to look for and
51 // create argument object of a certain type.
52 // vnExpectingNOptions - (R) The number of options expected to read
53 // following *this argument.
57 CMICmdArgValOptionShort::CMICmdArgValOptionShort(
58 const CMIUtilString &vrArgName, const bool vbMandatory,
59 const bool vbHandleByCmd, const ArgValType_e veType,
60 const MIuint vnExpectingNOptions)
61 : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd, veType,
62 vnExpectingNOptions) {}
65 //------------------------------------------------------------------------------------
66 // Details: CMICmdArgValOptionShort destructor.
72 CMICmdArgValOptionShort::~CMICmdArgValOptionShort() {}
75 //------------------------------------------------------------------------------------
76 // Details: Examine the string and determine if it is a valid short type option
79 // Args: vrTxt - (R) Some text.
80 // Return: bool - True = yes valid arg, false = no.
83 bool CMICmdArgValOptionShort::IsArgShortOption(
84 const CMIUtilString &vrTxt) const {
85 // Look for --someLongOption
86 MIint nPos = vrTxt.find("--");
90 // Look for -f short option
91 nPos = vrTxt.find('-');
95 if (vrTxt.length() > 2)
102 //------------------------------------------------------------------------------------
103 // Details: Examine the string and determine if it is a valid short type option
105 // Long type argument looks like -f some short option.
107 // Args: vrTxt - (R) Some text.
108 // Return: bool - True = yes valid arg, false = no.
111 bool CMICmdArgValOptionShort::IsArgOptionCorrect(
112 const CMIUtilString &vrTxt) const {
113 return IsArgShortOption(vrTxt);
117 //------------------------------------------------------------------------------------
118 // Details: Does the argument name of the argument being parsed ATM match the
120 // *this argument object.
122 // Args: vrTxt - (R) Some text.
123 // Return: bool - True = yes arg name matched, false = no.
126 bool CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const {
127 const CMIUtilString strArg = vrTxt.substr(1);
128 return (strArg == GetName());