PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/io/filter/quoted_printable_output_stream.e

http://github.com/tybor/Liberty
Specman e | 68 lines | 35 code | 7 blank | 26 comment | 0 complexity | ce719dfafa66499029a29fd2c0538b93 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4class QUOTED_PRINTABLE_OUTPUT_STREAM
 5   --
 6   -- A quoted-printable encoder. The underlying stream gets encoded in quoted-printable via this filter.
 7   --
 8
 9inherit
10   FILTER_OUTPUT_STREAM
11
12create {ANY}
13   connect_to
14
15feature {}
16   local_can_disconnect: BOOLEAN True
17
18feature {FILTER_OUTPUT_STREAM}
19   filtered_put_character (c: CHARACTER)
20      do
21         inspect
22            c.code
23         when 0 .. 9, 11 .. 31, 128 .. 255 then
24            put_quoted_character(c)
25         else
26            stream.filtered_put_character(c)
27         end
28      end
29
30   filtered_flush
31      do
32         stream.filtered_flush
33      end
34
35feature {}
36   put_quoted_character (c: CHARACTER)
37      local
38         s: STRING
39      do
40         s := once ""
41         s.clear_count
42         c.code.to_hexadecimal_in(s)
43         stream.filtered_put_character('=')
44         stream.filtered_put_character(s.item(s.upper - 1))
45         stream.filtered_put_character(s.last)
46      end
47
48end -- class QUOTED_PRINTABLE_OUTPUT_STREAM
49--
50-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
51--
52-- Permission is hereby granted, free of charge, to any person obtaining a copy
53-- of this software and associated documentation files (the "Software"), to deal
54-- in the Software without restriction, including without limitation the rights
55-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
56-- copies of the Software, and to permit persons to whom the Software is
57-- furnished to do so, subject to the following conditions:
58--
59-- The above copyright notice and this permission notice shall be included in
60-- all copies or substantial portions of the Software.
61--
62-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
68-- THE SOFTWARE.