1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _AUTO_BUFFER_HXX_ 29 #define _AUTO_BUFFER_HXX_ 30 31 //------------------------------------------------------------------------ 32 // includes 33 //------------------------------------------------------------------------ 34 35 #include <sal/types.h> 36 #include <rtl/ustring.hxx> 37 38 //------------------------------------------------------------- 39 // A simple unicode buffer management class, the class itself 40 // is responsible for the allocated unicode buffer, any 41 // modification of the buffer size outside the class may lead 42 // to undefined behaviour 43 //------------------------------------------------------------- 44 45 class CAutoUnicodeBuffer 46 { 47 public: 48 49 // if bLazyCreation is true the buffer will be created 50 // when someone wants to fill the buffer 51 CAutoUnicodeBuffer( size_t size, sal_Bool bLazyCreation = sal_False ); 52 ~CAutoUnicodeBuffer( ); 53 54 // resizes the buffer 55 sal_Bool SAL_CALL resize( size_t new_size ); 56 57 // zeros the buffer 58 void SAL_CALL empty( ); 59 60 // fills the buffer with a given content 61 sal_Bool SAL_CALL fill( const sal_Unicode* pContent, size_t nLen ); 62 63 // returns the size of the buffer 64 size_t SAL_CALL size( ) const; 65 66 // conversion operator 67 operator sal_Unicode*( ); 68 69 // address operator 70 sal_Unicode* operator&( ); 71 72 const sal_Unicode* operator&( ) const; 73 74 private: 75 void SAL_CALL init( ); 76 77 private: 78 size_t m_buffSize; // the number of unicode chars 79 sal_Unicode* m_pBuff; 80 }; 81 82 #endif 83