1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _COMPHELPER_BASIC_IO_HXX_
25 #define _COMPHELPER_BASIC_IO_HXX_
26 
27 #include <com/sun/star/io/XPersistObject.hpp>
28 #include <com/sun/star/awt/FontDescriptor.hpp>
29 #include "comphelper/comphelperdllapi.h"
30 
31 //.........................................................................
32 namespace comphelper
33 {
34 //.........................................................................
35 
36 namespace stario	= ::com::sun::star::io;
37 namespace staruno	= ::com::sun::star::uno;
38 namespace starawt	= ::com::sun::star::awt;
39 
40 // sal_Bool
41 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Bool& _rVal);
42 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Bool _bVal);
43 
44 // ::rtl::OUString
45 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, ::rtl::OUString& _rStr);
46 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, const ::rtl::OUString& _rStr);
47 
48 // sal_Int16
49 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Int16& _rValue);
50 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Int16 _nValue);
51 
52 // sal_uInt16
53 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_uInt16& _rValue);
54 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_uInt16 _nValue);
55 
56 // sal_uInt32
57 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_uInt32& _rValue);
58 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_uInt32 _nValue);
59 
60 // sal_Int16
61 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, sal_Int32& _rValue);
62 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, sal_Int32 _nValue);
63 
64 // FontDescriptor
65 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& InStream, starawt::FontDescriptor& rVal);
66 COMPHELPER_DLLPUBLIC const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& OutStream, const starawt::FontDescriptor& rVal);
67 
68 // sequences
69 template <class ELEMENT>
operator >>(const staruno::Reference<stario::XObjectInputStream> & _rxInStream,staruno::Sequence<ELEMENT> & _rSeq)70 const staruno::Reference<stario::XObjectInputStream>& operator >> (const staruno::Reference<stario::XObjectInputStream>& _rxInStream, staruno::Sequence<ELEMENT>& _rSeq)
71 {
72 	sal_Int32 nLen = _rxInStream->readLong();
73 	_rSeq.realloc(nLen);
74 	if (nLen)
75 	{
76 		ELEMENT* pElement = _rSeq.getArray();
77 		for (sal_Int32 i=0; i<nLen; ++i, ++pElement)
78 			_rxInStream >> *pElement;
79 	}
80 	return _rxInStream;
81 }
82 
83 template <class ELEMENT>
operator <<(const staruno::Reference<stario::XObjectOutputStream> & _rxOutStream,const staruno::Sequence<ELEMENT> & _rSeq)84 const staruno::Reference<stario::XObjectOutputStream>& operator << (const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream, const staruno::Sequence<ELEMENT>& _rSeq)
85 {
86 	sal_Int32 nLen = _rSeq.getLength();
87 	_rxOutStream->writeLong(nLen);
88 	if (nLen)
89 	{
90 		const ELEMENT* pElement = _rSeq.getConstArray();
91 		for (sal_Int32 i = 0; i < nLen; ++i, ++pElement)
92 			_rxOutStream << *pElement;
93 	}
94 	return _rxOutStream;
95 }
96 
97 //.........................................................................
98 }	// namespace comphelper
99 //.........................................................................
100 
101 #endif // _COMPHELPER_BASIC_IO_HXX_
102 
103