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