|
UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * This file is part of the LibreOffice project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * This file incorporates work covered by the following license notice: 00010 * 00011 * Licensed to the Apache Software Foundation (ASF) under one or more 00012 * contributor license agreements. See the NOTICE file distributed 00013 * with this work for additional information regarding copyright 00014 * ownership. The ASF licenses this file to you under the Apache 00015 * License, Version 2.0 (the "License"); you may not use this file 00016 * except in compliance with the License. You may obtain a copy of 00017 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 00018 */ 00019 #ifndef _RTL_BYTESEQ_HXX_ 00020 #define _RTL_BYTESEQ_HXX_ 00021 00022 #include <osl/interlck.h> 00023 #include <rtl/byteseq.h> 00024 #include <rtl/alloc.h> 00025 00026 #if ! defined EXCEPTIONS_OFF 00027 #include <new> 00028 #endif 00029 00030 00031 namespace rtl 00032 { 00033 00034 //__________________________________________________________________________________________________ 00035 inline ByteSequence::ByteSequence() SAL_THROW(()) 00036 : _pSequence( 0 ) 00037 { 00038 ::rtl_byte_sequence_construct( &_pSequence, 0 ); 00039 } 00040 //__________________________________________________________________________________________________ 00041 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(()) 00042 : _pSequence( 0 ) 00043 { 00044 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence ); 00045 } 00046 //__________________________________________________________________________________________________ 00047 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(()) 00048 : _pSequence( pSequence ) 00049 { 00050 ::rtl_byte_sequence_acquire( pSequence ); 00051 } 00052 //__________________________________________________________________________________________________ 00053 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len ) 00054 : _pSequence( 0 ) 00055 { 00056 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len ); 00057 #if ! defined EXCEPTIONS_OFF 00058 if (_pSequence == 0) 00059 throw ::std::bad_alloc(); 00060 #endif 00061 } 00062 //__________________________________________________________________________________________________ 00063 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault ) 00064 : _pSequence( 0 ) 00065 { 00066 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len ); 00067 #if ! defined EXCEPTIONS_OFF 00068 if (_pSequence == 0) 00069 throw ::std::bad_alloc(); 00070 #endif 00071 } 00072 //__________________________________________________________________________________________________ 00073 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(()) 00074 : _pSequence( pSequence ) 00075 { 00076 } 00077 //__________________________________________________________________________________________________ 00078 inline ByteSequence::ByteSequence( sal_Int32 len ) 00079 : _pSequence( 0 ) 00080 { 00081 ::rtl_byte_sequence_construct( &_pSequence, len ); 00082 #if ! defined EXCEPTIONS_OFF 00083 if (_pSequence == 0) 00084 throw ::std::bad_alloc(); 00085 #endif 00086 } 00087 //__________________________________________________________________________________________________ 00088 inline ByteSequence::~ByteSequence() SAL_THROW(()) 00089 { 00090 ::rtl_byte_sequence_release( _pSequence ); 00091 } 00092 //__________________________________________________________________________________________________ 00093 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(()) 00094 { 00095 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence ); 00096 return *this; 00097 } 00098 //__________________________________________________________________________________________________ 00099 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(()) 00100 { 00101 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence ); 00102 } 00103 //__________________________________________________________________________________________________ 00104 inline sal_Int8 * ByteSequence::getArray() 00105 { 00106 ::rtl_byte_sequence_reference2One( &_pSequence ); 00107 #if ! defined EXCEPTIONS_OFF 00108 if (_pSequence == 0) 00109 throw ::std::bad_alloc(); 00110 #endif 00111 return (sal_Int8 *)_pSequence->elements; 00112 } 00113 //__________________________________________________________________________________________________ 00114 inline void ByteSequence::realloc( sal_Int32 nSize ) 00115 { 00116 ::rtl_byte_sequence_realloc( &_pSequence, nSize ); 00117 #if ! defined EXCEPTIONS_OFF 00118 if (_pSequence == 0) 00119 throw ::std::bad_alloc(); 00120 #endif 00121 } 00122 //__________________________________________________________________________________________________ 00123 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex ) 00124 { 00125 return getArray()[ nIndex ]; 00126 } 00127 //__________________________________________________________________________________________________ 00128 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(()) 00129 { 00130 return (! operator == ( rSeq )); 00131 } 00132 00133 } 00134 #endif 00135 00136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3