My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
byteseq.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _RTL_BYTESEQ_HXX_
29 #define _RTL_BYTESEQ_HXX_
30 
31 #include <osl/interlck.h>
32 #include <rtl/byteseq.h>
33 #include <rtl/alloc.h>
34 #include <rtl/memory.h>
35 
36 #if ! defined EXCEPTIONS_OFF
37 #include <new>
38 #endif
39 
40 
41 namespace rtl
42 {
43 
44 //__________________________________________________________________________________________________
46  : _pSequence( 0 )
47 {
48  ::rtl_byte_sequence_construct( &_pSequence, 0 );
49 }
50 //__________________________________________________________________________________________________
52  : _pSequence( 0 )
53 {
54  ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
55 }
56 //__________________________________________________________________________________________________
58  : _pSequence( pSequence )
59 {
60  ::rtl_byte_sequence_acquire( pSequence );
61 }
62 //__________________________________________________________________________________________________
63 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
64  : _pSequence( 0 )
65 {
66  ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
67 #if ! defined EXCEPTIONS_OFF
68  if (_pSequence == 0)
69  throw ::std::bad_alloc();
70 #endif
71 }
72 //__________________________________________________________________________________________________
74  : _pSequence( 0 )
75 {
76  ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
77 #if ! defined EXCEPTIONS_OFF
78  if (_pSequence == 0)
79  throw ::std::bad_alloc();
80 #endif
81 }
82 //__________________________________________________________________________________________________
84  : _pSequence( pSequence )
85 {
86 }
87 //__________________________________________________________________________________________________
88 inline ByteSequence::ByteSequence( sal_Int32 len )
89  : _pSequence( 0 )
90 {
91  ::rtl_byte_sequence_construct( &_pSequence, len );
92 #if ! defined EXCEPTIONS_OFF
93  if (_pSequence == 0)
94  throw ::std::bad_alloc();
95 #endif
96 }
97 //__________________________________________________________________________________________________
99 {
100  ::rtl_byte_sequence_release( _pSequence );
101 }
102 //__________________________________________________________________________________________________
104 {
105  ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
106  return *this;
107 }
108 //__________________________________________________________________________________________________
110 {
111  return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
112 }
113 //__________________________________________________________________________________________________
115 {
116  ::rtl_byte_sequence_reference2One( &_pSequence );
117 #if ! defined EXCEPTIONS_OFF
118  if (_pSequence == 0)
119  throw ::std::bad_alloc();
120 #endif
121  return (sal_Int8 *)_pSequence->elements;
122 }
123 //__________________________________________________________________________________________________
124 inline void ByteSequence::realloc( sal_Int32 nSize )
125 {
126  ::rtl_byte_sequence_realloc( &_pSequence, nSize );
127 #if ! defined EXCEPTIONS_OFF
128  if (_pSequence == 0)
129  throw ::std::bad_alloc();
130 #endif
131 }
132 //__________________________________________________________________________________________________
133 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
134 {
135  return getArray()[ nIndex ];
136 }
137 //__________________________________________________________________________________________________
139 {
140  return (! operator == ( rSeq ));
141 }
142 
143 }
144 #endif
145 
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */