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.
71 CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext)
73 if (vwArgContext.IsEmpty())
74 return MIstatus::success;
76 if (vwArgContext.GetNumberArgsPresent() == 1)
78 const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
81 vwArgContext.RemoveArg(rArg);
82 return MIstatus::success;
85 // In reality there are more than one option, if so the file option
86 // is the last one (don't handle that here - find the best looking one)
87 const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
88 CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
89 while (it != vecOptions.end())
91 const CMIUtilString &rTxt(*it);
94 if (vwArgContext.RemoveArg(rTxt))
97 return MIstatus::success;
100 return MIstatus::success;
106 return MIstatus::failure;
109 //++ ------------------------------------------------------------------------------------
110 // Details: Nothing to examine as we just want to consume the argument or option (ignore
114 // Return: bool - True = yes ok, false = not ok.
118 CMICmdArgValConsume::IsOk(void) const