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 #ifndef INCLUDED_SAL_RTL_STRIMP_HXX
21 #define INCLUDED_SAL_RTL_STRIMP_HXX
23 #include <config_probes.h>
28 #include <sal/types.h>
29 #include <rtl/string.hxx>
30 #include <rtl/ustring.hxx>
32 /* ======================================================================= */
33 /* Help functions for String and UString */
34 /* ======================================================================= */
37 * refCount is opaque and includes 2 bit-fields;
38 * MSB: 'interned' - is stored in the intern hash
39 * MSB-1: 'static' - is a const / static string,
42 #define SAL_STRING_INTERN_FLAG 0x80000000
43 #define SAL_STRING_STATIC_FLAG 0x40000000
44 #define SAL_STRING_REFCOUNT(a) ((a) & 0x3fffffff)
46 #define SAL_STRING_IS_INTERN(a) ((a)->refCount & SAL_STRING_INTERN_FLAG)
47 #define SAL_STRING_IS_STATIC(a) ((a)->refCount & SAL_STRING_STATIC_FLAG)
49 sal_Int16
rtl_ImplGetDigit( sal_Unicode ch
, sal_Int16 nRadix
);
51 bool rtl_ImplIsWhitespace( sal_Unicode c
);
53 rtl_uString
* rtl_uString_ImplAlloc( sal_Int32 nLen
);
55 rtl_String
* rtl_string_ImplAlloc( sal_Int32 nLen
);
59 typedef void *(SAL_CALL
* rtl_allocateStringFn
)(size_t size
);
60 typedef void (*rtl_freeStringFn
)(void *);
64 extern rtl_allocateStringFn rtl_allocateString
;
65 extern rtl_freeStringFn rtl_freeString
;
67 // string lifetime instrumentation / diagnostics
69 # define PROBE_SNAME(n,b) n ## _ ## b
70 # define PROBE_NAME(n,b) PROBE_SNAME(n,b)
71 # define PROBE_NEW PROBE_NAME (new_string,RTL_LOG_STRING_BITS)
72 # define PROBE_DEL PROBE_NAME (delete_string,RTL_LOG_STRING_BITS)
73 # define PROBE_INTERN_NEW PROBE_NAME (new_string_intern,RTL_LOG_STRING_BITS)
74 # define PROBE_INTERN_DEL PROBE_NAME (delete_string_intern,RTL_LOG_STRING_BITS)
75 # define RTL_LOG_STRING_NEW(s) \
76 DTRACE_PROBE4(libreoffice, PROBE_NEW, s, \
77 (s)->refCount, (s)->length, (s)->buffer)
78 # define RTL_LOG_STRING_DELETE(s) \
79 DTRACE_PROBE4(libreoffice, PROBE_DEL, s, \
80 (s)->refCount, (s)->length, (s)->buffer)
81 # define RTL_LOG_STRING_INTERN_NEW(s,o) \
82 DTRACE_PROBE5(libreoffice, PROBE_INTERN_NEW, s, \
83 (s)->refCount, (s)->length, (s)->buffer, o)
84 # define RTL_LOG_STRING_INTERN_DELETE(s) \
85 DTRACE_PROBE4(libreoffice, PROBE_INTERN_DEL, s, \
86 (s)->refCount, (s)->length, (s)->buffer)
88 # define RTL_LOG_STRING_NEW(s)
89 # define RTL_LOG_STRING_DELETE(s)
90 # define RTL_LOG_STRING_INTERN_NEW(s,o)
91 # define RTL_LOG_STRING_INTERN_DELETE(s)
92 #endif /* USE_SDT_PROBES */
94 #endif // INCLUDED_SAL_RTL_STRIMP_HXX
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */