Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sal / rtl / ustrbuf.cxx
blobc91834cfa78318bc3f5b29556dab241e9bb2c0e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <string.h>
22 #include <osl/interlck.h>
23 #include <osl/diagnose.h>
24 #include <rtl/character.hxx>
25 #include <rtl/ustrbuf.hxx>
26 #include "strimp.hxx"
28 #if USE_SDT_PROBES
29 #define RTL_LOG_STRING_BITS 16
30 #endif
32 #include "strtmpl.hxx"
34 void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr,
35 const sal_Unicode * value,
36 sal_Int32 count)
38 rtl::str::stringbuffer_newFromStr_WithLength(newStr, value, count);
41 rtl_uString * SAL_CALL rtl_uStringBuffer_refReturn( rtl_uString * pThis )
43 RTL_LOG_STRING_NEW( pThis );
44 rtl::str::acquire( pThis );
45 return pThis;
48 rtl_uString * SAL_CALL rtl_uStringBuffer_makeStringAndClear( rtl_uString ** ppThis,
49 sal_Int32 *nCapacity )
51 assert(ppThis);
52 assert(nCapacity);
53 // avoid an un-necessary atomic ref/unref pair
54 rtl_uString *pStr = *ppThis;
55 *ppThis = nullptr;
57 rtl::str::new_(ppThis);
58 *nCapacity = 0;
60 RTL_LOG_STRING_NEW( pStr );
62 return pStr;
65 sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr,
66 sal_Int32 capacity,
67 rtl_uString * oldStr )
69 return rtl::str::stringbuffer_newFromStringBuffer(newStr, capacity, oldStr);
72 void SAL_CALL rtl_uStringbuffer_ensureCapacity
73 (rtl_uString ** This, sal_Int32* capacity, sal_Int32 minimumCapacity)
75 rtl::str::stringbuffer_ensureCapacity(This, capacity, minimumCapacity);
78 void SAL_CALL rtl_uStringbuffer_insert( rtl_uString ** This,
79 sal_Int32 * capacity,
80 sal_Int32 offset,
81 const sal_Unicode * str,
82 sal_Int32 len)
84 rtl::str::stringbuffer_insert(This, capacity, offset, str, len);
87 void rtl_uStringbuffer_insertUtf32(
88 rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c)
89 SAL_THROW_EXTERN_C()
91 sal_Unicode buf[2];
92 sal_Int32 len = rtl::splitSurrogates(c, buf);
93 rtl::str::stringbuffer_insert(pThis, capacity, offset, buf, len);
96 void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This,
97 /*inout*/sal_Int32 * capacity,
98 sal_Int32 offset,
99 const char * str,
100 sal_Int32 len)
102 rtl::str::stringbuffer_insert(This, capacity, offset, str, len);
105 /*************************************************************************
106 * rtl_uStringbuffer_remove
108 void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This,
109 sal_Int32 start,
110 sal_Int32 len )
112 rtl::str::stringbuffer_remove(This, start, len);
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */