Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / unx / gtk3_kde5 / filepicker_ipc_commands.hxx
blob1d0925257b9edb5b1051789b30a1312719c79667
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <cstdint>
23 #include <iostream>
24 #include <vector>
26 #include <sal/types.h>
27 #include <com/sun/star/uno/Sequence.hxx>
29 // #define DEBUG_FILEPICKER_IPC
31 namespace rtl
33 class OUString;
35 class QString;
37 enum class Commands : uint16_t
39 SetTitle,
40 SetWinId,
41 Execute,
42 SetMultiSelectionMode,
43 SetDefaultName,
44 SetDisplayDirectory,
45 GetDisplayDirectory,
46 GetSelectedFiles,
47 AppendFilter,
48 SetCurrentFilter,
49 GetCurrentFilter,
50 SetValue,
51 GetValue,
52 EnableControl,
53 SetLabel,
54 GetLabel,
55 AddCheckBox,
56 Initialize,
57 Quit,
58 EnablePickFolderMode,
61 inline std::vector<char> readIpcStringArg(std::istream& stream)
63 uint32_t length = 0;
64 stream >> length;
65 stream.ignore(); // skip space separator
66 std::vector<char> buffer(length, '\0');
67 stream.read(buffer.data(), length);
68 return buffer;
71 void readIpcArg(std::istream& stream, OUString& string);
72 void readIpcArg(std::istream& stream, QString& string);
73 void readIpcArg(std::istream& stream, css::uno::Sequence<OUString>& seq);
75 inline void readIpcArg(std::istream& stream, Commands& value)
77 uint16_t v = 0;
78 stream >> v;
79 stream.ignore(); // skip space
80 value = static_cast<Commands>(v);
83 void readIpcArg(std::istream&, sal_Bool) = delete;
85 inline void readIpcArg(std::istream& stream, bool& value)
87 stream >> value;
88 stream.ignore(); // skip space
91 inline void readIpcArg(std::istream& stream, sal_Int16& value)
93 stream >> value;
94 stream.ignore(); // skip space
97 inline void readIpcArg(std::istream& stream, sal_uIntPtr& value)
99 stream >> value;
100 stream.ignore(); // skip space
103 #if SAL_TYPES_SIZEOFPOINTER == 4
104 inline void readIpcArg(std::istream& stream, uint64_t& value)
106 stream >> value;
107 stream.ignore(); // skip space
109 #endif
111 inline void readIpcArgs(std::istream& /*stream*/)
113 // end of arguments, nothing to do
116 template <typename T, typename... Args>
117 inline void readIpcArgs(std::istream& stream, T& arg, Args&... args)
119 readIpcArg(stream, arg);
120 readIpcArgs(stream, args...);
123 void sendIpcArg(std::ostream& stream, const OUString& string);
124 void sendIpcArg(std::ostream& stream, const QString& string);
126 inline void sendIpcStringArg(std::ostream& stream, uint32_t length, const char* string)
128 stream << length << ' ';
129 stream.write(string, length);
130 stream << ' ';
133 inline void sendIpcArg(std::ostream& stream, Commands value)
135 stream << static_cast<uint16_t>(value) << ' ';
138 void sendIpcArg(std::ostream&, sal_Bool) = delete;
140 inline void sendIpcArg(std::ostream& stream, bool value) { stream << value << ' '; }
142 inline void sendIpcArg(std::ostream& stream, sal_Int16 value) { stream << value << ' '; }
144 inline void sendIpcArg(std::ostream& stream, sal_uIntPtr value) { stream << value << ' '; }
146 #if SAL_TYPES_SIZEOFPOINTER == 4
147 inline void sendIpcArg(std::ostream& stream, uint64_t value) { stream << value << ' '; }
148 #endif
150 inline void sendIpcArgsImpl(std::ostream& stream)
152 // end of arguments, flush stream
153 stream << std::endl;
156 template <typename T, typename... Args>
157 inline void sendIpcArgsImpl(std::ostream& stream, const T& arg, const Args&... args)
159 sendIpcArg(stream, arg);
160 sendIpcArgsImpl(stream, args...);
163 template <typename T, typename... Args>
164 inline void sendIpcArgs(std::ostream& stream, const T& arg, const Args&... args)
166 sendIpcArgsImpl(stream, arg, args...);
167 #ifdef DEBUG_FILEPICKER_IPC
168 std::cerr << "IPC MSG: ";
169 sendIpcArgsImpl(std::cerr, arg, args...);
170 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */