2 ==============================================================================
4 This file is part of the Water library.
5 Copyright (c) 2016 ROLI Ltd.
6 Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com>
8 Permission is granted to use this software under the terms of the ISC license
9 http://www.isc.org/downloads/software-support-policy/isc-license/
11 Permission to use, copy, modify, and/or distribute this software for any
12 purpose with or without fee is hereby granted, provided that the above
13 copyright notice and this permission notice appear in all copies.
15 THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
16 TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
18 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 ==============================================================================
26 #ifndef WATER_NEWLINE_H_INCLUDED
27 #define WATER_NEWLINE_H_INCLUDED
33 //==============================================================================
34 /** This class is used for represent a new-line character sequence.
36 To write a new-line to a stream, you can use the predefined 'newLine' variable, e.g.
38 myOutputStream << "Hello World" << newLine << newLine;
41 The exact character sequence that will be used for the new-line can be set and
42 retrieved with OutputStream::setNewLineString() and OutputStream::getNewLineString().
47 /** Returns the default new-line sequence that the library uses.
48 @see OutputStream::setNewLineString()
50 static const char* getDefault() noexcept
{ return "\r\n"; }
52 /** Returns the default new-line sequence that the library uses.
55 operator String() const { return getDefault(); }
57 /** Returns the default new-line sequence that the library uses.
58 @see OutputStream::setNewLineString()
60 operator StringRef() const noexcept
{ return getDefault(); }
63 //==============================================================================
64 /** Writes a new-line sequence to a string.
65 You can use the predefined object 'newLine' to invoke this, e.g.
67 myString << "Hello World" << newLine << newLine;
70 inline String
& operator<< (String
& string1
, const NewLine
&) { return string1
+= NewLine::getDefault(); }
71 inline String
& operator+= (String
& s1
, const NewLine
&) { return s1
+= NewLine::getDefault(); }
73 inline String
operator+ (const NewLine
&, const NewLine
&) { return String (NewLine::getDefault()) + NewLine::getDefault(); }
74 inline String
operator+ (String s1
, const NewLine
&) { return s1
+= NewLine::getDefault(); }
75 inline String
operator+ (const NewLine
&, const char* s2
) { return String (NewLine::getDefault()) + s2
; }
79 #endif // WATER_NEWLINE_H_INCLUDED