ICmdLine.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // Description : This is the interface to access command line arguments.
  9. // This will avoid the need to parse command line in multiple
  10. // places and thus reduce unnecessary code duplication
  11. #ifndef CRYINCLUDE_CRYCOMMON_ICMDLINE_H
  12. #define CRYINCLUDE_CRYCOMMON_ICMDLINE_H
  13. #pragma once
  14. // The type of command line argument
  15. enum ECmdLineArgType
  16. {
  17. // Description:
  18. // Argument was not preceeded by anything
  19. eCLAT_Normal = 0,
  20. // Description:
  21. // Argument was preceeded by a minus sign '-'
  22. eCLAT_Pre,
  23. // Description:
  24. // Argument was preceeded by a plus signe '+'
  25. eCLAT_Post,
  26. // Description:
  27. // Argument is the executable filename
  28. eCLAT_Executable,
  29. };
  30. // Container for a command line Argument
  31. class ICmdLineArg
  32. {
  33. public:
  34. // <interfuscator:shuffle>
  35. virtual ~ICmdLineArg(){}
  36. // Description:
  37. // Retrieve the name of the argument.
  38. // Return Value:
  39. // The name of the argument.
  40. virtual const char* GetName() const = 0;
  41. // Description:
  42. // Retrieve the value of the argument.
  43. // Return Value:
  44. // The value of the argument as a null-terminated string.
  45. virtual const char* GetValue() const = 0;
  46. // Description:
  47. // Retrieve the type of argument.
  48. // Return Value:
  49. // The type of argument.
  50. // See Also:
  51. // ECmdLineArgType
  52. virtual const ECmdLineArgType GetType() const = 0;
  53. // Description:
  54. // Retrieve the value of the argument.
  55. // Return Value:
  56. // The value of the argument as float number.
  57. virtual const float GetFValue() const = 0;
  58. // Description:
  59. // Retrieve the value of the argument.
  60. // Return Value:
  61. // The value of the argument as integer number.
  62. virtual const int GetIValue() const = 0;
  63. // </interfuscator:shuffle>
  64. // Description:
  65. // Retrieve the value of the argument.
  66. // Arguments:
  67. // cmdLineValue. The cmdline value will be filled out if a valid boolean is found.
  68. // Return Value:
  69. // Returns true if the cmdline arg is actually a boolean string matching "true" or "false"; otherwise return false.
  70. virtual const bool GetBoolValue(bool& cmdLineValue) const = 0;
  71. };
  72. // Command line interface
  73. class ICmdLine
  74. {
  75. public:
  76. // <interfuscator:shuffle>
  77. virtual ~ICmdLine(){}
  78. // Description:
  79. // Returns the n-th command line argument.
  80. // Arguments:
  81. // n - 0 returns executable name, otherwise returns n-th argument.
  82. // Return Value:
  83. // Pointer to the command line argument at index specified by idx.
  84. // See Also:
  85. // ICmdLineArg
  86. virtual const ICmdLineArg* GetArg(int n) const = 0;
  87. // Description:
  88. // Returns the number of command line arguments.
  89. // Return Value:
  90. // The number of command line arguments.
  91. virtual int GetArgCount() const = 0;
  92. // Description:
  93. // Finds an argument in the command line.
  94. // Arguments:
  95. // name - the name of the argument to find, excluding any '+' or '-'
  96. // Return Value:
  97. // 0 when if the argument was not found.
  98. // Pointer to a ICmdLineArg class containing the specified argument.
  99. // See Also:
  100. // ICmdLineArg
  101. virtual const ICmdLineArg* FindArg(const ECmdLineArgType ArgType, const char* name, bool caseSensitive = false) const = 0;
  102. // </interfuscator:shuffle>
  103. };
  104. #endif // CRYINCLUDE_CRYCOMMON_ICMDLINE_H