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
fx_system.h
Go to the documentation of this file.
1// Copyright 2014 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#ifndef CORE_FXCRT_FX_SYSTEM_H_
8#define CORE_FXCRT_FX_SYSTEM_H_
9
10#include <stddef.h>
11#include <stdint.h>
12#include <stdio.h>
13#include <stdlib.h>
14#include <wchar.h>
15
16#include "build/build_config.h"
17#include "core/fxcrt/compiler_specific.h"
18#include "core/fxcrt/fx_types.h"
19
20#if defined(_MSC_VER) && _MSC_VER < 1900
21#error Sorry, VC++ 2015 or later is required to compile PDFium.
22#endif // defined(_MSC_VER) && _MSC_VER < 1900
23
24#if defined(__wasm__) && defined(PDF_ENABLE_V8)
25#error Cannot compile v8 with wasm.
26#endif // PDF_ENABLE_V8
27
28#if BUILDFLAG(IS_WIN)
29#include <windows.h>
30#endif // BUILDFLAG(IS_WIN)
31
32#ifdef __cplusplus
33extern "C" {
34#endif // __cplusplus
35
36#define FXSYS_IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
37#define FXSYS_IsFloatBigger(fa, fb)
38 ((fa) > (fb) && !FXSYS_IsFloatZero((fa) - (fb)))
39#define FXSYS_IsFloatSmaller(fa, fb)
40 ((fa) < (fb) && !FXSYS_IsFloatZero((fa) - (fb)))
41#define FXSYS_IsFloatEqual(fa, fb) FXSYS_IsFloatZero((fa) - (fb))
42
43// M_PI not universally present on all platforms.
44#define FXSYS_PI 3.1415926535897932384626433832795f
45#define FXSYS_BEZIER 0.5522847498308f
46
47// NOTE: prevent use of the return value from snprintf() since some platforms
48// have different return values.
49#define FXSYS_snprintf (void)snprintf
50#define FXSYS_vsnprintf (void)vsnprintf
51#define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
52#define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
53
54#if BUILDFLAG(IS_WIN)
55#define FXSYS_itoa _itoa
56#define FXSYS_strlwr _strlwr
57#define FXSYS_strupr _strupr
58#define FXSYS_wcslwr _wcslwr
59#define FXSYS_wcsupr _wcsupr
60#define FXSYS_SetLastError SetLastError
61#define FXSYS_GetLastError GetLastError
62UNSAFE_BUFFER_USAGE size_t FXSYS_wcsftime(wchar_t* strDest,
63 size_t maxsize,
64 const wchar_t* format,
65 const struct tm* timeptr);
66#else // BUILDFLAG(IS_WIN)
67char* FXSYS_itoa(int value, char* str, int radix);
68char* FXSYS_strlwr(char* str);
69char* FXSYS_strupr(char* str);
70wchar_t* FXSYS_wcslwr(wchar_t* str);
71wchar_t* FXSYS_wcsupr(wchar_t* str);
72void FXSYS_SetLastError(uint32_t err);
73uint32_t FXSYS_GetLastError();
74#define FXSYS_wcsftime wcsftime
75#endif // BUILDFLAG(IS_WIN)
76
77const char* FXSYS_i64toa(int64_t value, char* str, int radix);
78int FXSYS_roundf(float f);
79int FXSYS_round(double d);
80float FXSYS_sqrt2(float a, float b);
81
82#ifdef __cplusplus
83} // extern "C"
84
85// C++-only section to allow future use of TerminatedPtr<>.
86int FXSYS_stricmp(const char* str1, const char* str2);
87int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2);
88int32_t FXSYS_atoi(const char* str);
89int32_t FXSYS_wtoi(const wchar_t* str);
90uint32_t FXSYS_atoui(const char* str);
91int64_t FXSYS_atoi64(const char* str);
92
93#endif // __cplusplus
94
95#endif // CORE_FXCRT_FX_SYSTEM_H_
uint32_t FX_HashCode_GetLoweredAsIfW(ByteStringView str)
fxcrt::ByteString ByteString
Definition bytestring.h:180
uint32_t FX_HashCode_GetLoweredA(ByteStringView str)
uint32_t FX_HashCode_GetAsIfW(ByteStringView str)
uint32_t FX_HashCode_GetA(ByteStringView str)
uint32_t GetID() const
Definition bytestring.h:98
ByteString(const char *ptr)
bool EqualNoCase(ByteStringView str) const
static ByteString Format(const char *pFormat,...)
ByteString & operator+=(const ByteString &str)
bool operator!=(ByteStringView str) const
Definition bytestring.h:66
ByteString Substr(size_t first, size_t count) const
bool operator==(ByteStringView str) const
ByteString()=default
intptr_t ReferenceCountForTesting() const
ByteString & operator+=(char ch)
ByteString(ByteStringView bstrc)
static ByteString FormatInteger(int i)
bool operator==(const ByteString &other) const
bool operator==(const char *ptr) const
UNSAFE_BUFFER_USAGE ByteString(const char *pStr, size_t len)
bool operator<(ByteStringView str) const
ByteString(wchar_t)=delete
ByteString & operator+=(const char *str)
ByteString & operator+=(ByteStringView str)
~ByteString()=default
UNSAFE_BUFFER_USAGE ByteString(const uint8_t *pStr, size_t len)
bool operator!=(const ByteString &other) const
Definition bytestring.h:67
ByteString & operator=(ByteStringView str)
ByteString(ByteStringView str1, ByteStringView str2)
ByteString & operator=(const char *str)
static ByteString FormatV(const char *pFormat, va_list argList)
ByteString Substr(size_t offset) const
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
ByteString(ByteString &&other) noexcept=default
bool operator<(const ByteString &other) const
ByteString(const std::initializer_list< ByteStringView > &list)
bool operator!=(const char *ptr) const
Definition bytestring.h:65
int Compare(ByteStringView str) const
ByteString(const ByteString &other)=default
ByteString(const fxcrt::ostringstream &outStream)
ByteString First(size_t count) const
bool operator<(const char *ptr) const
ByteString Last(size_t count) const
U * AsRaw() const
Definition retain_ptr.h:106
RetainPtr & operator=(const RetainPtr< U > &that)
Definition retain_ptr.h:88
operator bool() const
Definition retain_ptr.h:147
void Unleak(T *ptr)
Definition retain_ptr.h:128
RetainPtr(std::nullptr_t ptr)
Definition retain_ptr.h:34
void Reset(T *obj=nullptr)
Definition retain_ptr.h:115
bool operator!=(const RetainPtr &that) const
Definition retain_ptr.h:131
void Swap(RetainPtr &that)
Definition retain_ptr.h:124
RetainPtr() noexcept=default
RetainPtr(RetainPtr &&that) noexcept
Definition retain_ptr.h:47
bool operator!=(const U &that) const
Definition retain_ptr.h:139
RetainPtr & operator=(const RetainPtr &that)
Definition retain_ptr.h:71
bool operator==(const RetainPtr &that) const
Definition retain_ptr.h:130
T & operator*() const
Definition retain_ptr.h:148
bool operator==(const U &that) const
Definition retain_ptr.h:134
RetainPtr & operator=(RetainPtr &&that) noexcept
Definition retain_ptr.h:79
T * operator->() const
Definition retain_ptr.h:149
RetainPtr & operator=(RetainPtr< U > &&that) noexcept
Definition retain_ptr.h:98
RetainPtr(const RetainPtr< U > &that)
Definition retain_ptr.h:53
T * Get() const noexcept
Definition retain_ptr.h:122
~RetainPtr()=default
bool operator<(const RetainPtr &that) const
Definition retain_ptr.h:143
RetainPtr(const RetainPtr &that) noexcept
Definition retain_ptr.h:43
operator T*() const noexcept
Definition retain_ptr.h:121
RetainPtr & operator=(std::nullptr_t) noexcept
Definition retain_ptr.h:64
RetainPtr(RetainPtr< U > &&that) noexcept
Definition retain_ptr.h:59
RetainPtr< U > As() const
Definition retain_ptr.h:111
RetainPtr(T *pObj) noexcept
Definition retain_ptr.h:36
bool HasOneRef() const
Definition retain_ptr.h:160
Retainable()=default
virtual ~Retainable()=default
pdfium::span< CharType > alloc_span()
pdfium::span< CharType > span()
pdfium::span< const CharType > span_with_terminator() const
pdfium::span< const CharType > span() const
pdfium::span< CharType > capacity_span()
void CopyContents(const StringDataTemplate &other)
static RetainPtr< StringDataTemplate > Create(size_t nLen)
void CopyContentsAt(size_t offset, pdfium::span< const CharType > str)
void CopyContents(pdfium::span< const CharType > str)
bool CanOperateInPlace(size_t nTotalLen) const
pdfium::span< const CharType > capacity_span() const
pdfium::span< const CharType > alloc_span() const
pdfium::span< T > GetBuffer(size_t nMinBufLength)
size_t Delete(size_t index, size_t count=1)
const_iterator begin() const
void AllocBeforeWrite(size_t nNewLen)
pdfium::span< const UnsignedType > unsigned_span_with_terminator() const
size_t Replace(StringView oldstr, StringView newstr)
StringTemplate(const StringTemplate &other)=default
pdfium::span< const CharType > span_with_terminator() const
StringView AsStringView() const
void ReleaseBuffer(size_t nNewLength)
void Reserve(size_t len)
CharType operator[](const size_t index) const
CharType Front() const
pdfium::span< const UnsignedType > unsigned_span() const
StringDataTemplate< T > StringData
std::optional< size_t > ReverseFind(T ch) const
StringViewTemplate< T > StringView
void AssignCopy(const T *pSrcData, size_t nSrcLen)
RetainPtr< StringData > m_pData
std::optional< size_t > Find(StringView str, size_t start=0) const
void SetAt(size_t index, T ch)
const_reverse_iterator rbegin() const
const_iterator end() const
bool IsValidIndex(size_t index) const
bool Contains(T ch, size_t start=0) const
typename std::make_unsigned< CharType >::type UnsignedType
void TrimBack(StringView targets)
void Trim(StringView targets)
StringTemplate(StringTemplate &&other) noexcept=default
std::reverse_iterator< const_iterator > const_reverse_iterator
bool Contains(StringView str, size_t start=0) const
void Concat(const T *pSrcData, size_t nSrcLen)
CharType Back() const
std::optional< size_t > Find(T ch, size_t start=0) const
size_t GetLength() const
pdfium::span< const CharType > span() const
const UnsignedType * unsigned_str() const
bool IsValidLength(size_t length) const
size_t GetStringLength() const
void ReallocBeforeWrite(size_t nNewLen)
void TrimFront(StringView targets)
size_t Insert(size_t index, T ch)
const_reverse_iterator rend() const
const CharType * c_str() const
bool operator>(const StringViewTemplate &that) const
StringViewTemplate(const CharType *ptr) noexcept
bool operator<(const StringViewTemplate &that) const
bool IsValidLength(size_t length) const
bool operator!=(const CharType *ptr) const
typename std::make_unsigned< CharType >::type UnsignedType
StringViewTemplate TrimmedRight(CharType ch) const
pdfium::span< const UnsignedType > m_Span
bool EqualsASCII(const StringViewTemplate< char > &that) const
std::optional< size_t > Find(CharType ch) const
const CharType * unterminated_c_str() const
bool operator==(const CharType *ptr) const
bool Contains(CharType ch) const
bool EqualsASCIINoCase(const StringViewTemplate< char > &that) const
StringViewTemplate Substr(size_t first, size_t count) const
std::reverse_iterator< const_iterator > const_reverse_iterator
UNSAFE_BUFFER_USAGE constexpr StringViewTemplate(const CharType *ptr, size_t size) noexcept
bool operator==(const StringViewTemplate &other) const
const UnsignedType & operator[](const size_t index) const
StringViewTemplate Last(size_t count) const
const UnsignedType * unterminated_unsigned_str() const
CharType CharAt(const size_t index) const
bool operator!=(const StringViewTemplate &other) const
StringViewTemplate First(size_t count) const
constexpr StringViewTemplate(const pdfium::span< const CharType > &other) noexcept
constexpr StringViewTemplate(const StringViewTemplate &src) noexcept=default
const_iterator begin() const
StringViewTemplate & operator=(const StringViewTemplate &src)
const_reverse_iterator rend() const
StringViewTemplate & operator=(const CharType *src)
StringViewTemplate Substr(size_t offset) const
constexpr StringViewTemplate() noexcept=default
constexpr StringViewTemplate(const CharType &ch) noexcept
UNSAFE_BUFFER_USAGE constexpr StringViewTemplate(const UnsignedType *ptr, size_t size) noexcept
pdfium::span< const CharType > span() const
const_reverse_iterator rbegin() const
bool IsValidIndex(size_t index) const
constexpr StringViewTemplate(const pdfium::span< const UnsignedType > &other) noexcept
pdfium::span< const UnsignedType > unsigned_span() const
#define UNSAFE_BUFFERS(...)
#define TRIVIAL_ABI
#define UNSAFE_BUFFER_USAGE
CRYPT_md5_context CRYPT_MD5Start()
Definition fx_crypt.cpp:164
TEST(FXCRYPT, CryptToBase16)
TEST(FXCRYPT, MD5GenerateEmtpyData)
int32_t FXSYS_atoi(const char *str)
uint32_t FXSYS_atoui(const char *str)
int FXSYS_wcsicmp(const wchar_t *str1, const wchar_t *str2)
int32_t FXSYS_wtoi(const wchar_t *str)
int FXSYS_stricmp(const char *str1, const char *str2)
int64_t FXSYS_atoi64(const char *str)
char * FXSYS_strlwr(char *str)
wchar_t * FXSYS_wcsupr(wchar_t *str)
char * FXSYS_strupr(char *str)
wchar_t * FXSYS_wcslwr(wchar_t *str)
#define FXSYS_IsFloatZero(f)
Definition fx_system.h:36
uint32_t FXSYS_GetLastError()
const char * FXSYS_i64toa(int64_t value, char *str, int radix)
int FXSYS_roundf(float f)
int FXSYS_round(double d)
char * FXSYS_itoa(int value, char *str, int radix)
void FXSYS_SetLastError(uint32_t err)
float FXSYS_sqrt2(float a, float b)
std::string CryptToBase16(const uint8_t *digest)
Definition hash.cpp:9
bool operator==(const char *lhs, const ByteString &rhs)
Definition bytestring.h:109
bool operator<(const ByteStringView &lhs, const char *rhs)
Definition bytestring.h:127
ByteString operator+(const ByteString &str1, const ByteString &str2)
Definition bytestring.h:146
ByteString operator+(ByteStringView str1, const char *str2)
Definition bytestring.h:134
bool operator<(const ByteStringView &lhs, const ByteString &rhs)
Definition bytestring.h:124
StringViewTemplate< wchar_t > WideStringView
bool operator==(const T *lhs, const StringViewTemplate< T > &rhs)
bool operator<(const T *lhs, const StringViewTemplate< T > &rhs)
ByteString operator+(const ByteString &str1, char ch)
Definition bytestring.h:149
ByteString operator+(const ByteString &str1, const char *str2)
Definition bytestring.h:155
void PrintTo(const ByteString &str, std::ostream *os)
bool operator!=(const T *lhs, const StringViewTemplate< T > &rhs)
ByteString operator+(char ch, const ByteString &str2)
Definition bytestring.h:152
ByteString operator+(const ByteString &str1, ByteStringView str2)
Definition bytestring.h:161
ByteString operator+(const char *str1, const ByteString &str2)
Definition bytestring.h:158
constexpr const wchar_t * EmptyString(wchar_t *)
StringViewTemplate< char > ByteStringView
bool operator!=(ByteStringView lhs, const ByteString &rhs)
Definition bytestring.h:118
bool operator!=(const char *lhs, const ByteString &rhs)
Definition bytestring.h:115
ByteString operator+(ByteStringView str1, ByteStringView str2)
Definition bytestring.h:131
ByteString operator+(ByteStringView str1, char ch)
Definition bytestring.h:140
constexpr const char * EmptyString(char *)
bool operator<(const char *lhs, const ByteString &rhs)
Definition bytestring.h:121
ByteString operator+(char ch, ByteStringView str2)
Definition bytestring.h:143
ByteString operator+(ByteStringView str1, const ByteString &str2)
Definition bytestring.h:164
ByteString operator+(const char *str1, ByteStringView str2)
Definition bytestring.h:137
bool operator==(ByteStringView lhs, const ByteString &rhs)
Definition bytestring.h:112
RetainPtr< T > MakeRetain(Args &&... args)
Definition retain_ptr.h:207
RetainPtr< T > WrapRetain(T *that)
Definition retain_ptr.h:214
#define CHECK(cvref)
fxcrt::ByteStringView ByteStringView
fxcrt::WideStringView WideStringView
void operator()(T *ptr) const
Definition retain_ptr.h:23
size_t operator()(const ByteString &str) const
Definition bytestring.h:191