1 //===-- MICmdArgSet.h -------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include "MICmdArgContext.h"
14 #include "MICmnBase.h"
17 class CMICmdArgValBase;
20 //============================================================================
21 // Details: MI common code class. Command arguments container class.
22 // A command may have one or more arguments of which some may be
24 // *this class contains a list of the command's arguments which are
25 // validates against the commands argument options string (context
27 // Each argument tries to extract the value it is looking for.
28 // Argument objects added to *this container are owned by this
30 // and are deleted when this container goes out of scope. Allocate
32 // objects on the heap.
33 // It is assumed the arguments to be parsed are read from left to right
35 // order. The order added to *this container is the order they will
38 class CMICmdArgSet : public CMICmnBase {
42 // Description: ArgSet's interface for command arguments to implement.
46 virtual bool GetFound() const = 0;
47 virtual bool GetIsHandledByCmd() const = 0;
48 virtual bool GetIsMandatory() const = 0;
49 virtual bool GetIsMissingOptions() const = 0;
50 virtual const CMIUtilString &GetName() const = 0;
51 virtual bool GetValid() const = 0;
52 virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
54 virtual ~IArg() = default;
58 typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
63 void Add(CMICmdArgValBase *vArg);
64 bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
65 const SetCmdArgs_t &GetArgsThatAreMissing() const;
66 const SetCmdArgs_t &GetArgsThatInvalid() const;
67 size_t GetCount() const;
68 bool IsArgContextEmpty() const;
69 bool IsArgsPresentButNotHandledByCmd() const;
70 void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
71 bool Validate(const CMIUtilString &vStrMiCmd,
72 CMICmdArgContext &vwCmdArgsText);
75 ~CMICmdArgSet() override;
79 const SetCmdArgs_t &GetArgsNotHandledByCmd() const;
80 void Destroy(); // Release resources used by *this object
81 bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
84 bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client
85 // presented the command with options
86 // recognised but not handled by
87 // a command, false = all args handled
88 SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command
89 // is expecting to find in the options string
90 SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are
91 // required by the command but are
93 SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the
94 // text but for some reason unable to
96 SetCmdArgs_t m_setCmdArgsNotHandledByCmd; // The set of arguments specified by
97 // the command which were present to
98 // the command but not handled
99 SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were
100 // present but were found to be missing
101 // additional information i.e.
102 // --thread 3 but 3 is missing
103 CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options
104 // text before validate takes place (empties
106 const CMIUtilString m_constStrCommaSpc;