You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCETICE project - Copyright 2009 by Lucio Asnaghi.
  4. JUCETICE is based around the JUCE library - "Jules' Utility Class Extensions"
  5. Copyright 2007 by Julian Storer.
  6. ------------------------------------------------------------------------------
  7. JUCE and JUCETICE can be redistributed and/or modified under the terms of
  8. the GNU General Public License, as published by the Free Software Foundation;
  9. either version 2 of the License, or (at your option) any later version.
  10. JUCE and JUCETICE are distributed in the hope that they will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with JUCE and JUCETICE; if not, visit www.gnu.org/licenses or write to
  16. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17. Boston, MA 02111-1307 USA
  18. ==============================================================================
  19. */
  20. #ifndef __JUCETICE_COMMANDLINETOKENIZER_HEADER__
  21. #define __JUCETICE_COMMANDLINETOKENIZER_HEADER__
  22. //==============================================================================
  23. /** Utility class to tokenize a commandLine
  24. */
  25. class CommandLineTokenizer
  26. {
  27. public:
  28. CommandLineTokenizer () {}
  29. ~CommandLineTokenizer () {}
  30. //==============================================================================
  31. /** Handy utility to create a tokenized string
  32. If you pass an empty string, nothing will be done, every values are returned
  33. as empty strings
  34. */
  35. void parseCommandLine (const String& commandLine);
  36. //==============================================================================
  37. /** Handy functions to get values as like argv[x]
  38. Since the application name isn't used in juce the index of the first
  39. value is obviously zero.
  40. */
  41. const String& operator[] (const int index) const throw();
  42. //==============================================================================
  43. /** Get the numbers of actual string in the array */
  44. const int size();
  45. //==============================================================================
  46. /** Handy utility to check for an existing value in the line
  47. If are looking for an option switch it return the index of the switch
  48. token in the command line otherwise -1.
  49. Optionally you can make the option check not to be case sensitive.
  50. */
  51. int searchToken (const String& tokenToSearch, const bool caseSensitive = true);
  52. //==============================================================================
  53. /** Variables getter with casting */
  54. String getOptionString (const String& tokenToSearch,
  55. const String& defValue = String(),
  56. const bool caseSensitive = true);
  57. bool getOptionBool (const String& tokenToSearch,
  58. const bool defValue = false,
  59. const bool caseSensitive = true);
  60. int getOptionInt (const String& tokenToSearch,
  61. const int defValue = 0,
  62. const bool caseSensitive = true);
  63. double getOptionDouble (const String& tokenToSearch,
  64. const double defValue = 0.0,
  65. const bool caseSensitive = true);
  66. private:
  67. StringArray argv;
  68. };
  69. #endif // __JUCETICE_COMMANDLINETOKENIZER_HEADER__