xref: /aoo41x/main/binaryurp/source/unmarshal.hxx (revision cdf0e10c)
1 /*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2011 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27 
28 #ifndef INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX
29 #define INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX
30 
31 #include "sal/config.h"
32 
33 #include <vector>
34 
35 #include "boost/noncopyable.hpp"
36 #include "com/sun/star/uno/Sequence.hxx"
37 #include "rtl/ref.hxx"
38 #include "sal/types.h"
39 #include "typelib/typedescription.hxx"
40 
41 namespace binaryurp {
42     class BinaryAny;
43     class Bridge;
44     struct ReaderState;
45 }
46 namespace com { namespace sun { namespace star { namespace uno {
47     class TypeDescription;
48 } } } }
49 namespace rtl {
50     class ByteSequecne;
51     class OUString;
52 }
53 
54 namespace binaryurp {
55 
56 class Unmarshal: private boost::noncopyable {
57 public:
58     Unmarshal(
59         rtl::Reference< Bridge > const & bridge, ReaderState & state,
60         com::sun::star::uno::Sequence< sal_Int8 > const & buffer);
61 
62     ~Unmarshal();
63 
64     sal_uInt8 read8();
65 
66     sal_uInt16 read16();
67 
68     sal_uInt32 read32();
69 
70     com::sun::star::uno::TypeDescription readType();
71 
72     rtl::OUString readOid();
73 
74     rtl::ByteSequence readTid();
75 
76     BinaryAny readValue(com::sun::star::uno::TypeDescription const & type);
77 
78     void done() const;
79 
80 private:
81     void check(sal_Int32 size) const;
82 
83     sal_uInt32 readCompressed();
84 
85     sal_uInt16 readCacheIndex();
86 
87     sal_uInt64 read64();
88 
89     rtl::OUString readString();
90 
91     BinaryAny readSequence(com::sun::star::uno::TypeDescription const & type);
92 
93     void readMemberValues(
94         com::sun::star::uno::TypeDescription const & type,
95         std::vector< BinaryAny > * values);
96 
97     rtl::Reference< Bridge > bridge_;
98     ReaderState & state_;
99     com::sun::star::uno::Sequence< sal_Int8 > buffer_;
100     sal_uInt8 const * data_;
101     sal_uInt8 const * end_;
102 };
103 
104 }
105 
106 #endif
107