aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-01-20 08:36:24 +1100
committerNeil <nyamatongwe@gmail.com>2022-01-20 08:36:24 +1100
commita3fff53a48e63064b14f7a1842b20f260bc5a9bc (patch)
tree6d2ce6b1c61e94a0a708a3442977776f07a1d3f1 /src/PositionCache.h
parent5aff87386c21d5a345eff5b1982f4171577a922c (diff)
downloadscintilla-mirror-a3fff53a48e63064b14f7a1842b20f260bc5a9bc.tar.gz
Hide details of PositionCache.
Move class declarations of PositionCache and PositionCacheEntry into cxx file and only define IPositionCache interface and CreatePositionCache factory function in header.
Diffstat (limited to 'src/PositionCache.h')
-rw-r--r--src/PositionCache.h41
1 files changed, 9 insertions, 32 deletions
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 1cbc94495..e8c9293d1 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -163,28 +163,6 @@ public:
Sci::Line linesOnScreen, Sci::Line linesInDoc);
};
-class PositionCacheEntry {
- uint16_t styleNumber;
- uint16_t len;
- uint16_t clock;
- std::unique_ptr<XYPOSITION []> positions;
-public:
- PositionCacheEntry() noexcept;
- // Copy constructor not currently used, but needed for being element in std::vector.
- PositionCacheEntry(const PositionCacheEntry &);
- PositionCacheEntry(PositionCacheEntry &&) noexcept = default;
- // Deleted so PositionCacheEntry objects can not be assigned.
- void operator=(const PositionCacheEntry &) = delete;
- void operator=(PositionCacheEntry &&) = delete;
- ~PositionCacheEntry();
- void Set(unsigned int styleNumber_, std::string_view sv, const XYPOSITION *positions_, uint16_t clock_);
- void Clear() noexcept;
- bool Retrieve(unsigned int styleNumber_, std::string_view sv, XYPOSITION *positions_) const noexcept;
- static size_t Hash(unsigned int styleNumber_, std::string_view sv) noexcept;
- bool NewerThan(const PositionCacheEntry &other) const noexcept;
- void ResetClock() noexcept;
-};
-
class Representation {
public:
static constexpr size_t maxLength = 200;
@@ -269,19 +247,18 @@ public:
bool More() const noexcept;
};
-class PositionCache {
- std::vector<PositionCacheEntry> pces;
- uint16_t clock;
- bool allClear;
+class IPositionCache {
public:
- PositionCache();
- void Clear() noexcept;
- void SetSize(size_t size_);
- size_t GetSize() const noexcept;
- void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
- std::string_view sv, XYPOSITION *positions);
+ virtual ~IPositionCache() = default;
+ virtual void Clear() noexcept = 0;
+ virtual void SetSize(size_t size_) = 0;
+ virtual size_t GetSize() const noexcept = 0;
+ virtual void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
+ std::string_view sv, XYPOSITION *positions) = 0;
};
+std::unique_ptr<IPositionCache> CreatePositionCache();
+
}
#endif