]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/tools/lldb-mi/MICmdArgSet.h
Unbreak DRM KMS build by adding the needed compatibility field in the LinuxKPI.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / tools / lldb-mi / MICmdArgSet.h
1 //===-- MICmdArgSet.h -------------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 #pragma once
10
11 #include <vector>
12
13 #include "MICmdArgContext.h"
14 #include "MICmnBase.h"
15
16 // Declarations:
17 class CMICmdArgValBase;
18
19 //++
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
23 //          optional.
24 //          *this class contains a list of the command's arguments which are
25 //          validates against the commands argument options string (context
26 //          string).
27 //          Each argument tries to extract the value it is looking for.
28 //          Argument objects added to *this container are owned by this
29 //          container
30 //          and are deleted when this container goes out of scope. Allocate
31 //          argument
32 //          objects on the heap.
33 //          It is assumed the arguments to be parsed are read from left to right
34 //          in
35 //          order. The order added to *this container is the order they will
36 //          parsed.
37 //--
38 class CMICmdArgSet : public CMICmnBase {
39   // Classes:
40 public:
41   //++
42   // Description: ArgSet's interface for command arguments to implement.
43   //--
44   class IArg {
45   public:
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;
53
54     virtual ~IArg() = default;
55   };
56
57   // Typedefs:
58   typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
59
60   // Methods:
61   CMICmdArgSet();
62
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);
73
74   // Overrideable:
75   ~CMICmdArgSet() override;
76
77   // Methods:
78 private:
79   const SetCmdArgs_t &GetArgsNotHandledByCmd() const;
80   void Destroy(); // Release resources used by *this object
81   bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
82
83   // Attributes:
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
92                                            // missing
93   SetCmdArgs_t m_setCmdArgsThatNotValid;   // The set of arguments found in the
94                                            // text but for some reason unable to
95                                            // extract a value
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
105                                     // it of content)
106   const CMIUtilString m_constStrCommaSpc;
107 };