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 _AUTO_BUFFER_HXX_ 25 #define _AUTO_BUFFER_HXX_ 26 27 //------------------------------------------------------------------------ 28 // includes 29 //------------------------------------------------------------------------ 30 31 #include <sal/types.h> 32 #include <rtl/ustring.hxx> 33 34 //------------------------------------------------------------- 35 // A simple unicode buffer management class, the class itself 36 // is responsible for the allocated unicode buffer, any 37 // modification of the buffer size outside the class may lead 38 // to undefined behaviour 39 //------------------------------------------------------------- 40 41 class CAutoUnicodeBuffer 42 { 43 public: 44 45 // if bLazyCreation is true the buffer will be created 46 // when someone wants to fill the buffer 47 CAutoUnicodeBuffer( size_t size, sal_Bool bLazyCreation = sal_False ); 48 ~CAutoUnicodeBuffer( ); 49 50 // resizes the buffer 51 sal_Bool SAL_CALL resize( size_t new_size ); 52 53 // zeros the buffer 54 void SAL_CALL empty( ); 55 56 // fills the buffer with a given content 57 sal_Bool SAL_CALL fill( const sal_Unicode* pContent, size_t nLen ); 58 59 // returns the size of the buffer 60 size_t SAL_CALL size( ) const; 61 62 // conversion operator 63 operator sal_Unicode*( ); 64 65 // address operator 66 sal_Unicode* operator&( ); 67 68 const sal_Unicode* operator&( ) const; 69 70 private: 71 void SAL_CALL init( ); 72 73 private: 74 size_t m_buffSize; // the number of unicode chars 75 sal_Unicode* m_pBuff; 76 }; 77 78 #endif 79