1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "AutoBuffer.hxx"
21 #include <osl/diagnose.h>
24 #pragma warning(push, 1)
31 //------------------------------------------------------------------------
32 // namespace directives
33 //------------------------------------------------------------------------
36 //------------------------------------------------------------------------
38 //------------------------------------------------------------------------
40 CAutoUnicodeBuffer::CAutoUnicodeBuffer( size_t nSize
, sal_Bool bLazyCreation
) :
48 //------------------------------------------------------------------------
50 //------------------------------------------------------------------------
52 CAutoUnicodeBuffer::~CAutoUnicodeBuffer( )
57 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
61 sal_Bool SAL_CALL
CAutoUnicodeBuffer::resize( size_t new_size
)
63 if ( new_size
!= m_buffSize
)
65 if ( new_size
> m_buffSize
)
71 m_buffSize
= new_size
;
77 //------------------------------------------------------------------------
79 //------------------------------------------------------------------------
81 void SAL_CALL
CAutoUnicodeBuffer::empty( )
84 ZeroMemory( m_pBuff
, m_buffSize
* sizeof( sal_Unicode
) );
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
91 sal_Bool SAL_CALL
CAutoUnicodeBuffer::fill( const sal_Unicode
* pContent
, size_t nLen
)
93 OSL_ASSERT( pContent
&& m_buffSize
&& (m_buffSize
>= nLen
) );
97 sal_Bool bRet
= sal_False
;
99 if ( m_pBuff
&& pContent
&& nLen
)
101 CopyMemory( m_pBuff
, pContent
, nLen
* sizeof( sal_Unicode
) );
108 //------------------------------------------------------------------------
110 //------------------------------------------------------------------------
112 size_t SAL_CALL
CAutoUnicodeBuffer::size( ) const
117 //------------------------------------------------------------------------
119 //------------------------------------------------------------------------
121 CAutoUnicodeBuffer::operator sal_Unicode
*( )
126 //------------------------------------------------------------------------
128 //------------------------------------------------------------------------
130 sal_Unicode
* CAutoUnicodeBuffer::operator&( )
135 //------------------------------------------------------------------------
137 //------------------------------------------------------------------------
139 const sal_Unicode
* CAutoUnicodeBuffer::operator&( ) const
144 //------------------------------------------------------------------------
146 //------------------------------------------------------------------------
148 void SAL_CALL
CAutoUnicodeBuffer::init( )
150 if ( !m_pBuff
&& (m_buffSize
> 0) )
151 m_pBuff
= new sal_Unicode
[ m_buffSize
];
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */