1 //===-- MICmdArgSet.h -------------------------------------------*- 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: MICmdArgSet.h
13 // Overview: CMICmdArgSet interface.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
24 // Third party headers:
28 #include "MICmnBase.h"
29 #include "MICmdArgContext.h"
32 class CMICmdArgValBase;
34 //++ ============================================================================
35 // Details: MI common code class. Command arguments container class.
36 // A command may have one or more arguments of which some may be optional.
37 // *this class contains a list of the command's arguments which are
38 // validates against the commands argument options string (context string).
39 // Each argument tries to extract the value it is looking for.
40 // Argument objects added to *this container are owned by this container
41 // and are deleted when this container goes out of scope. Allocate argument
42 // objects on the heap.
43 // It is assummed the arguments to be parsed are read from left to right in
44 // order. The order added to *this container is the order they will parsed.
46 // Authors: Illya Rudkin 14/04/2014.
49 class CMICmdArgSet : public CMICmnBase
54 // Description: ArgSet's interface for command arguments to implement.
59 virtual bool GetFound(void) const = 0;
60 virtual bool GetIsHandledByCmd(void) const = 0;
61 virtual bool GetIsMandatory(void) const = 0;
62 virtual bool GetIsMissingOptions(void) const = 0;
63 virtual const CMIUtilString &GetName(void) const = 0;
64 virtual bool GetValid(void) const = 0;
65 virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
67 /* dtor */ virtual ~IArg(void){};
72 typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
76 /* ctor */ CMICmdArgSet(void);
78 bool Add(const CMICmdArgValBase &vArg);
79 bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
80 const SetCmdArgs_t &GetArgsThatAreMissing(void) const;
81 const SetCmdArgs_t &GetArgsThatInvalid(void) const;
82 MIuint GetCount(void) const;
83 bool IsArgContextEmpty(void) const;
84 bool IsArgsPresentButNotHandledByCmd(void) const;
85 void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
86 bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText);
90 /* dtor */ virtual ~CMICmdArgSet(void);
94 const SetCmdArgs_t &GetArgsNotHandledByCmd(void) const;
96 Destroy(void); // Release resources used by *this object
97 bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
101 bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by
102 // a command, false = all args handled
103 SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string
104 SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are required by the command but are missing
105 SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the text but for some reason unable to extract a value
107 m_setCmdArgsNotHandledByCmd; // The set of arguments specified by the command which were present to the command but not handled
108 SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were present but were found to be missing additional information i.e.
109 // --thread 3 but 3 is missing
110 CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options text before validate takes place (empties it of content)
111 const CMIUtilString m_constStrCommaSpc;