summaryrefslogtreecommitdiff
path: root/core/fxcrt/include/fx_string.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-11 17:35:35 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 17:35:35 -0700
commitf7fe678a4ada859a2e4fbbeeb0b1dff5b5887227 (patch)
tree271f61e203bcb7026db6b4936668f51f7f5e0de8 /core/fxcrt/include/fx_string.h
parent94dfd56acc7ceb2acfc2e5c7ae516e34b160ea15 (diff)
downloadpdfium-f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227.tar.xz
Add much-needed Find() method for CFX_*StringC
BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1968233002
Diffstat (limited to 'core/fxcrt/include/fx_string.h')
-rw-r--r--core/fxcrt/include/fx_string.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 66a8039a8d..fbfb91f759 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -100,6 +100,12 @@ class CFX_ByteStringC {
uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
+ FX_STRSIZE Find(FX_CHAR ch) const {
+ const uint8_t* found =
+ static_cast<const uint8_t*>(memchr(m_Ptr, ch, m_Length));
+ return found ? found - m_Ptr : -1;
+ }
+
CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
if (index < 0) {
index = 0;
@@ -417,6 +423,12 @@ class CFX_WideStringC {
return CFX_WideStringC(m_Ptr, count);
}
+ FX_STRSIZE Find(FX_WCHAR ch) const {
+ const FX_WCHAR* found =
+ static_cast<const FX_WCHAR*>(wmemchr(m_Ptr, ch, m_Length));
+ return found ? found - m_Ptr : -1;
+ }
+
CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
if (index < 0) {
index = 0;