Branch data 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 _COMPHELPER_BASIC_IO_HXX_
21 : : #define _COMPHELPER_BASIC_IO_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 : :
32 : : namespace stario = ::com::sun::star::io;
33 : : namespace staruno = ::com::sun::star::uno;
34 : : namespace starawt = ::com::sun::star::awt;
35 : :
36 : : // sal_Bool
37 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Bool& _rVal);
38 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Bool _bVal);
39 : :
40 : : // ::rtl::OUString
41 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, ::rtl::OUString& _rStr);
42 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, const ::rtl::OUString& _rStr);
43 : :
44 : : // sal_Int16
45 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Int16& _rValue);
46 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Int16 _nValue);
47 : :
48 : : // sal_uInt16
49 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_uInt16& _rValue);
50 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_uInt16 _nValue);
51 : :
52 : : // sal_uInt32
53 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_uInt32& _rValue);
54 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_uInt32 _nValue);
55 : :
56 : : // sal_Int16
57 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Int32& _rValue);
58 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Int32 _nValue);
59 : :
60 : : // FontDescriptor
61 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& InStream, starawt::FontDescriptor& rVal);
62 : : COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& OutStream, const starawt::FontDescriptor& rVal);
63 : :
64 : : // sequences
65 : : template <class ELEMENT>
66 : 8 : const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, staruno::Sequence<ELEMENT>& _rSeq)
67 : : {
68 : 8 : sal_Int32 nLen = _rxInStream->readLong();
69 : 8 : _rSeq.realloc(nLen);
70 [ + + # # ]: 8 : if (nLen)
71 : : {
72 : 4 : ELEMENT* pElement = _rSeq.getArray();
73 [ + + ][ # # ]: 12 : for (sal_Int32 i=0; i<nLen; ++i, ++pElement)
74 : 8 : _rxInStream >> *pElement;
75 : : }
76 : 8 : return _rxInStream;
77 : : }
78 : :
79 : : template <class ELEMENT>
80 : 8 : const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, const staruno::Sequence<ELEMENT>& _rSeq)
81 : : {
82 : 8 : sal_Int32 nLen = _rSeq.getLength();
83 : 8 : _rxOutStream->writeLong(nLen);
84 [ + + # # ]: 8 : if (nLen)
85 : : {
86 : 4 : const ELEMENT* pElement = _rSeq.getConstArray();
87 [ + + ][ # # ]: 12 : for (sal_Int32 i = 0; i < nLen; ++i, ++pElement)
88 : 8 : _rxOutStream << *pElement;
89 : : }
90 : 8 : return _rxOutStream;
91 : : }
92 : :
93 : : //.........................................................................
94 : : } // namespace comphelper
95 : : //.........................................................................
96 : :
97 : : #endif // _COMPHELPER_BASIC_IO_HXX_
98 : :
99 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|