OpenShot Library | libopenshot-audio  0.2.0
juce_NewLine.h
1 
2 /** @weakgroup juce_core-text
3  * @{
4  */
5 /*
6  ==============================================================================
7 
8  This file is part of the JUCE library.
9  Copyright (c) 2017 - ROLI Ltd.
10 
11  JUCE is an open source library subject to commercial or open-source
12  licensing.
13 
14  The code included in this file is provided under the terms of the ISC license
15  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16  To use, copy, modify, and/or distribute this software for any purpose with or
17  without fee is hereby granted provided that the above copyright notice and
18  this permission notice appear in all copies.
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 
30 //==============================================================================
31 /** This class is used for represent a new-line character sequence.
32 
33  To write a new-line to a stream, you can use the predefined 'newLine' variable, e.g.
34  @code
35  myOutputStream << "Hello World" << newLine << newLine;
36  @endcode
37 
38  The exact character sequence that will be used for the new-line can be set and
39  retrieved with OutputStream::setNewLineString() and OutputStream::getNewLineString().
40 
41  @tags{Core}
42 */
44 {
45 public:
46  /** Returns the default new-line sequence that the library uses.
47  @see OutputStream::setNewLineString()
48  */
49  static const char* getDefault() noexcept { return "\r\n"; }
50 
51  /** Returns the default new-line sequence that the library uses.
52  @see getDefault()
53  */
54  operator String() const { return getDefault(); }
55 
56  /** Returns the default new-line sequence that the library uses.
57  @see OutputStream::setNewLineString()
58  */
59  operator StringRef() const noexcept { return getDefault(); }
60 };
61 
62 //==============================================================================
63 /** A predefined object representing a new-line, which can be written to a string or stream.
64 
65  To write a new-line to a stream, you can use the predefined 'newLine' variable like this:
66  @code
67  myOutputStream << "Hello World" << newLine << newLine;
68  @endcode
69 */
70 extern NewLine newLine;
71 
72 //==============================================================================
73 /** Writes a new-line sequence to a string.
74  You can use the predefined object 'newLine' to invoke this, e.g.
75  @code
76  myString << "Hello World" << newLine << newLine;
77  @endcode
78 */
79 inline String& operator<< (String& string1, const NewLine&) { return string1 += NewLine::getDefault(); }
80 inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLine::getDefault(); }
81 
82 inline String operator+ (const NewLine&, const NewLine&) { return String (NewLine::getDefault()) + NewLine::getDefault(); }
83 inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); }
84 inline String operator+ (const NewLine&, const char* s2) { return String (NewLine::getDefault()) + s2; }
85 
86 } // namespace juce
87 
88 /** @}*/
juce::StringRef
A simple class for holding temporary references to a string literal or String.
Definition: juce_StringRef.h:65
juce::NewLine
This class is used for represent a new-line character sequence.
Definition: juce_NewLine.h:43
juce::NewLine::getDefault
static const char * getDefault() noexcept
Returns the default new-line sequence that the library uses.
Definition: juce_NewLine.h:49
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition: juce_StandardHeader.h:143
juce::String
The JUCE String class!
Definition: juce_String.h:42