1 //===-- MICmdArgValListBase.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 // Third party headers: 13 #include <vector> 14 15 // In-house headers: 16 #include "MICmdArgValBase.h" 17 18 // Declarations: 19 class CMICmdArgContext; 20 21 //++ 22 //============================================================================ 23 // Details: MI common code class. Command argument with addition options class. 24 // For example --recurse 1 2 4 [group ...]. Arguments object that 25 // require a list of options associated with them derive from the 26 // CMICmdArgValListBase class. Additional options are also extracted 27 // from 28 // the command arguments text string. 29 // An argument knows what type of argument it is and how it is to 30 // interpret the options (context) string to find and validate a 31 // matching 32 // options and so extract a values from it . 33 // The CMICmdArgValBase objects are added to the derived argument 34 // class's 35 // container. The option arguments belong to that derived class and 36 // will 37 // be deleted that object goes out of scope. 38 // Based on the Interpreter pattern. 39 //-- 40 class CMICmdArgValListBase 41 : public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> { 42 // Typedef: 43 public: 44 typedef std::vector<CMICmdArgValBase *> VecArgObjPtr_t; 45 46 // Enums: 47 public: 48 //++ 49 //--------------------------------------------------------------------------------- 50 // Details: CMICmdArgValListBase needs to know what type of argument to look 51 // for in 52 // the command options text. It also needs to create argument objects 53 // of 54 // a specific type. 55 //-- 56 enum ArgValType_e { 57 eArgValType_File = 0, 58 eArgValType_Consume, 59 eArgValType_Number, 60 eArgValType_OptionLong, 61 eArgValType_OptionShort, 62 eArgValType_String, 63 eArgValType_StringQuoted, 64 eArgValType_StringQuotedNumber, 65 eArgValType_StringQuotedNumberPath, 66 eArgValType_StringAnything, // Accept any words for a string 'type' even if 67 // they look like --longOptions for example 68 eArgValType_ThreadGrp, 69 eArgValType_count, // Always the last one 70 eArgValType_invalid 71 }; 72 73 // Methods: 74 public: 75 /* ctor */ CMICmdArgValListBase(); 76 /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, 77 const bool vbMandatory, 78 const bool vbHandleByCmd); 79 /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, 80 const bool vbMandatory, 81 const bool vbHandleByCmd, 82 const ArgValType_e veType); 83 84 // Overridden: 85 public: 86 // From CMICmdArgValBase 87 /* dtor */ ~CMICmdArgValListBase() override; 88 89 // Methods: 90 protected: 91 bool IsExpectedCorrectType(const CMIUtilString &vrTxt, 92 const ArgValType_e veType) const; 93 CMICmdArgValBase *CreationObj(const CMIUtilString &vrTxt, 94 const ArgValType_e veType) const; 95 96 // Attributes: 97 protected: 98 ArgValType_e m_eArgType; 99 100 // Methods: 101 private: 102 void Destroy(); 103 }; 104