1 /*
2  * synergy -- mouse and keyboard sharing utility
3  * Copyright (C) 2012-2016 Symless Ltd.
4  * Copyright (C) 2004 Chris Schoeneman
5  *
6  * This package is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * found in the file LICENSE that should have accompanied this file.
9  *
10  * This package is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "platform/OSXClipboard.h"
22 
23 //! Convert to/from some text encoding
24 class OSXClipboardAnyTextConverter : public IOSXClipboardConverter {
25 public:
26     OSXClipboardAnyTextConverter();
27     virtual ~OSXClipboardAnyTextConverter();
28 
29     // IOSXClipboardConverter overrides
30     virtual IClipboard::EFormat
31                         getFormat() const;
32     virtual CFStringRef
33                         getOSXFormat() const = 0;
34     virtual String        fromIClipboard(const String &) const;
35     virtual String        toIClipboard(const String &) const;
36 
37 protected:
38     //! Convert from IClipboard format
39     /*!
40     Do UTF-8 conversion and linefeed conversion.
41     */
42     virtual String        doFromIClipboard(const String&) const = 0;
43 
44     //! Convert to IClipboard format
45     /*!
46     Do UTF-8 conversion and Linefeed conversion.
47     */
48     virtual String        doToIClipboard(const String&) const = 0;
49 
50 private:
51     static String        convertLinefeedToMacOS(const String&);
52     static String        convertLinefeedToUnix(const String&);
53 };
54