summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpvt_wordplace.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpvt_wordplace.h')
-rw-r--r--core/fpdfdoc/cpvt_wordplace.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/core/fpdfdoc/cpvt_wordplace.h b/core/fpdfdoc/cpvt_wordplace.h
index f4a6b087b9..c0a1a9cd5c 100644
--- a/core/fpdfdoc/cpvt_wordplace.h
+++ b/core/fpdfdoc/cpvt_wordplace.h
@@ -14,55 +14,55 @@ struct CPVT_WordPlace {
CPVT_WordPlace(int32_t other_nSecIndex,
int32_t other_nLineIndex,
- int32_t other_nWordIndex) {
- nSecIndex = other_nSecIndex;
- nLineIndex = other_nLineIndex;
- nWordIndex = other_nWordIndex;
+ int32_t other_nWordIndex)
+ : nSecIndex(other_nSecIndex),
+ nLineIndex(other_nLineIndex),
+ nWordIndex(other_nWordIndex) {}
+
+ void Reset() {
+ nSecIndex = -1;
+ nLineIndex = -1;
+ nWordIndex = -1;
}
- void Default() { nSecIndex = nLineIndex = nWordIndex = -1; }
+ void AdvanceSection() {
+ nSecIndex++;
+ nLineIndex = 0;
+ nWordIndex = -1;
+ }
- bool operator==(const CPVT_WordPlace& wp) const {
+ inline bool operator==(const CPVT_WordPlace& wp) const {
return wp.nSecIndex == nSecIndex && wp.nLineIndex == nLineIndex &&
wp.nWordIndex == nWordIndex;
}
-
- bool operator!=(const CPVT_WordPlace& wp) const { return !(*this == wp); }
-
- inline int32_t WordCmp(const CPVT_WordPlace& wp) const {
- if (nSecIndex > wp.nSecIndex)
- return 1;
- if (nSecIndex < wp.nSecIndex)
- return -1;
- if (nLineIndex > wp.nLineIndex)
- return 1;
- if (nLineIndex < wp.nLineIndex)
- return -1;
- if (nWordIndex > wp.nWordIndex)
- return 1;
- if (nWordIndex < wp.nWordIndex)
- return -1;
- return 0;
+ inline bool operator!=(const CPVT_WordPlace& wp) const {
+ return !(*this == wp);
}
-
- inline int32_t LineCmp(const CPVT_WordPlace& wp) const {
- if (nSecIndex > wp.nSecIndex)
- return 1;
- if (nSecIndex < wp.nSecIndex)
- return -1;
- if (nLineIndex > wp.nLineIndex)
- return 1;
- if (nLineIndex < wp.nLineIndex)
- return -1;
- return 0;
+ inline bool operator<(const CPVT_WordPlace& wp) const {
+ if (nSecIndex != wp.nSecIndex)
+ return nSecIndex < wp.nSecIndex;
+ if (nLineIndex != wp.nLineIndex)
+ return nLineIndex < wp.nLineIndex;
+ return nWordIndex < wp.nWordIndex;
+ }
+ inline bool operator>(const CPVT_WordPlace& wp) const {
+ if (nSecIndex != wp.nSecIndex)
+ return nSecIndex > wp.nSecIndex;
+ if (nLineIndex != wp.nLineIndex)
+ return nLineIndex > wp.nLineIndex;
+ return nWordIndex > wp.nWordIndex;
+ }
+ inline bool operator<=(const CPVT_WordPlace& wp) const {
+ return *this < wp || *this == wp;
+ }
+ inline bool operator>=(const CPVT_WordPlace& wp) const {
+ return *this > wp || *this == wp;
}
- inline int32_t SecCmp(const CPVT_WordPlace& wp) const {
- if (nSecIndex > wp.nSecIndex)
- return 1;
- if (nSecIndex < wp.nSecIndex)
- return -1;
- return 0;
+ inline int32_t LineCmp(const CPVT_WordPlace& wp) const {
+ if (nSecIndex != wp.nSecIndex)
+ return nSecIndex - wp.nSecIndex;
+ return nLineIndex - wp.nLineIndex;
}
int32_t nSecIndex;