2
0

commandline.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. */
  5. #ifndef BX_COMMANDLINE_H_HEADER_GUARD
  6. #define BX_COMMANDLINE_H_HEADER_GUARD
  7. #include "bx.h"
  8. namespace bx
  9. {
  10. /// Reference:
  11. /// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
  12. const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term = '\0');
  13. ///
  14. class CommandLine
  15. {
  16. public:
  17. ///
  18. CommandLine(int32_t _argc, char const* const* _argv);
  19. ///
  20. const char* findOption(const char* _long, const char* _default) const;
  21. ///
  22. const char* findOption(const char _short, const char* _long, const char* _default) const;
  23. ///
  24. const char* findOption(const char* _long, int32_t _numParams = 1) const;
  25. ///
  26. const char* findOption(const char _short, const char* _long = NULL, int32_t _numParams = 1) const;
  27. ///
  28. const char* findOption(int32_t _skip, const char _short, const char* _long = NULL, int32_t _numParams = 1) const;
  29. ///
  30. bool hasArg(const char _short, const char* _long = NULL) const;
  31. ///
  32. bool hasArg(const char* _long) const;
  33. ///
  34. bool hasArg(const char*& _value, const char _short, const char* _long = NULL) const;
  35. ///
  36. bool hasArg(int32_t& _value, const char _short, const char* _long = NULL) const;
  37. ///
  38. bool hasArg(uint32_t& _value, const char _short, const char* _long = NULL) const;
  39. ///
  40. bool hasArg(float& _value, const char _short, const char* _long = NULL) const;
  41. ///
  42. bool hasArg(double& _value, const char _short, const char* _long = NULL) const;
  43. ///
  44. bool hasArg(bool& _value, const char _short, const char* _long = NULL) const;
  45. private:
  46. ///
  47. const char* find(int32_t _skip, const char _short, const char* _long, int32_t _numParams) const;
  48. int32_t m_argc;
  49. char const* const* m_argv;
  50. };
  51. } // namespace bx
  52. #endif /// BX_COMMANDLINE_H_HEADER_GUARD