Browse Source

Adding GetBool method to CmdLineArg

Signed-off-by: Gene Walters <[email protected]>
Gene Walters 3 years ago
parent
commit
d600b1c9fd

+ 8 - 0
Code/Legacy/CryCommon/ICmdLine.h

@@ -71,6 +71,14 @@ public:
     //      The value of the argument as integer number.
     virtual const int GetIValue() const = 0;
     // </interfuscator:shuffle>
+
+    // Description:
+    //      Retrieve the value of the argument.
+    // Arguments:
+    //      cmdLineValue. The cmdline value will be filled out if a valid boolean is found.
+    // Return Value:
+    //      Returns true if the cmdline arg is actually a boolean string matching "true" or "false"; otherwise return false.
+    virtual const bool GetBoolValue(bool& cmdLineValue) const = 0;
 };
 
 // Command line interface

+ 18 - 1
Code/Legacy/CrySystem/CmdLineArg.cpp

@@ -42,5 +42,22 @@ const int CCmdLineArg::GetIValue() const
 {
     return atoi(m_value.c_str());
 }
-
+const bool CCmdLineArg::GetBoolValue(bool& cmdLineValue) const
+{
+    AZStd::string lowercaseValue(m_value);
+    AZStd::to_lower(lowercaseValue.begin(), lowercaseValue.end());
+    if (lowercaseValue == "true")
+    {
+        cmdLineValue = true;
+        return true;
+    }
+
+    if (lowercaseValue == "false")
+    {
+        cmdLineValue = false;
+        return true;
+    }
+    
+    return false;
+}
 

+ 1 - 0
Code/Legacy/CrySystem/CmdLineArg.h

@@ -30,6 +30,7 @@ public:
     const ECmdLineArgType GetType() const;
     const float GetFValue() const;
     const int GetIValue() const;
+    const bool GetBoolValue(bool& cmdLineValue) const;
 
 private: