1 //===-- MICmdArgValNumber.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 // In-house headers: 13 #include "MICmdArgValBase.h" 14 15 // Declarations: 16 class CMICmdArgContext; 17 18 //++ 19 //============================================================================ 20 // Details: MI common code class. Command argument class. Arguments object 21 // needing specialization derived from the CMICmdArgValBase class. 22 // An argument knows what type of argument it is and how it is to 23 // interpret the options (context) string to find and validate a 24 // matching 25 // argument and so extract a value from it . 26 // Based on the Interpreter pattern. 27 //-- 28 class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64> { 29 // Enums: 30 public: 31 //++ 32 //--------------------------------------------------------------------------------- 33 // Details: CMICmdArgValNumber needs to know what format of argument to look 34 // for in 35 // the command options text. 36 //-- 37 enum ArgValNumberFormat_e { 38 eArgValNumberFormat_Decimal = (1u << 0), 39 eArgValNumberFormat_Hexadecimal = (1u << 1), 40 eArgValNumberFormat_Auto = 41 ((eArgValNumberFormat_Hexadecimal << 1) - 42 1u) ///< Indicates to try and lookup everything up during a query. 43 }; 44 45 // Methods: 46 public: 47 /* ctor */ CMICmdArgValNumber(); 48 /* ctor */ CMICmdArgValNumber( 49 const CMIUtilString &vrArgName, const bool vbMandatory, 50 const bool vbHandleByCmd, 51 const MIuint vnNumberFormatMask = eArgValNumberFormat_Decimal); 52 // 53 bool IsArgNumber(const CMIUtilString &vrTxt) const; 54 55 // Overridden: 56 public: 57 // From CMICmdArgValBase 58 /* dtor */ ~CMICmdArgValNumber() override; 59 // From CMICmdArgSet::IArg 60 bool Validate(CMICmdArgContext &vwArgContext) override; 61 62 // Methods: 63 private: 64 bool ExtractNumber(const CMIUtilString &vrTxt); 65 MIint64 GetNumber() const; 66 67 // Attributes: 68 private: 69 MIuint m_nNumberFormatMask; 70 MIint64 m_nNumber; 71 }; 72