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