CmdLineArg.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "CrySystem_precompiled.h"
  9. #include "CmdLineArg.h"
  10. CCmdLineArg::CCmdLineArg(const char* name, const char* value, ECmdLineArgType type)
  11. {
  12. m_name = name;
  13. m_value = value;
  14. m_type = type;
  15. }
  16. CCmdLineArg::~CCmdLineArg()
  17. {
  18. }
  19. const char* CCmdLineArg::GetName() const
  20. {
  21. return m_name.c_str();
  22. }
  23. const char* CCmdLineArg::GetValue() const
  24. {
  25. return m_value.c_str();
  26. }
  27. const ECmdLineArgType CCmdLineArg::GetType() const
  28. {
  29. return m_type;
  30. }
  31. const float CCmdLineArg::GetFValue() const
  32. {
  33. return (float)atof(m_value.c_str());
  34. }
  35. const int CCmdLineArg::GetIValue() const
  36. {
  37. return atoi(m_value.c_str());
  38. }
  39. const bool CCmdLineArg::GetBoolValue(bool& cmdLineValue) const
  40. {
  41. AZStd::string lowercaseValue(m_value);
  42. AZStd::to_lower(lowercaseValue.begin(), lowercaseValue.end());
  43. if (lowercaseValue == "true")
  44. {
  45. cmdLineValue = true;
  46. return true;
  47. }
  48. if (lowercaseValue == "false")
  49. {
  50. cmdLineValue = false;
  51. return true;
  52. }
  53. return false;
  54. }