The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

152 lines
7.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__
  19. #define __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__
  20. //==============================================================================
  21. #define JUCE_T(stringLiteral) (L##stringLiteral)
  22. typedef juce_wchar tchar;
  23. #if ! JUCE_DONT_DEFINE_MACROS
  24. /** The 'T' macro allows a literal string to be compiled as unicode.
  25. If you write your string literals in the form T("xyz"), it will be compiled as L"xyz"
  26. or "xyz", depending on which representation is best for the String class to work with.
  27. Because the 'T' symbol is occasionally used inside 3rd-party library headers which you
  28. may need to include after juce.h, you can use the juce_withoutMacros.h file (in
  29. the juce/src directory) to avoid defining this macro. See the comments in
  30. juce_withoutMacros.h for more info.
  31. */
  32. #define T(stringLiteral) JUCE_T(stringLiteral)
  33. #endif
  34. //==============================================================================
  35. /**
  36. A set of methods for manipulating characters and character strings, with
  37. duplicate methods to handle 8-bit and unicode characters.
  38. These are defined as wrappers around the basic C string handlers, to provide
  39. a clean, cross-platform layer, (because various platforms differ in the
  40. range of C library calls that they provide).
  41. @see String
  42. */
  43. class JUCE_API CharacterFunctions
  44. {
  45. public:
  46. static int length (const char* const s) throw();
  47. static int length (const juce_wchar* const s) throw();
  48. static void copy (char* dest, const char* src, const int maxBytes) throw();
  49. static void copy (juce_wchar* dest, const juce_wchar* src, const int maxChars) throw();
  50. static void copy (juce_wchar* dest, const char* src, const int maxChars) throw();
  51. static void copy (char* dest, const juce_wchar* src, const int maxBytes) throw();
  52. static int bytesRequiredForCopy (const juce_wchar* src) throw();
  53. static void append (char* dest, const char* src) throw();
  54. static void append (juce_wchar* dest, const juce_wchar* src) throw();
  55. static int compare (const char* const s1, const char* const s2) throw();
  56. static int compare (const juce_wchar* s1, const juce_wchar* s2) throw();
  57. static int compare (const juce_wchar* s1, const char* s2) throw();
  58. static int compare (const char* s1, const juce_wchar* s2) throw();
  59. static int compare (const char* const s1, const char* const s2, const int maxChars) throw();
  60. static int compare (const juce_wchar* s1, const juce_wchar* s2, int maxChars) throw();
  61. static int compareIgnoreCase (const char* const s1, const char* const s2) throw();
  62. static int compareIgnoreCase (const juce_wchar* s1, const juce_wchar* s2) throw();
  63. static int compareIgnoreCase (const char* const s1, const char* const s2, const int maxChars) throw();
  64. static int compareIgnoreCase (const juce_wchar* s1, const juce_wchar* s2, int maxChars) throw();
  65. static const char* find (const char* const haystack, const char* const needle) throw();
  66. static const juce_wchar* find (const juce_wchar* haystack, const juce_wchar* const needle) throw();
  67. static int indexOfChar (const char* const haystack, const char needle, const bool ignoreCase) throw();
  68. static int indexOfChar (const juce_wchar* const haystack, const juce_wchar needle, const bool ignoreCase) throw();
  69. static int indexOfCharFast (const char* const haystack, const char needle) throw();
  70. static int indexOfCharFast (const juce_wchar* const haystack, const juce_wchar needle) throw();
  71. static int getIntialSectionContainingOnly (const char* const text, const char* const allowedChars) throw();
  72. static int getIntialSectionContainingOnly (const juce_wchar* const text, const juce_wchar* const allowedChars) throw();
  73. static int ftime (char* const dest, const int maxChars, const char* const format, const struct tm* const tm) throw();
  74. static int ftime (juce_wchar* const dest, const int maxChars, const juce_wchar* const format, const struct tm* const tm) throw();
  75. static int getIntValue (const char* const s) throw();
  76. static int getIntValue (const juce_wchar* s) throw();
  77. static int64 getInt64Value (const char* s) throw();
  78. static int64 getInt64Value (const juce_wchar* s) throw();
  79. static double getDoubleValue (const char* const s) throw();
  80. static double getDoubleValue (const juce_wchar* const s) throw();
  81. //==============================================================================
  82. static char toUpperCase (const char character) throw();
  83. static juce_wchar toUpperCase (const juce_wchar character) throw();
  84. static void toUpperCase (char* s) throw();
  85. static void toUpperCase (juce_wchar* s) throw();
  86. static bool isUpperCase (const char character) throw();
  87. static bool isUpperCase (const juce_wchar character) throw();
  88. static char toLowerCase (const char character) throw();
  89. static juce_wchar toLowerCase (const juce_wchar character) throw();
  90. static void toLowerCase (char* s) throw();
  91. static void toLowerCase (juce_wchar* s) throw();
  92. static bool isLowerCase (const char character) throw();
  93. static bool isLowerCase (const juce_wchar character) throw();
  94. //==============================================================================
  95. static bool isWhitespace (const char character) throw();
  96. static bool isWhitespace (const juce_wchar character) throw();
  97. static bool isDigit (const char character) throw();
  98. static bool isDigit (const juce_wchar character) throw();
  99. static bool isLetter (const char character) throw();
  100. static bool isLetter (const juce_wchar character) throw();
  101. static bool isLetterOrDigit (const char character) throw();
  102. static bool isLetterOrDigit (const juce_wchar character) throw();
  103. /** Returns 0 to 16 for '0' to 'F", or -1 for characters that aren't a legel
  104. hex digit.
  105. */
  106. static int getHexDigitValue (const juce_wchar digit) throw();
  107. };
  108. #endif // __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__