UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 #ifndef _RTL_BYTESEQ_HXX_ 00029 #define _RTL_BYTESEQ_HXX_ 00030 00031 #include <osl/interlck.h> 00032 #include <rtl/byteseq.h> 00033 #include <rtl/alloc.h> 00034 #include <rtl/memory.h> 00035 00036 #if ! defined EXCEPTIONS_OFF 00037 #include <new> 00038 #endif 00039 00040 00041 namespace rtl 00042 { 00043 00044 //__________________________________________________________________________________________________ 00045 inline ByteSequence::ByteSequence() SAL_THROW(()) 00046 : _pSequence( 0 ) 00047 { 00048 ::rtl_byte_sequence_construct( &_pSequence, 0 ); 00049 } 00050 //__________________________________________________________________________________________________ 00051 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(()) 00052 : _pSequence( 0 ) 00053 { 00054 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence ); 00055 } 00056 //__________________________________________________________________________________________________ 00057 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(()) 00058 : _pSequence( pSequence ) 00059 { 00060 ::rtl_byte_sequence_acquire( pSequence ); 00061 } 00062 //__________________________________________________________________________________________________ 00063 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len ) 00064 : _pSequence( 0 ) 00065 { 00066 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len ); 00067 #if ! defined EXCEPTIONS_OFF 00068 if (_pSequence == 0) 00069 throw ::std::bad_alloc(); 00070 #endif 00071 } 00072 //__________________________________________________________________________________________________ 00073 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault ) 00074 : _pSequence( 0 ) 00075 { 00076 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len ); 00077 #if ! defined EXCEPTIONS_OFF 00078 if (_pSequence == 0) 00079 throw ::std::bad_alloc(); 00080 #endif 00081 } 00082 //__________________________________________________________________________________________________ 00083 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(()) 00084 : _pSequence( pSequence ) 00085 { 00086 } 00087 //__________________________________________________________________________________________________ 00088 inline ByteSequence::ByteSequence( sal_Int32 len ) 00089 : _pSequence( 0 ) 00090 { 00091 ::rtl_byte_sequence_construct( &_pSequence, len ); 00092 #if ! defined EXCEPTIONS_OFF 00093 if (_pSequence == 0) 00094 throw ::std::bad_alloc(); 00095 #endif 00096 } 00097 //__________________________________________________________________________________________________ 00098 inline ByteSequence::~ByteSequence() SAL_THROW(()) 00099 { 00100 ::rtl_byte_sequence_release( _pSequence ); 00101 } 00102 //__________________________________________________________________________________________________ 00103 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(()) 00104 { 00105 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence ); 00106 return *this; 00107 } 00108 //__________________________________________________________________________________________________ 00109 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(()) 00110 { 00111 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence ); 00112 } 00113 //__________________________________________________________________________________________________ 00114 inline sal_Int8 * ByteSequence::getArray() 00115 { 00116 ::rtl_byte_sequence_reference2One( &_pSequence ); 00117 #if ! defined EXCEPTIONS_OFF 00118 if (_pSequence == 0) 00119 throw ::std::bad_alloc(); 00120 #endif 00121 return (sal_Int8 *)_pSequence->elements; 00122 } 00123 //__________________________________________________________________________________________________ 00124 inline void ByteSequence::realloc( sal_Int32 nSize ) 00125 { 00126 ::rtl_byte_sequence_realloc( &_pSequence, nSize ); 00127 #if ! defined EXCEPTIONS_OFF 00128 if (_pSequence == 0) 00129 throw ::std::bad_alloc(); 00130 #endif 00131 } 00132 //__________________________________________________________________________________________________ 00133 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex ) 00134 { 00135 return getArray()[ nIndex ]; 00136 } 00137 //__________________________________________________________________________________________________ 00138 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(()) 00139 { 00140 return (! operator == ( rSeq )); 00141 } 00142 00143 } 00144 #endif 00145 00146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */