LibreOffice Module tools (master) 1
inetmime.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_TOOLS_INETMIME_HXX
20#define INCLUDED_TOOLS_INETMIME_HXX
21
22#include <tools/toolsdllapi.h>
23#include <rtl/character.hxx>
24#include <rtl/string.hxx>
25#include <rtl/ustring.hxx>
26#include <tools/debug.hxx>
27
28#include <unordered_map>
29
31{
35 OString m_sCharset;
36
40 OString m_sLanguage;
41
59 OUString m_sValue;
60
66};
67
73typedef std::unordered_map<OString, INetContentTypeParameter>
75
76
78{
79public:
87 static inline bool isVisible(sal_uInt32 nChar);
88
97 static bool isAtomChar(sal_uInt32 nChar);
98
108 static bool isIMAPAtomChar(sal_uInt32 nChar);
109
118 static inline int getWeight(sal_uInt32 nChar);
119
128 static inline int getHexWeight(sal_uInt32 nChar);
129
144 static bool equalIgnoreCase(const sal_Unicode * pBegin1,
145 const sal_Unicode * pEnd1,
146 const char * pString2);
147
148 static bool scanUnsigned(const sal_Unicode *& rBegin,
149 const sal_Unicode * pEnd, bool bLeadingZeroes,
150 sal_uInt32 & rValue);
151
182 static sal_Unicode const * scanContentType(
183 std::u16string_view rStr,
184 OUString * pType = nullptr, OUString * pSubType = nullptr,
185 INetContentTypeParameterList * pParameters = nullptr);
186
187 static OUString decodeHeaderFieldBody(const OString& rBody);
188
202 static inline sal_uInt32 getUTF32Character(const sal_Unicode *& rBegin,
203 const sal_Unicode * pEnd);
204};
205
206// static
207inline bool INetMIME::isVisible(sal_uInt32 nChar)
208{
209 return nChar >= '!' && nChar <= '~';
210}
211
212// static
213inline int INetMIME::getWeight(sal_uInt32 nChar)
214{
215 return rtl::isAsciiDigit(nChar) ? int(nChar - '0') : -1;
216}
217
218// static
219inline int INetMIME::getHexWeight(sal_uInt32 nChar)
220{
221 return rtl::isAsciiDigit(nChar) ? int(nChar - '0') :
222 nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) :
223 nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1;
224}
225
226// static
227inline sal_uInt32 INetMIME::getUTF32Character(const sal_Unicode *& rBegin,
228 const sal_Unicode * pEnd)
229{
230 assert(rBegin && rBegin < pEnd &&
231 "INetMIME::getUTF32Character(): Bad sequence");
232 sal_uInt32 nUTF32 = *rBegin++;
233 if (rBegin < pEnd && rtl::isHighSurrogate(nUTF32) && rtl::isLowSurrogate(rBegin[0]))
234 nUTF32 = rtl::combineSurrogates(nUTF32, *rBegin++);
235 return nUTF32;
236}
237
238
239#endif
240
241/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool isVisible(sal_uInt32 nChar)
Check for US-ASCII visible character.
Definition: inetmime.hxx:207
static sal_uInt32 getUTF32Character(const sal_Unicode *&rBegin, const sal_Unicode *pEnd)
Get the UTF-32 character at the head of a UTF-16 encoded string.
Definition: inetmime.hxx:227
static int getHexWeight(sal_uInt32 nChar)
Get the hexadecimal digit weight of a US-ASCII character.
Definition: inetmime.hxx:219
static int getWeight(sal_uInt32 nChar)
Get the digit weight of a US-ASCII character.
Definition: inetmime.hxx:213
std::unordered_map< OString, INetContentTypeParameter > INetContentTypeParameterList
The key is the name of the attribute, in US-ASCII encoding and converted to lower case.
Definition: inetmime.hxx:74
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
bool m_bConverted
This is true if the value is successfully converted to Unicode, and false if the value is a special m...
Definition: inetmime.hxx:65
OString m_sLanguage
The optional language specification (see RFC 2231), in US-ASCII encoding and converted to lower case.
Definition: inetmime.hxx:40
OString m_sCharset
The optional character set specification (see RFC 2231), in US-ASCII encoding and converted to lower ...
Definition: inetmime.hxx:35
OUString m_sValue
The attribute value.
Definition: inetmime.hxx:59
#define TOOLS_DLLPUBLIC
Definition: toolsdllapi.h:28
sal_uInt16 sal_Unicode
#define SAL_WARN_UNUSED