1 //===-- MICmdArgSet.h -------------------------------------------*- 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 #pragma once 11 12 #include <vector> 13 14 #include "MICmdArgContext.h" 15 #include "MICmnBase.h" 16 17 // Declarations: 18 class CMICmdArgValBase; 19 20 //++ 21 //============================================================================ 22 // Details: MI common code class. Command arguments container class. 23 // A command may have one or more arguments of which some may be 24 // optional. 25 // *this class contains a list of the command's arguments which are 26 // validates against the commands argument options string (context 27 // string). 28 // Each argument tries to extract the value it is looking for. 29 // Argument objects added to *this container are owned by this 30 // container 31 // and are deleted when this container goes out of scope. Allocate 32 // argument 33 // objects on the heap. 34 // It is assumed the arguments to be parsed are read from left to right 35 // in 36 // order. The order added to *this container is the order they will 37 // parsed. 38 //-- 39 class CMICmdArgSet : public CMICmnBase { 40 // Classes: 41 public: 42 //++ 43 // Description: ArgSet's interface for command arguments to implement. 44 //-- 45 class IArg { 46 public: 47 virtual bool GetFound() const = 0; 48 virtual bool GetIsHandledByCmd() const = 0; 49 virtual bool GetIsMandatory() const = 0; 50 virtual bool GetIsMissingOptions() const = 0; 51 virtual const CMIUtilString &GetName() const = 0; 52 virtual bool GetValid() const = 0; 53 virtual bool Validate(CMICmdArgContext &vwArgContext) = 0; 54 55 virtual ~IArg() = default; 56 }; 57 58 // Typedefs: 59 typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t; 60 61 // Methods: 62 CMICmdArgSet(); 63 64 void Add(CMICmdArgValBase *vArg); 65 bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const; 66 const SetCmdArgs_t &GetArgsThatAreMissing() const; 67 const SetCmdArgs_t &GetArgsThatInvalid() const; 68 size_t GetCount() const; 69 bool IsArgContextEmpty() const; 70 bool IsArgsPresentButNotHandledByCmd() const; 71 void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName); 72 bool Validate(const CMIUtilString &vStrMiCmd, 73 CMICmdArgContext &vwCmdArgsText); 74 75 // Overrideable: 76 ~CMICmdArgSet() override; 77 78 // Methods: 79 private: 80 const SetCmdArgs_t &GetArgsNotHandledByCmd() const; 81 void Destroy(); // Release resources used by *this object 82 bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText); 83 84 // Attributes: 85 bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client 86 // presented the command with options 87 // recognised but not handled by 88 // a command, false = all args handled 89 SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command 90 // is expecting to find in the options string 91 SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are 92 // required by the command but are 93 // missing 94 SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the 95 // text but for some reason unable to 96 // extract a value 97 SetCmdArgs_t m_setCmdArgsNotHandledByCmd; // The set of arguments specified by 98 // the command which were present to 99 // the command but not handled 100 SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were 101 // present but were found to be missing 102 // additional information i.e. 103 // --thread 3 but 3 is missing 104 CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options 105 // text before validate takes place (empties 106 // it of content) 107 const CMIUtilString m_constStrCommaSpc; 108 }; 109