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.

83 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /** This class is used for represent a new-line character sequence.
  21. To write a new-line to a stream, you can use the predefined 'newLine' variable, e.g.
  22. @code
  23. myOutputStream << "Hello World" << newLine << newLine;
  24. @endcode
  25. The exact character sequence that will be used for the new-line can be set and
  26. retrieved with OutputStream::setNewLineString() and OutputStream::getNewLineString().
  27. @tags{Core}
  28. */
  29. class JUCE_API NewLine
  30. {
  31. public:
  32. /** Returns the default new-line sequence that the library uses.
  33. @see OutputStream::setNewLineString()
  34. */
  35. static const char* getDefault() noexcept { return "\r\n"; }
  36. /** Returns the default new-line sequence that the library uses.
  37. @see getDefault()
  38. */
  39. operator String() const { return getDefault(); }
  40. /** Returns the default new-line sequence that the library uses.
  41. @see OutputStream::setNewLineString()
  42. */
  43. operator StringRef() const noexcept { return getDefault(); }
  44. };
  45. //==============================================================================
  46. /** A predefined object representing a new-line, which can be written to a string or stream.
  47. To write a new-line to a stream, you can use the predefined 'newLine' variable like this:
  48. @code
  49. myOutputStream << "Hello World" << newLine << newLine;
  50. @endcode
  51. */
  52. extern NewLine newLine;
  53. //==============================================================================
  54. /** Writes a new-line sequence to a string.
  55. You can use the predefined object 'newLine' to invoke this, e.g.
  56. @code
  57. myString << "Hello World" << newLine << newLine;
  58. @endcode
  59. */
  60. inline String& operator<< (String& string1, const NewLine&) { return string1 += NewLine::getDefault(); }
  61. inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLine::getDefault(); }
  62. inline String operator+ (const NewLine&, const NewLine&) { return String (NewLine::getDefault()) + NewLine::getDefault(); }
  63. inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); }
  64. inline String operator+ (const NewLine&, const char* s2) { return String (NewLine::getDefault()) + s2; }
  65. } // namespace juce