Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
widetext_buffer.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fxcrt/widetext_buffer.h"
8
9
#
include
"core/fxcrt/fx_safe_types.h"
10
#
include
"core/fxcrt/span_util.h"
11
12
namespace
fxcrt
{
13
14
size_t
WideTextBuffer::
GetLength
()
const
{
15
return
GetSize() /
sizeof
(
wchar_t
);
16
}
17
18
pdfium
::
span
<
wchar_t
> WideTextBuffer::
GetWideSpan
() {
19
return
reinterpret_span<
wchar_t
>(GetMutableSpan());
20
}
21
22
pdfium
::
span
<
const
wchar_t
> WideTextBuffer::
GetWideSpan
()
const
{
23
return
reinterpret_span<
const
wchar_t
>(GetSpan());
24
}
25
26
WideStringView
WideTextBuffer::
AsStringView
()
const
{
27
return
WideStringView(GetWideSpan());
28
}
29
30
WideString
WideTextBuffer::
MakeString
()
const
{
31
return
WideString(AsStringView());
32
}
33
34
void
WideTextBuffer::
AppendChar
(
wchar_t
ch) {
35
pdfium::span<
wchar_t
> new_span = ExpandWideBuf(1);
36
new_span[0] = ch;
37
}
38
39
void
WideTextBuffer::
Delete
(size_t start_index, size_t count) {
40
DeleteBuf(start_index *
sizeof
(
wchar_t
), count *
sizeof
(
wchar_t
));
41
}
42
43
void
WideTextBuffer::AppendWideString(
WideStringView
str) {
44
AppendSpan(pdfium::as_bytes(str.span()));
45
}
46
47
WideTextBuffer& WideTextBuffer::operator<<(
ByteStringView
ascii) {
48
pdfium::span<
wchar_t
> new_span = ExpandWideBuf(ascii.GetLength());
49
for
(size_t i = 0; i < ascii.GetLength(); ++i)
50
new_span[i] = ascii[i];
51
return
*
this
;
52
}
53
54
WideTextBuffer& WideTextBuffer::operator<<(
WideStringView
str) {
55
AppendWideString(str);
56
return
*
this
;
57
}
58
59
WideTextBuffer& WideTextBuffer::operator<<(
const
WideString
& str) {
60
AppendWideString(str.AsStringView());
61
return
*
this
;
62
}
63
64
WideTextBuffer& WideTextBuffer::operator<<(
const
wchar_t
* lpsz) {
65
AppendWideString(WideStringView(lpsz));
66
return
*
this
;
67
}
68
69
WideTextBuffer& WideTextBuffer::operator<<(
const
WideTextBuffer& buf) {
70
AppendWideString(buf.AsStringView());
71
return
*
this
;
72
}
73
74
pdfium::span<
wchar_t
> WideTextBuffer::ExpandWideBuf(size_t char_count) {
75
size_t original_count = GetLength();
76
FX_SAFE_SIZE_T safe_bytes = char_count;
77
safe_bytes *=
sizeof
(
wchar_t
);
78
size_t bytes = safe_bytes.ValueOrDie();
79
ExpandBuf(bytes);
80
m_DataSize += bytes;
81
return
GetWideSpan().subspan(original_count);
82
}
83
84
}
// namespace fxcrt
fxcrt::WideString
Definition
widestring.h:28
fxcrt::WideTextBuffer::GetWideSpan
pdfium::span< wchar_t > GetWideSpan()
Definition
widetext_buffer.cpp:18
fxcrt::WideTextBuffer::AppendChar
void AppendChar(wchar_t wch)
Definition
widetext_buffer.cpp:34
fxcrt::WideTextBuffer::Delete
void Delete(size_t start_index, size_t count)
Definition
widetext_buffer.cpp:39
fxcrt::WideTextBuffer::GetWideSpan
pdfium::span< const wchar_t > GetWideSpan() const
Definition
widetext_buffer.cpp:22
fxcrt::WideTextBuffer::MakeString
WideString MakeString() const
Definition
widetext_buffer.cpp:30
fxcrt::WideTextBuffer::AsStringView
WideStringView AsStringView() const
Definition
widetext_buffer.cpp:26
fxcrt::WideTextBuffer::GetLength
size_t GetLength() const override
Definition
widetext_buffer.cpp:14
fxcrt
Definition
stl_util.h:17
fxcrt::WideStringView
StringViewTemplate< wchar_t > WideStringView
Definition
string_view_template.h:321
fxcrt::ByteStringView
StringViewTemplate< char > ByteStringView
Definition
string_view_template.h:320
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
widetext_buffer.cpp
Generated on
for Qt by
1.18.0