Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_COMPHELPER_BASICIO_HXX
21 : #define INCLUDED_COMPHELPER_BASICIO_HXX
22 :
23 : #include <com/sun/star/io/XPersistObject.hpp>
24 : #include <com/sun/star/awt/FontDescriptor.hpp>
25 : #include <comphelper/comphelperdllapi.h>
26 :
27 :
28 : namespace comphelper
29 : {
30 :
31 : // bool
32 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, bool& _rVal);
33 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, bool _bVal);
34 : void operator <<(
35 : css::uno::Reference<css::io::XObjectOutputStream> const &, sal_Bool)
36 : SAL_DELETED_FUNCTION;
37 :
38 : // OUString
39 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, OUString& _rStr);
40 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, const OUString& _rStr);
41 :
42 : // sal_Int16
43 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_Int16& _rValue);
44 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_Int16 _nValue);
45 :
46 : // sal_uInt16
47 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_uInt16& _rValue);
48 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_uInt16 _nValue);
49 :
50 : // sal_uInt32
51 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_uInt32& _rValue);
52 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_uInt32 _nValue);
53 :
54 : // sal_Int16
55 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_Int32& _rValue);
56 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_Int32 _nValue);
57 :
58 : // FontDescriptor
59 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& InStream, css::awt::FontDescriptor& rVal);
60 : COMPHELPER_DLLPUBLIC const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& OutStream, const css::awt::FontDescriptor& rVal);
61 :
62 : // sequences
63 : template <class ELEMENT>
64 4 : const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, css::uno::Sequence<ELEMENT>& _rSeq)
65 : {
66 4 : sal_Int32 nLen = _rxInStream->readLong();
67 4 : _rSeq.realloc(nLen);
68 4 : if (nLen)
69 : {
70 2 : ELEMENT* pElement = _rSeq.getArray();
71 6 : for (sal_Int32 i=0; i<nLen; ++i, ++pElement)
72 4 : _rxInStream >> *pElement;
73 : }
74 4 : return _rxInStream;
75 : }
76 :
77 : template <class ELEMENT>
78 4 : const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, const css::uno::Sequence<ELEMENT>& _rSeq)
79 : {
80 4 : sal_Int32 nLen = _rSeq.getLength();
81 4 : _rxOutStream->writeLong(nLen);
82 4 : if (nLen)
83 : {
84 2 : const ELEMENT* pElement = _rSeq.getConstArray();
85 6 : for (sal_Int32 i = 0; i < nLen; ++i, ++pElement)
86 4 : _rxOutStream << *pElement;
87 : }
88 4 : return _rxOutStream;
89 : }
90 :
91 :
92 : } // namespace comphelper
93 :
94 :
95 : #endif // INCLUDED_COMPHELPER_BASICIO_HXX
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|