xref: /trunk/main/binaryurp/source/unmarshal.hxx (revision 3638366c)
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 INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX
25 #define INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX
26 
27 #include "sal/config.h"
28 
29 #include <vector>
30 
31 #include "boost/noncopyable.hpp"
32 #include "com/sun/star/uno/Sequence.hxx"
33 #include "rtl/ref.hxx"
34 #include "sal/types.h"
35 #include "typelib/typedescription.hxx"
36 
37 namespace binaryurp {
38     class BinaryAny;
39     class Bridge;
40     struct ReaderState;
41 }
42 namespace com { namespace sun { namespace star { namespace uno {
43     class TypeDescription;
44 } } } }
45 namespace rtl {
46     class ByteSequecne;
47     class OUString;
48 }
49 
50 namespace binaryurp {
51 
52 class Unmarshal: private boost::noncopyable {
53 public:
54     Unmarshal(
55         rtl::Reference< Bridge > const & bridge, ReaderState & state,
56         com::sun::star::uno::Sequence< sal_Int8 > const & buffer);
57 
58     ~Unmarshal();
59 
60     sal_uInt8 read8();
61 
62     sal_uInt16 read16();
63 
64     sal_uInt32 read32();
65 
66     com::sun::star::uno::TypeDescription readType();
67 
68     rtl::OUString readOid();
69 
70     rtl::ByteSequence readTid();
71 
72     BinaryAny readValue(com::sun::star::uno::TypeDescription const & type);
73 
74     void done() const;
75 
76 private:
77     void check(sal_Int32 size) const;
78 
79     sal_uInt32 readCompressed();
80 
81     sal_uInt16 readCacheIndex();
82 
83     sal_uInt64 read64();
84 
85     rtl::OUString readString();
86 
87     BinaryAny readSequence(com::sun::star::uno::TypeDescription const & type);
88 
89     void readMemberValues(
90         com::sun::star::uno::TypeDescription const & type,
91         std::vector< BinaryAny > * values);
92 
93     rtl::Reference< Bridge > bridge_;
94     ReaderState & state_;
95     com::sun::star::uno::Sequence< sal_Int8 > buffer_;
96     sal_uInt8 const * data_;
97     sal_uInt8 const * end_;
98 };
99 
100 }
101 
102 #endif
103