1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
//===-- MICmdArgValOptionShort.cpp ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// In-house headers:
#include "MICmdArgValOptionShort.h"
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
CMICmdArgValOptionShort::CMICmdArgValOptionShort(void)
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
// vbMandatory - (R) True = Yes must be present, false = optional argument.
// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
// Return: None.
// Throws: None.
//--
CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
: CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd)
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
// vbMandatory - (R) True = Yes must be present, false = optional argument.
// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
// veType - (R) The type of argument to look for and create argument object of a certain type.
// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
// Return: None.
// Throws: None.
//--
CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const ArgValType_e veType, const MIuint vnExpectingNOptions)
: CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd, veType, vnExpectingNOptions)
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
CMICmdArgValOptionShort::~CMICmdArgValOptionShort(void)
{
}
//++ ------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid short type option argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
bool
CMICmdArgValOptionShort::IsArgShortOption(const CMIUtilString &vrTxt) const
{
// Look for --someLongOption
MIint nPos = vrTxt.find("--");
if (nPos == 0)
return false;
// Look for -f short option
nPos = vrTxt.find("-");
if (nPos != 0)
return false;
if (vrTxt.length() > 2)
return false;
return true;
}
//++ ------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid short type option argument.
// Long type argument looks like -f some short option.
// Type: Overridden.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
bool
CMICmdArgValOptionShort::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
{
return IsArgShortOption(vrTxt);
}
//++ ------------------------------------------------------------------------------------
// Details: Does the argument name of the argument being parsed ATM match the name of
// *this argument object.
// Type: Overridden.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes arg name matched, false = no.
// Throws: None.
//--
bool
CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const
{
const CMIUtilString strArg = vrTxt.substr(1).c_str();
return (strArg == GetName());
}
|