diff options
author | tsepez <tsepez@chromium.org> | 2016-05-13 15:02:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-13 15:02:44 -0700 |
commit | f7036ba5884b9829fcb17aea4f3a16831abb7516 (patch) | |
tree | e142bb59eea5d48d354a6f4841d1ef57306e985f /core/fxcrt/include/fx_system.h | |
parent | 19ea309f3d46bbd76d4201b4e791b11d736f7834 (diff) | |
download | pdfium-f7036ba5884b9829fcb17aea4f3a16831abb7516.tar.xz |
Templatize CFX_{Byte,Wide}StringC
Review-Url: https://codereview.chromium.org/1874773002
Diffstat (limited to 'core/fxcrt/include/fx_system.h')
-rw-r--r-- | core/fxcrt/include/fx_system.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/fxcrt/include/fx_system.h b/core/fxcrt/include/fx_system.h index b4659d14e4..205976fb15 100644 --- a/core/fxcrt/include/fx_system.h +++ b/core/fxcrt/include/fx_system.h @@ -158,6 +158,31 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode); #define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr)) #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) +// Overloaded functions for C++ templates +inline FX_STRSIZE FXSYS_len(const FX_CHAR* ptr) { + return FXSYS_strlen(ptr); +} + +inline FX_STRSIZE FXSYS_len(const FX_WCHAR* ptr) { + return FXSYS_wcslen(ptr); +} + +inline int FXSYS_cmp(const FX_CHAR* ptr1, const FX_CHAR* ptr2, size_t len) { + return memcmp(ptr1, ptr2, len); +} + +inline int FXSYS_cmp(const FX_WCHAR* ptr1, const FX_WCHAR* ptr2, size_t len) { + return wmemcmp(ptr1, ptr2, len); +} + +inline const FX_CHAR* FXSYS_chr(const FX_CHAR* ptr, FX_CHAR ch, size_t len) { + return reinterpret_cast<const FX_CHAR*>(memchr(ptr, ch, len)); +} + +inline const FX_WCHAR* FXSYS_chr(const FX_WCHAR* ptr, FX_WCHAR ch, size_t len) { + return wmemchr(ptr, ch, len); +} + extern "C" { #else #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) |