1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AutoBuffer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _AUTO_BUFFER_HXX_
32 #define _AUTO_BUFFER_HXX_
34 //------------------------------------------------------------------------
36 //------------------------------------------------------------------------
38 #include <sal/types.h>
39 #include <rtl/ustring.hxx>
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 //-------------------------------------------------------------
48 class CAutoUnicodeBuffer
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( );
58 sal_Bool SAL_CALL
resize( size_t new_size
);
61 void SAL_CALL
empty( );
63 // fills the buffer with a given content
64 sal_Bool SAL_CALL
fill( const sal_Unicode
* pContent
, size_t nLen
);
66 // returns the size of the buffer
67 size_t SAL_CALL
size( ) const;
69 // conversion operator
70 operator sal_Unicode
*( );
73 sal_Unicode
* operator&( );
75 const sal_Unicode
* operator&( ) const;
78 void SAL_CALL
init( );
81 size_t m_buffSize
; // the number of unicode chars