1 //===-- MICmdArgValConsume.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 // File: MICmdArgValConsume.cpp
13 // Overview: CMICmdArgValConsume implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
23 #include "MICmdArgValConsume.h"
24 #include "MICmdArgContext.h"
26 //++ ------------------------------------------------------------------------------------
27 // Details: CMICmdArgValConsume constructor.
33 CMICmdArgValConsume::CMICmdArgValConsume( void )
37 //++ ------------------------------------------------------------------------------------
38 // Details: CMICmdArgValConsume constructor.
40 // Args: vrArgName - (R) Argument's name to search by.
41 // vbMandatory - (R) True = Yes must be present, false = optional argument.
45 CMICmdArgValConsume::CMICmdArgValConsume( const CMIUtilString & vrArgName, const bool vbMandatory )
46 : CMICmdArgValBaseTemplate( vrArgName, vbMandatory, true )
50 //++ ------------------------------------------------------------------------------------
51 // Details: CMICmdArgValConsume destructor.
57 CMICmdArgValConsume::~CMICmdArgValConsume( void )
61 //++ ------------------------------------------------------------------------------------
62 // Details: Parse the command's argument options string and try to extract the value *this
63 // argument is looking for.
65 // Args: vwArgContext - (R) The command's argument options string.
66 // Return: MIstatus::success - Functional succeeded.
67 // MIstatus::failure - Functional failed.
70 bool CMICmdArgValConsume::Validate( CMICmdArgContext & vwArgContext )
72 if( vwArgContext.IsEmpty() )
73 return MIstatus::success;
75 if( vwArgContext.GetNumberArgsPresent() == 1 )
77 const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
80 vwArgContext.RemoveArg( rArg );
81 return MIstatus::success;
84 // In reality there are more than one option, if so the file option
85 // is the last one (don't handle that here - find the best looking one)
86 const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
87 CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
88 while( it != vecOptions.end() )
90 const CMIUtilString & rTxt( *it );
93 if( vwArgContext.RemoveArg( rTxt ) )
96 return MIstatus::success;
99 return MIstatus::success;
105 return MIstatus::failure;
108 //++ ------------------------------------------------------------------------------------
109 // Details: Nothing to examine as we just want to consume the argument or option (ignore
113 // Return: bool - True = yes ok, false = not ok.
116 bool CMICmdArgValConsume::IsOk( void ) const