xref: /aoo42x/main/binaryurp/source/marshal.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_MARSHAL_HXX
29 #define INCLUDED_BINARYURP_SOURCE_MARSHAL_HXX
30 
31 #include "sal/config.h"
32 
33 #include <vector>
34 
35 #include "boost/noncopyable.hpp"
36 #include "rtl/byteseq.hxx"
37 #include "rtl/ref.hxx"
38 #include "rtl/ustring.hxx"
39 #include "sal/types.h"
40 #include "typelib/typedescription.hxx"
41 
42 namespace binaryurp {
43     class BinaryAny;
44     class Bridge;
45     struct WriterState;
46 }
47 
48 namespace binaryurp {
49 
50 class Marshal: private boost::noncopyable {
51 public:
52     Marshal(rtl::Reference< Bridge > const & bridge, WriterState & state);
53 
54     ~Marshal();
55 
56     static void write8(std::vector< unsigned char > * buffer, sal_uInt8 value);
57 
58     static void write16(
59         std::vector< unsigned char > * buffer, sal_uInt16 value);
60 
61     static void write32(
62         std::vector< unsigned char > * buffer, sal_uInt32 value);
63 
64     void writeValue(
65         std::vector< unsigned char > * buffer,
66         com::sun::star::uno::TypeDescription const & type,
67         BinaryAny const & value);
68 
69     void writeType(
70         std::vector< unsigned char > * buffer,
71         com::sun::star::uno::TypeDescription const & value);
72 
73     void writeOid(
74         std::vector< unsigned char > * buffer, rtl::OUString const & oid);
75 
76     void writeTid(
77         std::vector< unsigned char > * buffer, rtl::ByteSequence const & tid);
78 
79 private:
80     void writeValue(
81         std::vector< unsigned char > * buffer,
82         com::sun::star::uno::TypeDescription const & type, void const * value);
83 
84     void writeMemberValues(
85         std::vector< unsigned char > * buffer,
86         com::sun::star::uno::TypeDescription const & type,
87         void const * aggregateValue);
88 
89     rtl::Reference< Bridge > bridge_;
90     WriterState & state_;
91 };
92 
93 }
94 
95 #endif
96