1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
26 #include <sal/types.h>
27 #include <com/sun/star/uno/Sequence.hxx>
29 // #define DEBUG_FILEPICKER_IPC
37 enum class Commands
: uint16_t
42 SetMultiSelectionMode
,
61 inline std::vector
<char> readIpcStringArg(std::istream
& stream
)
65 stream
.ignore(); // skip space separator
66 std::vector
<char> buffer(length
, '\0');
67 stream
.read(buffer
.data(), length
);
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
)
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
)
88 stream
.ignore(); // skip space
91 inline void readIpcArg(std::istream
& stream
, sal_Int16
& value
)
94 stream
.ignore(); // skip space
97 inline void readIpcArg(std::istream
& stream
, sal_uIntPtr
& value
)
100 stream
.ignore(); // skip space
103 #if SAL_TYPES_SIZEOFPOINTER == 4
104 inline void readIpcArg(std::istream
& stream
, uint64_t& value
)
107 stream
.ignore(); // skip space
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
);
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
<< ' '; }
150 inline void sendIpcArgsImpl(std::ostream
& stream
)
152 // end of arguments, flush stream
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
...);
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */