Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
checked_math_impl.h
Go to the documentation of this file.
1// Copyright 2024 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#ifndef CORE_FXCRT_NUMERICS_CHECKED_MATH_IMPL_H_
6#define CORE_FXCRT_NUMERICS_CHECKED_MATH_IMPL_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include <climits>
12#include <cmath>
13#include <cstdlib>
14#include <limits>
15#include <type_traits>
16
17#include "core/fxcrt/numerics/safe_conversions.h"
18#include "core/fxcrt/numerics/safe_math_shared_impl.h"
19
20namespace pdfium {
21namespace internal {
22
23template <typename T>
24constexpr bool CheckedAddImpl(T x, T y, T* result) {
25 static_assert(std::is_integral<T>::value, "Type must be integral");
26 // Since the value of x+y is undefined if we have a signed type, we compute
27 // it using the unsigned type of the same size.
28 using UnsignedDst = typename std::make_unsigned<T>::type;
29 using SignedDst = typename std::make_signed<T>::type;
30 const UnsignedDst ux = static_cast<UnsignedDst>(x);
31 const UnsignedDst uy = static_cast<UnsignedDst>(y);
32 const UnsignedDst uresult = static_cast<UnsignedDst>(ux + uy);
33 // Addition is valid if the sign of (x + y) is equal to either that of x or
34 // that of y.
35 if (std::is_signed<T>::value
36 ? static_cast<SignedDst>((uresult ^ ux) & (uresult ^ uy)) < 0
37 : uresult < uy) // Unsigned is either valid or underflow.
38 return false;
39 *result = static_cast<T>(uresult);
40 return true;
41}
42
43template <typename T, typename U, class Enable = void>
44struct CheckedAddOp {};
45
46template <typename T, typename U>
48 U,
49 typename std::enable_if<std::is_integral<T>::value &&
50 std::is_integral<U>::value>::type> {
52 template <typename V>
53 static constexpr bool Do(T x, U y, V* result) {
54 if constexpr (CheckedAddFastOp<T, U>::is_supported)
55 return CheckedAddFastOp<T, U>::Do(x, y, result);
56
57 // Double the underlying type up to a full machine word.
59 using Promotion =
62 typename BigEnoughPromotion<T, U>::type,
64 // Fail if either operand is out of range for the promoted type.
65 // TODO(jschuh): This could be made to work for a broader range of values.
68 return false;
69 }
70
71 Promotion presult = {};
72 bool is_valid = true;
74 presult = static_cast<Promotion>(x) + static_cast<Promotion>(y);
75 } else {
76 is_valid = CheckedAddImpl(static_cast<Promotion>(x),
77 static_cast<Promotion>(y), &presult);
78 }
80 return false;
81 *result = static_cast<V>(presult);
82 return true;
83 }
84};
85
86template <typename T>
87constexpr bool CheckedSubImpl(T x, T y, T* result) {
88 static_assert(std::is_integral<T>::value, "Type must be integral");
89 // Since the value of x+y is undefined if we have a signed type, we compute
90 // it using the unsigned type of the same size.
91 using UnsignedDst = typename std::make_unsigned<T>::type;
92 using SignedDst = typename std::make_signed<T>::type;
93 const UnsignedDst ux = static_cast<UnsignedDst>(x);
94 const UnsignedDst uy = static_cast<UnsignedDst>(y);
95 const UnsignedDst uresult = static_cast<UnsignedDst>(ux - uy);
96 // Subtraction is valid if either x and y have same sign, or (x-y) and x have
97 // the same sign.
98 if (std::is_signed<T>::value
99 ? static_cast<SignedDst>((uresult ^ ux) & (ux ^ uy)) < 0
100 : x < y)
101 return false;
102 *result = static_cast<T>(uresult);
103 return true;
104}
105
106template <typename T, typename U, class Enable = void>
107struct CheckedSubOp {};
108
109template <typename T, typename U>
111 U,
112 typename std::enable_if<std::is_integral<T>::value &&
113 std::is_integral<U>::value>::type> {
115 template <typename V>
116 static constexpr bool Do(T x, U y, V* result) {
117 if constexpr (CheckedSubFastOp<T, U>::is_supported)
118 return CheckedSubFastOp<T, U>::Do(x, y, result);
119
120 // Double the underlying type up to a full machine word.
122 using Promotion =
125 typename BigEnoughPromotion<T, U>::type,
127 // Fail if either operand is out of range for the promoted type.
128 // TODO(jschuh): This could be made to work for a broader range of values.
131 return false;
132 }
133
134 Promotion presult = {};
135 bool is_valid = true;
137 presult = static_cast<Promotion>(x) - static_cast<Promotion>(y);
138 } else {
139 is_valid = CheckedSubImpl(static_cast<Promotion>(x),
140 static_cast<Promotion>(y), &presult);
141 }
143 return false;
144 *result = static_cast<V>(presult);
145 return true;
146 }
147};
148
149template <typename T>
150constexpr bool CheckedMulImpl(T x, T y, T* result) {
151 static_assert(std::is_integral<T>::value, "Type must be integral");
152 // Since the value of x*y is potentially undefined if we have a signed type,
153 // we compute it using the unsigned type of the same size.
154 using UnsignedDst = typename std::make_unsigned<T>::type;
155 using SignedDst = typename std::make_signed<T>::type;
156 const UnsignedDst ux = SafeUnsignedAbs(x);
157 const UnsignedDst uy = SafeUnsignedAbs(y);
158 const UnsignedDst uresult = static_cast<UnsignedDst>(ux * uy);
159 const bool is_negative =
160 std::is_signed<T>::value && static_cast<SignedDst>(x ^ y) < 0;
161 // We have a fast out for unsigned identity or zero on the second operand.
162 // After that it's an unsigned overflow check on the absolute value, with
163 // a +1 bound for a negative result.
164 if (uy > UnsignedDst(!std::is_signed<T>::value || is_negative) &&
165 ux > (std::numeric_limits<T>::max() + UnsignedDst(is_negative)) / uy)
166 return false;
167 *result = static_cast<T>(is_negative ? 0 - uresult : uresult);
168 return true;
169}
170
171template <typename T, typename U, class Enable = void>
172struct CheckedMulOp {};
173
174template <typename T, typename U>
176 U,
177 typename std::enable_if<std::is_integral<T>::value &&
178 std::is_integral<U>::value>::type> {
180 template <typename V>
181 static constexpr bool Do(T x, U y, V* result) {
182 if constexpr (CheckedMulFastOp<T, U>::is_supported)
183 return CheckedMulFastOp<T, U>::Do(x, y, result);
184
185 using Promotion = typename FastIntegerArithmeticPromotion<T, U>::type;
186 // Verify the destination type can hold the result (always true for 0).
189 x && y)) {
190 return false;
191 }
192
193 Promotion presult = {};
194 bool is_valid = true;
196 // The fast op may be available with the promoted type.
197 // The casts here are safe because of the "value in range" conditional
198 // above.
200 static_cast<Promotion>(x), static_cast<Promotion>(y), &presult);
201 } else if (IsIntegerArithmeticSafe<Promotion, T, U>::value) {
202 presult = static_cast<Promotion>(x) * static_cast<Promotion>(y);
203 } else {
204 is_valid = CheckedMulImpl(static_cast<Promotion>(x),
205 static_cast<Promotion>(y), &presult);
206 }
208 return false;
209 *result = static_cast<V>(presult);
210 return true;
211 }
212};
213
214// Division just requires a check for a zero denominator or an invalid negation
215// on signed min/-1.
216template <typename T, typename U, class Enable = void>
217struct CheckedDivOp {};
218
219template <typename T, typename U>
221 U,
222 typename std::enable_if<std::is_integral<T>::value &&
223 std::is_integral<U>::value>::type> {
225 template <typename V>
226 static constexpr bool Do(T x, U y, V* result) {
228 return false;
229
230 // The overflow check can be compiled away if we don't have the exact
231 // combination of types needed to trigger this case.
232 using Promotion = typename BigEnoughPromotion<T, U>::type;
234 (std::is_signed<T>::value && std::is_signed<U>::value &&
236 static_cast<Promotion>(x) ==
238 y == static_cast<U>(-1)))) {
239 return false;
240 }
241
242 // This branch always compiles away if the above branch wasn't removed.
245 x)) {
246 return false;
247 }
248
251 return false;
252 *result = static_cast<V>(presult);
253 return true;
254 }
255};
256
257template <typename T, typename U, class Enable = void>
258struct CheckedModOp {};
259
260template <typename T, typename U>
262 U,
263 typename std::enable_if<std::is_integral<T>::value &&
264 std::is_integral<U>::value>::type> {
266 template <typename V>
267 static constexpr bool Do(T x, U y, V* result) {
269 return false;
270
271 using Promotion = typename BigEnoughPromotion<T, U>::type;
273 (std::is_signed<T>::value && std::is_signed<U>::value &&
275 static_cast<Promotion>(x) ==
277 y == static_cast<U>(-1)))) {
278 *result = 0;
279 return true;
280 }
281
282 const Promotion presult =
283 static_cast<Promotion>(x) % static_cast<Promotion>(y);
285 return false;
286 *result = static_cast<Promotion>(presult);
287 return true;
288 }
289};
290
291template <typename T, typename U, class Enable = void>
292struct CheckedLshOp {};
293
294// Left shift. Shifts less than 0 or greater than or equal to the number
295// of bits in the promoted type are undefined. Shifts of negative values
296// are undefined. Otherwise it is defined when the result fits.
297template <typename T, typename U>
299 U,
300 typename std::enable_if<std::is_integral<T>::value &&
301 std::is_integral<U>::value>::type> {
302 using result_type = T;
303 template <typename V>
304 static constexpr bool Do(T x, U shift, V* result) {
305 // Disallow negative numbers and verify the shift is in bounds.
309 // Shift as unsigned to avoid undefined behavior.
310 *result = static_cast<V>(as_unsigned(x) << shift);
311 // If the shift can be reversed, we know it was valid.
312 return *result >> shift == x;
313 }
314
315 // Handle the legal corner-case of a full-width signed shift of zero.
316 if (!std::is_signed<T>::value || x ||
318 return false;
319 *result = 0;
320 return true;
321 }
322};
323
324template <typename T, typename U, class Enable = void>
325struct CheckedRshOp {};
326
327// Right shift. Shifts less than 0 or greater than or equal to the number
328// of bits in the promoted type are undefined. Otherwise, it is always defined,
329// but a right shift of a negative value is implementation-dependent.
330template <typename T, typename U>
332 U,
333 typename std::enable_if<std::is_integral<T>::value &&
334 std::is_integral<U>::value>::type> {
335 using result_type = T;
336 template <typename V>
337 static constexpr bool Do(T x, U shift, V* result) {
338 // Use sign conversion to push negative values out of range.
341 return false;
342 }
343
344 const T tmp = x >> shift;
346 return false;
347 *result = static_cast<V>(tmp);
348 return true;
349 }
350};
351
352template <typename T, typename U, class Enable = void>
353struct CheckedAndOp {};
354
355// For simplicity we support only unsigned integer results.
356template <typename T, typename U>
358 U,
359 typename std::enable_if<std::is_integral<T>::value &&
360 std::is_integral<U>::value>::type> {
361 using result_type = typename std::make_unsigned<
362 typename MaxExponentPromotion<T, U>::type>::type;
363 template <typename V>
364 static constexpr bool Do(T x, U y, V* result) {
365 const result_type tmp =
366 static_cast<result_type>(x) & static_cast<result_type>(y);
368 return false;
369 *result = static_cast<V>(tmp);
370 return true;
371 }
372};
373
374template <typename T, typename U, class Enable = void>
375struct CheckedOrOp {};
376
377// For simplicity we support only unsigned integers.
378template <typename T, typename U>
380 U,
381 typename std::enable_if<std::is_integral<T>::value &&
382 std::is_integral<U>::value>::type> {
383 using result_type = typename std::make_unsigned<
384 typename MaxExponentPromotion<T, U>::type>::type;
385 template <typename V>
386 static constexpr bool Do(T x, U y, V* result) {
387 const result_type tmp =
388 static_cast<result_type>(x) | static_cast<result_type>(y);
390 return false;
391 *result = static_cast<V>(tmp);
392 return true;
393 }
394};
395
396template <typename T, typename U, class Enable = void>
397struct CheckedXorOp {};
398
399// For simplicity we support only unsigned integers.
400template <typename T, typename U>
402 U,
403 typename std::enable_if<std::is_integral<T>::value &&
404 std::is_integral<U>::value>::type> {
405 using result_type = typename std::make_unsigned<
406 typename MaxExponentPromotion<T, U>::type>::type;
407 template <typename V>
408 static constexpr bool Do(T x, U y, V* result) {
409 const result_type tmp =
410 static_cast<result_type>(x) ^ static_cast<result_type>(y);
412 return false;
413 *result = static_cast<V>(tmp);
414 return true;
415 }
416};
417
418// Max doesn't really need to be implemented this way because it can't fail,
419// but it makes the code much cleaner to use the MathOp wrappers.
420template <typename T, typename U, class Enable = void>
421struct CheckedMaxOp {};
422
423template <typename T, typename U>
425 T,
426 U,
427 typename std::enable_if<std::is_arithmetic<T>::value &&
430 template <typename V>
431 static constexpr bool Do(T x, U y, V* result) {
432 const result_type tmp = IsGreater<T, U>::Test(x, y)
433 ? static_cast<result_type>(x)
434 : static_cast<result_type>(y);
436 return false;
437 *result = static_cast<V>(tmp);
438 return true;
439 }
440};
441
442// Min doesn't really need to be implemented this way because it can't fail,
443// but it makes the code much cleaner to use the MathOp wrappers.
444template <typename T, typename U, class Enable = void>
445struct CheckedMinOp {};
446
447template <typename T, typename U>
449 T,
450 U,
451 typename std::enable_if<std::is_arithmetic<T>::value &&
454 template <typename V>
455 static constexpr bool Do(T x, U y, V* result) {
456 const result_type tmp = IsLess<T, U>::Test(x, y)
457 ? static_cast<result_type>(x)
458 : static_cast<result_type>(y);
460 return false;
461 *result = static_cast<V>(tmp);
462 return true;
463 }
464};
465
466// This is just boilerplate that wraps the standard floating point arithmetic.
467// A macro isn't the nicest solution, but it beats rewriting these repeatedly.
468#define BASE_FLOAT_ARITHMETIC_OPS(NAME, OP)
469 template <typename T, typename U>
470 struct Checked##NAME##Op<
471 T, U,
472 typename std::enable_if<std::is_floating_point<T>::value ||
473 std::is_floating_point<U>::value>::type> {
474 using result_type = typename MaxExponentPromotion<T, U>::type;
475 template <typename V>
476 static constexpr bool Do(T x, U y, V* result) {
477 using Promotion = typename MaxExponentPromotion<T, U>::type;
478 const Promotion presult = x OP y;
479 if (!IsValueInRangeForNumericType<V>(presult))
480 return false;
481 *result = static_cast<V>(presult);
482 return true;
483 }
484 };
485
490
491#undef BASE_FLOAT_ARITHMETIC_OPS
492
493// Floats carry around their validity state with them, but integers do not. So,
494// we wrap the underlying value in a specialization in order to hide that detail
495// and expose an interface via accessors.
501
502template <typename NumericType>
505 std::is_integral<NumericType>::value
507 : (std::is_floating_point<NumericType>::value ? NUMERIC_FLOATING
509};
510
511template <typename T,
514
515// Integrals require quite a bit of additional housekeeping to manage state.
516template <typename T>
518 public:
519 template <typename Src = int>
520 constexpr explicit CheckedNumericState(Src value = 0, bool is_valid = true)
521 : is_valid_(is_valid && IsValueInRangeForNumericType<T>(value)),
522 value_(WellDefinedConversionOrZero(value, is_valid_)) {
523 static_assert(std::is_arithmetic<Src>::value, "Argument must be numeric.");
524 }
525
526 template <typename Src>
527 constexpr CheckedNumericState(const CheckedNumericState<Src>& rhs)
528 : CheckedNumericState(rhs.value(), rhs.is_valid()) {}
529
530 constexpr bool is_valid() const { return is_valid_; }
531
532 constexpr T value() const { return value_; }
533
534 private:
535 // Ensures that a type conversion does not trigger undefined behavior.
536 template <typename Src>
537 static constexpr T WellDefinedConversionOrZero(Src value, bool is_valid) {
538 using SrcType = typename internal::UnderlyingType<Src>::type;
539 return (std::is_integral<SrcType>::value || is_valid)
540 ? static_cast<T>(value)
541 : 0;
542 }
543
544 // is_valid_ precedes value_ because member initializers in the constructors
545 // are evaluated in field order, and is_valid_ must be read when initializing
546 // value_.
547 bool is_valid_;
548 T value_;
549};
550
551// Floating points maintain their own validity, but need translation wrappers.
552template <typename T>
554 public:
555 template <typename Src = double>
556 constexpr explicit CheckedNumericState(Src value = 0.0, bool is_valid = true)
557 : value_(WellDefinedConversionOrNaN(
558 value,
559 is_valid && IsValueInRangeForNumericType<T>(value))) {}
560
561 template <typename Src>
562 constexpr CheckedNumericState(const CheckedNumericState<Src>& rhs)
563 : CheckedNumericState(rhs.value(), rhs.is_valid()) {}
564
565 constexpr bool is_valid() const {
566 // Written this way because std::isfinite is not reliably constexpr.
567 return IsConstantEvaluated()
568 ? value_ <= std::numeric_limits<T>::max() &&
569 value_ >= std::numeric_limits<T>::lowest()
570 : std::isfinite(value_);
571 }
572
573 constexpr T value() const { return value_; }
574
575 private:
576 // Ensures that a type conversion does not trigger undefined behavior.
577 template <typename Src>
578 static constexpr T WellDefinedConversionOrNaN(Src value, bool is_valid) {
579 using SrcType = typename internal::UnderlyingType<Src>::type;
580 return (StaticDstRangeRelationToSrcRange<T, SrcType>::value ==
581 NUMERIC_RANGE_CONTAINED ||
582 is_valid)
583 ? static_cast<T>(value)
584 : std::numeric_limits<T>::quiet_NaN();
585 }
586
587 T value_;
588};
589
590} // namespace internal
591} // namespace pdfium
592
593#endif // CORE_FXCRT_NUMERICS_CHECKED_MATH_IMPL_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
#define DCHECK
Definition check.h:33
#define CHECK_LE(x, y)
Definition check_op.h:14
#define BASE_FLOAT_ARITHMETIC_OPS(NAME, OP)
CPDF_ArrayLocker(RetainPtr< CPDF_Array > pArray)
const_iterator begin() const
Definition cpdf_array.h:185
const_iterator end() const
Definition cpdf_array.h:189
CPDF_ArrayLocker(const CPDF_Array *pArray)
CPDF_ArrayLocker(RetainPtr< const CPDF_Array > pArray)
size_t size() const
Definition cpdf_array.h:41
void Append(RetainPtr< CPDF_Stream > stream)=delete
bool GetBooleanAt(size_t index, bool bDefault) const
void SetAt(size_t index, RetainPtr< CPDF_Object > object)
RetainPtr< CPDF_Dictionary > GetMutableDictAt(size_t index)
RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const override
bool IsEmpty() const
Definition cpdf_array.h:40
RetainPtr< const CPDF_Object > GetDirectObjectAt(size_t index) const
RetainPtr< const CPDF_Stream > GetStreamAt(size_t index) const
Type GetType() const override
CPDF_Array * AsMutableArray() override
RetainPtr< const CPDF_Object > GetObjectAt(size_t index) const
RetainPtr< CPDF_Object > GetMutableObjectAt(size_t index)
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type AppendNew(Args &&... args)
Definition cpdf_array.h:85
WideString GetUnicodeTextAt(size_t index) const
RetainPtr< CPDF_Array > GetMutableArrayAt(size_t index)
RetainPtr< CPDF_Object > Clone() const override
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type AppendNew(Args &&... args)
Definition cpdf_array.h:94
RetainPtr< const CPDF_Dictionary > GetDictAt(size_t index) const
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition cpdf_array.h:29
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type InsertNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:115
bool IsLocked() const
Definition cpdf_array.h:150
RetainPtr< CPDF_Stream > GetMutableStreamAt(size_t index)
bool Contains(const CPDF_Object *pThat) const
void ConvertToIndirectObjectAt(size_t index, CPDF_IndirectObjectHolder *pHolder)
std::optional< size_t > Find(const CPDF_Object *pThat) const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type InsertNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:124
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type SetNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:100
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
RetainPtr< CPDF_Object > GetMutableDirectObjectAt(size_t index)
CFX_Matrix GetMatrix() const
~CPDF_Array() override
int GetIntegerAt(size_t index) const
void SetAt(size_t index, RetainPtr< CPDF_Stream > stream)=delete
void InsertAt(size_t index, RetainPtr< CPDF_Object > object)
ByteString GetByteStringAt(size_t index) const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type SetNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:109
void Append(RetainPtr< CPDF_Object > object)
RetainPtr< const CPDF_String > GetStringAt(size_t index) const
RetainPtr< const CPDF_Array > GetArrayAt(size_t index) const
RetainPtr< const CPDF_Number > GetNumberAt(size_t index) const
CFX_FloatRect GetRect() const
void InsertAt(size_t index, RetainPtr< CPDF_Stream > stream)=delete
void RemoveAt(size_t index)
float GetFloatAt(size_t index) const
CPDF_Creator(CPDF_Document *pDoc, RetainPtr< IFX_RetainableWriteStream > archive)
bool SetFileVersion(int32_t fileVersion)
void RemoveSecurity()
bool Create(uint32_t flags)
CPDF_Dictionary * GetMutableTrailerForTesting()
const CPDF_Dictionary * trailer() const
const ObjectInfo * GetObjectInfo(uint32_t obj_num) const
CPDF_CrossRefTable(RetainPtr< CPDF_Dictionary > trailer, uint32_t trailer_object_number)
void SetFree(uint32_t obj_num, uint16_t gen_num)
void Update(std::unique_ptr< CPDF_CrossRefTable > new_cross_ref)
const std::map< uint32_t, ObjectInfo > & objects_info() const
static std::unique_ptr< CPDF_CrossRefTable > MergeUp(std::unique_ptr< CPDF_CrossRefTable > current, std::unique_ptr< CPDF_CrossRefTable > top)
void AddCompressed(uint32_t obj_num, uint32_t archive_obj_num, uint32_t archive_obj_index)
uint32_t trailer_object_number() const
void AddNormal(uint32_t obj_num, uint16_t gen_num, bool is_object_stream, FX_FILESIZE pos)
void SetTrailer(RetainPtr< CPDF_Dictionary > trailer, uint32_t trailer_object_number)
void SetObjectMapSize(uint32_t size)
CPDF_CryptoHandler(Cipher cipher, pdfium::span< const uint8_t > key)
bool DecryptObjectTree(RetainPtr< CPDF_Object > object)
static bool IsSignatureDictionary(const CPDF_Dictionary *dictionary)
DataVector< uint8_t > EncryptContent(uint32_t objnum, uint32_t gennum, pdfium::span< const uint8_t > source) const
const_iterator end() const
CPDF_DictionaryLocker(const CPDF_Dictionary *pDictionary)
const_iterator begin() const
CPDF_DictionaryLocker(RetainPtr< const CPDF_Dictionary > pDictionary)
CPDF_DictionaryLocker(RetainPtr< CPDF_Dictionary > pDictionary)
Type GetType() const override
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_Stream > GetStreamFor(const ByteString &key) const
RetainPtr< const CPDF_Number > GetNumberFor(const ByteString &key) const
void SetFor(const ByteString &key, RetainPtr< CPDF_Object > object)
ByteString GetByteStringFor(const ByteString &key, const ByteString &default_str) const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type SetNewFor(const ByteString &key, Args &&... args)
RetainPtr< CPDF_Object > RemoveFor(ByteStringView key)
RetainPtr< CPDF_Array > GetOrCreateArrayFor(const ByteString &key)
void SetMatrixFor(const ByteString &key, const CFX_Matrix &matrix)
RetainPtr< CPDF_Stream > GetMutableStreamFor(const ByteString &key)
RetainPtr< CPDF_Object > GetMutableDirectObjectFor(const ByteString &key)
RetainPtr< const CPDF_Dictionary > GetDictFor(const ByteString &key) const
RetainPtr< CPDF_Array > GetMutableArrayFor(const ByteString &key)
float GetFloatFor(const ByteString &key) const
RetainPtr< CPDF_Dictionary > GetOrCreateDictFor(const ByteString &key)
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type SetNewFor(const ByteString &key, Args &&... args)
void ConvertToIndirectObjectFor(const ByteString &key, CPDF_IndirectObjectHolder *pHolder)
WideString GetUnicodeTextFor(const ByteString &key) const
RetainPtr< CPDF_Object > Clone() const override
const CPDF_Dictionary * GetDictInternal() const override
RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *visited) const override
CPDF_Dictionary * AsMutableDictionary() override
std::vector< ByteString > GetKeys() const
bool GetBooleanFor(const ByteString &key, bool bDefault) const
ByteString GetByteStringFor(const ByteString &key) const
int GetDirectIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_String > GetStringFor(const ByteString &key) const
WeakPtr< ByteStringPool > GetByteStringPool() const
void SetRectFor(const ByteString &key, const CFX_FloatRect &rect)
RetainPtr< CPDF_Dictionary > GetMutableDictFor(const ByteString &key)
RetainPtr< const CPDF_Object > GetDirectObjectFor(const ByteString &key) const
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
size_t size() const
RetainPtr< const CPDF_Object > GetObjectFor(const ByteString &key) const
int GetIntegerFor(const ByteString &key, int default_int) const
~CPDF_Dictionary() override
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
bool IsLocked() const
void SetFor(const ByteString &key, RetainPtr< CPDF_Stream > stream)=delete
CFX_FloatRect GetRectFor(const ByteString &key) const
ByteString GetNameFor(const ByteString &key) const
CFX_Matrix GetMatrixFor(const ByteString &key) const
RetainPtr< CPDF_Object > GetMutableObjectFor(const ByteString &key)
void ReplaceKey(const ByteString &oldkey, const ByteString &newkey)
virtual uint32_t DeletePage(int page_index)=0
virtual ~Extension()=default
virtual bool ContainsExtensionForm() const =0
virtual bool ContainsExtensionFullForm() const =0
virtual int GetPageCount() const =0
virtual bool ContainsExtensionForegroundForm() const =0
virtual ~LinkListIface()=default
void SetDocument(CPDF_Document *pDoc)
CPDF_Document * GetDocument() const
virtual void MaybePurgeImage(uint32_t objnum)=0
virtual void ClearStockFont()=0
virtual RetainPtr< CPDF_StreamAcc > GetFontFileStreamAcc(RetainPtr< const CPDF_Stream > pFontStream)=0
virtual void MaybePurgeFontFileStreamAcc(RetainPtr< CPDF_StreamAcc > &&pStreamAcc)=0
void SetDocument(CPDF_Document *pDoc)
CPDF_Document * GetDocument() const
~CPDF_Document() override
bool has_valid_cross_reference_table() const
JBig2_DocumentContext * GetOrCreateCodecContext()
CPDF_Parser::Error LoadLinearizedDoc(RetainPtr< CPDF_ReadValidator > validator, const ByteString &password)
RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum) override
uint32_t GetParsedPageCountForTesting()
bool IsPageLoaded(int iPage) const
RetainPtr< const CPDF_Dictionary > GetPageDictionary(int iPage)
int GetPageCount() const
RetainPtr< CPDF_Dictionary > CreateNewPage(int iPage)
void SetExtension(std::unique_ptr< Extension > pExt)
void SetLinksContext(std::unique_ptr< LinkListIface > pContext)
PageDataIface * GetPageData() const
bool IsModifiedAPStream(const CPDF_Stream *stream) const
RetainPtr< const CPDF_Array > GetFileIdentifier() const
void MaybePurgeImage(uint32_t objnum)
void MaybePurgeFontFileStreamAcc(RetainPtr< CPDF_StreamAcc > &&pStreamAcc)
RetainPtr< CPDF_Dictionary > GetMutableRoot()
RetainPtr< CPDF_Dictionary > GetInfo()
RenderDataIface * GetRenderData() const
LinkListIface * GetLinksContext() const
CPDF_Document(std::unique_ptr< RenderDataIface > pRenderData, std::unique_ptr< PageDataIface > pPageData)
CPDF_Parser::Error LoadDoc(RetainPtr< IFX_SeekableReadStream > pFileAccess, const ByteString &password)
void ResizePageListForTesting(size_t size)
CPDF_Parser * GetParser() const
RetainPtr< CPDF_Dictionary > GetMutablePageDictionary(int iPage)
bool MovePages(pdfium::span< const int > page_indices, int dest_page_index)
int GetPageIndex(uint32_t objnum)
Extension * GetExtension() const
uint32_t GetUserPermissions(bool get_owner_perms) const
void SetPageToNullObject(uint32_t page_obj_num)
RetainPtr< CPDF_StreamAcc > GetFontFileStreamAcc(RetainPtr< const CPDF_Stream > pFontStream)
RetainPtr< CPDF_Stream > CreateModifiedAPStream(RetainPtr< CPDF_Dictionary > dict)
void SetRootForTesting(RetainPtr< CPDF_Dictionary > root)
bool TryInit() override
static bool IsValidPageObject(const CPDF_Object *obj)
const CPDF_Dictionary * GetRoot() const
void SetParser(std::unique_ptr< CPDF_Parser > pParser)
uint32_t DeletePage(int iPage)
static constexpr int kPageMaxNum
void SetPageObjNum(int iPage, uint32_t objNum)
void IncrementParsedPageCount()
CPDF_Encryptor(const CPDF_CryptoHandler *pHandler, int objnum)
DataVector< uint8_t > Encrypt(pdfium::span< const uint8_t > src_data) const
bool WriteDictTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const
pdfium::span< const uint8_t > GetSpan() const
CPDF_FlateEncoder(RetainPtr< const CPDF_Stream > pStream, bool bFlateEncode)
void UpdateLength(size_t size)
RetainPtr< const CPDF_Object > GetIndirectObject(uint32_t objnum) const
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type New(Args &&... args)
RetainPtr< T > NewIndirect(Args &&... args)
RetainPtr< CPDF_Object > GetOrParseIndirectObject(uint32_t objnum)
WeakPtr< ByteStringPool > GetByteStringPool() const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type New(Args &&... args)
virtual RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum)
RetainPtr< CPDF_Object > GetMutableIndirectObject(uint32_t objnum)
uint32_t AddIndirectObject(RetainPtr< CPDF_Object > pObj)
bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, RetainPtr< CPDF_Object > pObj)
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
float GetNumber() const override
bool IsInteger() const
Definition cpdf_number.h:30
int GetInteger() const override
RetainPtr< CPDF_Object > Clone() const override
void SetString(const ByteString &str) override
~CPDF_Number() override
ByteString GetString() const override
CPDF_Number * AsMutableNumber() override
Type GetType() const override
void SetGenNum(uint32_t gennum)
Definition cpdf_object.h:68
RetainPtr< const CPDF_Dictionary > GetDict() const
bool IsInline() const
Definition cpdf_object.h:69
uint32_t GetGenNum() const
Definition cpdf_object.h:67
virtual Type GetType() const =0
virtual WideString GetUnicodeText() const
virtual ByteString GetString() const
RetainPtr< const CPDF_Object > GetDirect() const
uint32_t m_GenNum
bool IsName() const
virtual CPDF_Null * AsMutableNull()
const CPDF_Name * AsName() const
bool IsArray() const
const CPDF_Boolean * AsBoolean() const
virtual void SetString(const ByteString &str)
const CPDF_Null * AsNull() const
bool IsDictionary() const
bool IsStream() const
virtual RetainPtr< CPDF_Reference > MakeReference(CPDF_IndirectObjectHolder *holder) const
RetainPtr< CPDF_Object > GetMutableDirect()
const CPDF_Array * AsArray() const
virtual int GetInteger() const
CPDF_Object()=default
virtual float GetNumber() const
bool IsNull() const
bool IsBoolean() const
uint32_t GetObjNum() const
Definition cpdf_object.h:65
const CPDF_Dictionary * AsDictionary() const
virtual bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const =0
RetainPtr< CPDF_Object > CloneDirectObject() const
virtual CPDF_Stream * AsMutableStream()
bool IsString() const
virtual CPDF_Number * AsMutableNumber()
virtual CPDF_Dictionary * AsMutableDictionary()
virtual RetainPtr< CPDF_Object > Clone() const =0
bool IsNumber() const
virtual CPDF_Reference * AsMutableReference()
uint32_t m_ObjNum
CPDF_Object(const CPDF_Object &src)=delete
const CPDF_Stream * AsStream() const
static constexpr uint32_t kInvalidObjNum
Definition cpdf_object.h:52
virtual const CPDF_Object * GetDirectInternal() const
virtual CPDF_Name * AsMutableName()
bool IsReference() const
void SetObjNum(uint32_t objnum)
Definition cpdf_object.h:66
const CPDF_String * AsString() const
uint64_t KeyForCache() const
virtual CPDF_Array * AsMutableArray()
const CPDF_Reference * AsReference() const
virtual RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const
virtual CPDF_String * AsMutableString()
const CPDF_Number * AsNumber() const
RetainPtr< CPDF_Dictionary > GetMutableDict()
RetainPtr< CPDF_Object > CloneObjectNonCyclic(bool bDirect) const
virtual const CPDF_Dictionary * GetDictInternal() const
~CPDF_Object() override
virtual CPDF_Boolean * AsMutableBoolean()
void SetSyntaxParserForTesting(std::unique_ptr< CPDF_SyntaxParser > parser)
bool RebuildCrossRef()
uint32_t GetPermissions(bool get_owner_perms) const
const CPDF_Dictionary * GetTrailer() const
RetainPtr< CPDF_Object > ParseIndirectObjectAtForTesting(FX_FILESIZE pos)
FX_FILESIZE GetObjectPositionOrZero(uint32_t objnum) const
void SetLinearizedHeaderForTesting(std::unique_ptr< CPDF_LinearizedHeader > pLinearized)
int GetFileVersion() const
Error StartLinearizedParse(RetainPtr< CPDF_ReadValidator > validator, const ByteString &password)
uint32_t GetRootObjNum() const
RetainPtr< const CPDF_Array > GetIDArray() const
RetainPtr< const CPDF_Dictionary > GetEncryptDict() const
std::vector< unsigned int > GetTrailerEnds()
CPDF_Parser(ParsedObjectsHolder *holder)
FX_FILESIZE GetLastXRefOffset() const
Definition cpdf_parser.h:83
bool WriteToArchive(IFX_ArchiveStream *archive, FX_FILESIZE src_size)
const CPDF_LinearizedHeader * GetLinearizedHeader() const
ByteString GetPassword() const
Definition cpdf_parser.h:70
static constexpr size_t kInvalidPos
Definition cpdf_parser.h:59
const CPDF_CrossRefTable * GetCrossRefTableForTesting() const
CPDF_Dictionary * GetMutableTrailerForTesting()
uint32_t GetTrailerObjectNumber() const
static constexpr uint32_t kMaxObjectNumber
Definition cpdf_parser.h:57
bool IsXRefStream() const
uint32_t GetFirstPageNo() const
Error StartParseInternal()
ByteString GetEncodedPassword() const
FX_FILESIZE GetDocumentSize() const
bool IsValidObjectNumber(uint32_t objnum) const
Error StartParse(RetainPtr< IFX_SeekableReadStream > pFile, const ByteString &password)
std::unique_ptr< CPDF_LinearizedHeader > ParseLinearizedHeader()
FX_FILESIZE ParseStartXRef()
bool IsObjectFree(uint32_t objnum) const
RetainPtr< CPDF_Dictionary > GetCombinedTrailer() const
bool LoadCrossRefTable(FX_FILESIZE pos, bool skip)
uint32_t GetLastObjNum() const
const RetainPtr< CPDF_SecurityHandler > & GetSecurityHandler() const
Definition cpdf_parser.h:96
RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum)
uint32_t GetInfoObjNum() const
bool xref_table_rebuilt() const
CPDF_CryptoHandler * GetCryptoHandler() const
bool OnInit(const CPDF_Dictionary *pEncryptDict, RetainPtr< const CPDF_Array > pIdArray, const ByteString &password)
~CPDF_SecurityHandler() override
uint32_t GetPermissions(bool get_owner_perms) const
void OnCreate(CPDF_Dictionary *pEncryptDict, const CPDF_Array *pIdArray, const ByteString &password)
ByteString GetEncodedPassword(ByteStringView password) const
void SetString(const ByteString &str) override
~CPDF_String() override
CPDF_String * AsMutableString() override
Type GetType() const override
bool IsHex() const
Definition cpdf_string.h:34
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
ByteString EncodeString() const
RetainPtr< CPDF_Object > Clone() const override
WideString GetUnicodeText() const override
ByteString GetString() const override
bool IsInteger() const
Definition fx_number.cpp:86
FX_Number(int32_t value)
Definition fx_number.cpp:20
FX_Number(float value)
Definition fx_number.cpp:22
FX_Number(uint32_t value)=delete
int32_t GetSigned() const
Definition fx_number.cpp:96
float GetFloat() const
bool IsSigned() const
Definition fx_number.cpp:91
FX_Number(ByteStringView str)
Definition fx_number.cpp:24
virtual FX_FILESIZE CurrentOffset() const =0
static RetainPtr< IFX_SeekableReadStream > CreateFromFilename(const char *filename)
Definition fx_stream.cpp:68
virtual FX_FILESIZE GetPosition()
Definition fx_stream.cpp:80
virtual bool ReadBlockAtOffset(pdfium::span< uint8_t > buffer, FX_FILESIZE offset)=0
virtual bool IsEOF()
Definition fx_stream.cpp:76
virtual bool Flush()=0
virtual FX_FILESIZE GetSize()=0
bool WriteFilesize(FX_FILESIZE size)
Definition fx_stream.cpp:61
bool WriteByte(uint8_t byte)
Definition fx_stream.cpp:50
bool WriteString(ByteStringView str)
Definition fx_stream.cpp:46
virtual ~IFX_WriteStream()=default
bool WriteDWord(uint32_t i)
Definition fx_stream.cpp:54
virtual bool WriteBlock(pdfium::span< const uint8_t > data)=0
virtual size_t GetLength() const
void AppendUint8(uint8_t value)
BinaryBuffer & operator=(const BinaryBuffer &that)=delete
void AppendUint16(uint16_t value)
virtual ~BinaryBuffer()
DataVector< uint8_t > m_buffer
void AppendSpan(pdfium::span< const uint8_t > span)
size_t GetSize() const
pdfium::span< const uint8_t > GetSpan() const
void DeleteBuf(size_t start_index, size_t count)
void AppendDouble(double value)
void ExpandBuf(size_t size)
bool IsEmpty() const
void AppendString(const ByteString &str)
void EstimateSize(size_t size)
BinaryBuffer & operator=(BinaryBuffer &&that) noexcept
BinaryBuffer(BinaryBuffer &&that) noexcept
void AppendUint32(uint32_t value)
BinaryBuffer(const BinaryBuffer &that)=delete
pdfium::span< uint8_t > GetMutableSpan()
DataVector< uint8_t > DetachBuffer()
void SetAllocStep(size_t step)
static ByteString Format(const char *pFormat,...)
ByteString & operator=(ByteString &&that) noexcept
FixedSizeDataVector & operator=(FixedSizeDataVector< T > &&that) noexcept
FixedSizeDataVector & operator=(const FixedSizeDataVector &)=delete
static FixedSizeDataVector TruncatedFrom(FixedSizeDataVector &&that, size_t new_size)
static FixedSizeDataVector Uninit(size_t size)
FixedSizeDataVector(const FixedSizeDataVector &)=delete
FixedSizeDataVector(FixedSizeDataVector< T > &&that) noexcept
static FixedSizeDataVector TryZeroed(size_t size)
static FixedSizeDataVector TryUninit(size_t size)
static FixedSizeDataVector Zeroed(size_t size)
virtual void OnObservableDestroyed()=0
virtual ~ObserverIface()=default
Observable(const Observable &that)=delete
void AddObserver(ObserverIface *pObserver)
size_t ActiveObserversForTesting() const
void RemoveObserver(ObserverIface *pObserver)
Observable & operator=(const Observable &that)=delete
ObservedPtr(T *pObservable)
ObservedPtr()=default
ObservedPtr & operator=(const ObservedPtr &that)
bool operator==(const ObservedPtr &that) const
void OnObservableDestroyed() override
bool HasObservable() const
~ObservedPtr() override
void Reset(T *pObservable=nullptr)
T & operator*() const
ObservedPtr(const ObservedPtr &that)
bool operator!=(const ObservedPtr &that) const
bool operator!=(const U *that) const
bool operator==(const U *that) const
T * operator->() const
StringType Intern(const StringType &str)
T * get() const noexcept
UnownedPtr(const UnownedPtr< U > &that)
Definition unowned_ptr.h:99
bool operator==(const UnownedPtr &that) const
operator T*() const noexcept
UnownedPtr(UnownedPtr< U > &&that) noexcept
UnownedPtr & operator=(UnownedPtr< U > &&that) noexcept
constexpr UnownedPtr(const UnownedPtr &that) noexcept=default
constexpr UnownedPtr(T *pObj) noexcept
Definition unowned_ptr.h:84
UnownedPtr & operator=(T *that) noexcept
bool operator==(std::nullptr_t ptr) const
UnownedPtr & operator=(UnownedPtr &&that) noexcept
UnownedPtr & operator=(std::nullptr_t) noexcept
UnownedPtr & operator=(const UnownedPtr< U > &that) noexcept
T * operator->() const
constexpr UnownedPtr() noexcept=default
bool operator<(const UnownedPtr &that) const
UnownedPtr & operator=(const UnownedPtr &that) noexcept=default
T & operator*() const
constexpr UnownedPtr(UnownedPtr &&that) noexcept
Definition unowned_ptr.h:92
constexpr UnownedPtr(std::nullptr_t ptr)
Definition unowned_ptr.h:82
bool operator==(const WeakPtr &that) const
Definition weak_ptr.h:40
void Swap(WeakPtr &that)
Definition weak_ptr.h:56
T * operator->()
Definition weak_ptr.h:34
void Reset()
Definition weak_ptr.h:52
T * Get() const
Definition weak_ptr.h:45
WeakPtr()=default
void Reset(std::unique_ptr< T, D > pObj)
Definition weak_ptr.h:53
WeakPtr(std::unique_ptr< T, D > pObj)
Definition weak_ptr.h:25
WeakPtr(const WeakPtr &that)
Definition weak_ptr.h:23
WeakPtr & operator=(const WeakPtr &that)
Definition weak_ptr.h:36
WeakPtr(std::nullptr_t arg)
Definition weak_ptr.h:30
operator bool() const
Definition weak_ptr.h:32
void DeleteObject()
Definition weak_ptr.h:46
const T * operator->() const
Definition weak_ptr.h:35
bool HasOneRef() const
Definition weak_ptr.h:33
WeakPtr(WeakPtr &&that) noexcept
Definition weak_ptr.h:24
bool operator!=(const WeakPtr &that) const
Definition weak_ptr.h:43
WideString(char)=delete
WideString(const std::initializer_list< WideStringView > &list)
WideString & operator+=(const WideString &str)
WideString(wchar_t ch)
bool operator==(const WideString &other) const
ByteString ToUTF8() const
static WideString Format(const wchar_t *pFormat,...)
UNSAFE_BUFFER_USAGE WideString(const wchar_t *pStr, size_t len)
WideString & operator=(WideString &&that) noexcept
WideString(WideStringView str1, WideStringView str2)
WideString()=default
WideString First(size_t count) const
static WideString FromUTF8(ByteStringView str)
WideString & operator+=(const wchar_t *str)
bool operator==(const wchar_t *ptr) const
WideString & operator+=(wchar_t ch)
bool operator<(WideStringView str) const
bool EqualsASCIINoCase(ByteStringView that) const
Definition widestring.h:114
~WideString()=default
WideString(const WideString &other)=default
static WideString FromDefANSI(ByteStringView str)
int GetInteger() const
int CompareNoCase(const wchar_t *str) const
WideString(const wchar_t *ptr)
static WideString FromLatin1(ByteStringView str)
WideString(WideString &&other) noexcept=default
bool IsASCII() const
Definition widestring.h:110
bool operator==(WideStringView str) const
bool operator!=(const WideString &other) const
Definition widestring.h:85
ByteString ToLatin1() const
intptr_t ReferenceCountForTesting() const
static WideString FromUTF16BE(pdfium::span< const uint8_t > data)
bool operator<(const WideString &other) const
int Compare(const wchar_t *str) const
WideString & operator=(const WideString &that)
WideString EncodeEntities() const
ByteString ToASCII() const
static WideString FromASCII(ByteStringView str)
WideString & operator+=(WideStringView str)
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
ByteString ToUCS2LE() const
WideString Last(size_t count) const
int Compare(const WideString &str) const
WideString & operator=(const wchar_t *str)
WideString Substr(size_t offset) const
WideString(WideStringView str)
bool operator!=(const wchar_t *ptr) const
Definition widestring.h:83
static WideString FormatV(const wchar_t *lpszFormat, va_list argList)
ByteString ToUTF16LE() const
static WideString FormatInteger(int i)
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:111
ByteString ToDefANSI() const
bool operator<(const wchar_t *ptr) const
WideString Substr(size_t first, size_t count) const
bool operator!=(WideStringView str) const
Definition widestring.h:84
WideString & operator=(WideStringView str)
constexpr CheckedNumericState(Src value=0.0, bool is_valid=true)
constexpr CheckedNumericState(const CheckedNumericState< Src > &rhs)
constexpr CheckedNumericState(const CheckedNumericState< Src > &rhs)
constexpr CheckedNumericState(Src value=0, bool is_valid=true)
constexpr bool AssignIfValid(Dst *result) const
static constexpr CheckedNumeric MathOp(const L lhs, const R rhs)
constexpr CheckedNumeric< typename UnderlyingType< Dst >::type > Cast() const
constexpr CheckedNumeric operator-() const
constexpr CheckedNumeric & operator>>=(const Src rhs)
constexpr CheckedNumeric & operator/=(const Src rhs)
constexpr CheckedNumeric(StrictNumeric< Src > value)
constexpr CheckedNumeric(const CheckedNumeric< Src > &rhs)
constexpr CheckedNumeric operator~() const
constexpr CheckedNumeric operator++(int)
constexpr CheckedNumeric & operator^=(const Src rhs)
constexpr CheckedNumeric & operator-=(const Src rhs)
constexpr bool IsValid() const
constexpr CheckedNumeric< typename MathWrapper< CheckedMaxOp, T, U >::type > Max(const U rhs) const
constexpr CheckedNumeric & operator++()
constexpr CheckedNumeric & operator+=(const Src rhs)
constexpr CheckedNumeric operator--(int)
constexpr StrictNumeric< Dst > ValueOrDefault(const Src default_value) const
constexpr CheckedNumeric()=default
constexpr CheckedNumeric & operator|=(const Src rhs)
constexpr CheckedNumeric< typename MathWrapper< CheckedMinOp, T, U >::type > Min(const U rhs) const
constexpr CheckedNumeric< typename UnsignedOrFloatForSize< T >::type > UnsignedAbs() const
constexpr CheckedNumeric(T value)
constexpr CheckedNumeric & operator&=(const Src rhs)
friend U GetNumericValueForTest(const CheckedNumeric< U > &src)
constexpr CheckedNumeric & operator--()
constexpr CheckedNumeric Abs() const
constexpr CheckedNumeric & operator*=(const Src rhs)
constexpr CheckedNumeric & operator%=(const Src rhs)
constexpr CheckedNumeric & MathOp(const R rhs)
constexpr CheckedNumeric(Src value)
constexpr StrictNumeric< Dst > ValueOrDie() const
#define UNSAFE_BUFFERS(...)
#define GSL_POINTER
#define TRIVIAL_ABI
#define UNSAFE_BUFFER_USAGE
CPDF_Array * ToArray(CPDF_Object *obj)
Definition cpdf_array.h:198
const CPDF_Array * ToArray(const CPDF_Object *obj)
Definition cpdf_array.h:202
RetainPtr< CPDF_Array > ToArray(RetainPtr< CPDF_Object > obj)
Definition cpdf_array.h:206
#define FPDFCREATE_INCREMENTAL
#define FPDFCREATE_NO_ORIGINAL
const CPDF_Dictionary * ToDictionary(const CPDF_Object *obj)
RetainPtr< CPDF_Dictionary > ToDictionary(RetainPtr< CPDF_Object > obj)
CPDF_Dictionary * ToDictionary(CPDF_Object *obj)
const CPDF_Number * ToNumber(const CPDF_Object *obj)
Definition cpdf_number.h:46
RetainPtr< CPDF_Number > ToNumber(RetainPtr< CPDF_Object > obj)
Definition cpdf_number.h:50
CPDF_Number * ToNumber(CPDF_Object *obj)
Definition cpdf_number.h:42
CPDF_String * ToString(CPDF_Object *obj)
Definition cpdf_string.h:50
RetainPtr< const CPDF_String > ToString(RetainPtr< const CPDF_Object > obj)
Definition cpdf_string.h:58
const CPDF_String * ToString(const CPDF_Object *obj)
Definition cpdf_string.h:54
bool PDFCharIsWhitespace(uint8_t c)
bool ValidateDictOptionalType(const CPDF_Dictionary *dict, ByteStringView type)
std::optional< FX_FILESIZE > GetHeaderOffset(const RetainPtr< IFX_SeekableReadStream > &pFile)
bool PDFCharIsOther(uint8_t c)
ByteString PDF_NameDecode(ByteStringView orig)
const char kPDFCharTypes[256]
ByteString PDF_NameEncode(const ByteString &orig)
bool PDFCharIsNumeric(uint8_t c)
uint8_t GetPDFCharTypeFromArray(uint8_t c)
bool ValidateFontResourceDict(const CPDF_Dictionary *dict)
bool ValidateDictType(const CPDF_Dictionary *dict, ByteStringView type)
std::vector< float > ReadArrayElementsToVector(const CPDF_Array *pArray, size_t nCount)
bool ValidateDictAllResourcesOfType(const CPDF_Dictionary *dict, ByteStringView type)
bool PDFCharIsDelimiter(uint8_t c)
bool PDFCharIsLineEnding(uint8_t c)
time_t FXSYS_time(time_t *tloc)
int FXSYS_WideHexCharToInt(wchar_t c)
int32_t FXSYS_towupper(wchar_t c)
bool FXSYS_IsHexDigit(char c)
void FXSYS_IntToTwoHexChars(uint8_t n, char *buf)
void FXSYS_SetTimeFunction(time_t(*func)())
bool FXSYS_IsDecimalDigit(wchar_t c)
bool FXSYS_iswalpha(wchar_t c)
bool FXSYS_iswlower(int32_t c)
float FXSYS_wcstof(WideStringView pwsStr, size_t *pUsedLen)
int FXSYS_DecimalCharToInt(char c)
bool FXSYS_IsWideHexDigit(wchar_t c)
bool FXSYS_IsOctalDigit(char c)
bool FXSYS_SafeLT(const T &lhs, const T &rhs)
bool FXSYS_iswupper(int32_t c)
bool FXSYS_IsDecimalDigit(char c)
size_t FXSYS_ToUTF16BE(uint32_t unicode, char *buf)
bool FXSYS_IsUpperASCII(int32_t c)
char FXSYS_ToUpperASCII(char c)
int FXSYS_DecimalCharToInt(wchar_t c)
int FXSYS_HexCharToInt(char c)
bool FXSYS_IsLowerASCII(int32_t c)
bool FXSYS_iswalnum(wchar_t c)
void FXSYS_IntToFourHexChars(uint16_t n, char *buf)
bool FXSYS_iswspace(wchar_t c)
struct tm * FXSYS_localtime(const time_t *tp)
bool FXSYS_SafeEQ(const T &lhs, const T &rhs)
int32_t FXSYS_towlower(wchar_t c)
UNSAFE_BUFFER_USAGE wchar_t * FXSYS_wcsncpy(wchar_t *dstStr, const wchar_t *srcStr, size_t count)
void FXSYS_SetLocaltimeFunction(struct tm *(*func)(const time_t *))
void * FX_Random_MT_Start(uint32_t dwSeed)
Definition fx_random.cpp:87
uint32_t FX_Random_MT_Generate(void *pContext)
Definition fx_random.cpp:98
void FX_Random_GenerateMT(pdfium::span< uint32_t > pBuffer)
void FX_Random_MT_Close(void *pContext)
pdfium::CheckedNumeric< FX_FILESIZE > FX_SAFE_FILESIZE
pdfium::CheckedNumeric< uint32_t > FX_SAFE_UINT32
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
constexpr uint32_t FXBSTR_ID(uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4)
Definition fx_string.h:19
double StringToDouble(WideStringView wsStr)
float StringToFloat(ByteStringView str)
ByteString FX_UTF8Encode(WideStringView wsStr)
Definition fx_string.cpp:68
std::u16string FX_UTF16Encode(WideStringView wsStr)
Definition fx_string.cpp:76
float StringToFloat(WideStringView wsStr)
double StringToDouble(ByteStringView str)
#define FX_FILESIZE
Definition fx_types.h:19
WideString operator+(const wchar_t *str1, WideStringView str2)
Definition widestring.h:147
bool operator==(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:177
WideString operator+(const WideString &str1, const WideString &str2)
Definition widestring.h:156
StringViewTemplate< wchar_t > WideStringView
WideString operator+(const WideString &str1, WideStringView str2)
Definition widestring.h:171
WideString operator+(const WideString &str1, wchar_t ch)
Definition widestring.h:159
bool operator!=(const U *lhs, const ObservedPtr< T > &rhs)
WideString operator+(WideStringView str1, const WideString &str2)
Definition widestring.h:174
std::vector< StrType > Split(const StrType &that, typename StrType::CharType ch)
Definition fx_string.h:36
bool operator!=(WideStringView lhs, const WideString &rhs)
Definition widestring.h:186
StringViewTemplate< char > ByteStringView
bool operator==(WideStringView lhs, const WideString &rhs)
Definition widestring.h:180
bool operator!=(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:183
WideString operator+(WideStringView str1, const wchar_t *str2)
Definition widestring.h:144
WideString operator+(WideStringView str1, wchar_t ch)
Definition widestring.h:150
void PrintTo(const WideString &str, std::ostream *os)
WideString operator+(WideStringView str1, WideStringView str2)
Definition widestring.h:141
WideString operator+(wchar_t ch, WideStringView str2)
Definition widestring.h:153
WideString operator+(wchar_t ch, const WideString &str2)
Definition widestring.h:162
WideString operator+(const wchar_t *str1, const WideString &str2)
Definition widestring.h:168
bool operator<(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:189
bool operator==(const U *lhs, const ObservedPtr< T > &rhs)
WideString operator+(const WideString &str1, const wchar_t *str2)
Definition widestring.h:165
constexpr CheckedNumeric< typename MathWrapper< M, L, R >::type > CheckMathOp(const L lhs, const R rhs)
constexpr bool CheckedMulImpl(T x, T y, T *result)
constexpr bool IsValidForType(const CheckedNumeric< Src > value)
constexpr CheckedNumeric< typename UnderlyingType< T >::type > MakeCheckedNum(const T value)
constexpr StrictNumeric< Dst > ValueOrDefaultForType(const CheckedNumeric< Src > value, const Default default_value)
constexpr auto CheckMathOp(const L lhs, const R rhs, const Args... args)
constexpr bool CheckedSubImpl(T x, T y, T *result)
constexpr StrictNumeric< Dst > ValueOrDieForType(const CheckedNumeric< Src > value)
L * operator+(L *lhs, const StrictNumeric< R > rhs)
constexpr bool CheckedAddImpl(T x, T y, T *result)
L * operator-(L *lhs, const StrictNumeric< R > rhs)
UnownedPtr< T > WrapUnowned(T *that)
bool Contains(const Container &container, const Value &value)
Definition contains.h:69
std::set< uint32_t > GetObjectsWithReferences(const CPDF_Document *document)
std::set< uint32_t > GetObjectsWithMultipleReferences(const CPDF_Document *document)
#define CHECK(cvref)
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:222
#define BASE_NUMERICS_LIKELY(x)
#define BASE_NUMERICS_UNLIKELY(x)
#define IsConstantEvaluated()
#define BASE_NUMERIC_ARITHMETIC_OPERATORS(CLASS, CL_ABBR, OP_NAME, OP, CMP_OP)
#define BASE_NUMERIC_ARITHMETIC_VARIADIC(CLASS, CL_ABBR, OP_NAME)
StringPoolTemplate< WideString > WideStringPool
StringPoolTemplate< ByteString > ByteStringPool
fxcrt::ByteStringView ByteStringView
fxcrt::WideStringView WideStringView
static constexpr bool value
static const NumericRepresentation value
size_t operator()(const WideString &str) const
Definition widestring.h:216
#define UNOWNED_PTR_EXCLUSION
fxcrt::WideString WideString
Definition widestring.h:207
uint32_t FX_HashCode_GetLoweredW(WideStringView str)
uint32_t FX_HashCode_GetW(WideStringView str)