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