aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graph_base.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-04-23 02:00:05 +0800
committercrupest <crupest@outlook.com>2020-04-23 02:00:05 +0800
commit922d7f6c96f81a33538900f8a8992a5b6f640874 (patch)
tree71bd88e931137a23d4c4fcf7a27c55859ab5b0f4 /include/cru/platform/graph_base.hpp
parentf42531cc4c0f49451c4df30e4243e39581751215 (diff)
downloadcru-922d7f6c96f81a33538900f8a8992a5b6f640874.tar.gz
cru-922d7f6c96f81a33538900f8a8992a5b6f640874.tar.bz2
cru-922d7f6c96f81a33538900f8a8992a5b6f640874.zip
...
Diffstat (limited to 'include/cru/platform/graph_base.hpp')
-rw-r--r--include/cru/platform/graph_base.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/cru/platform/graph_base.hpp b/include/cru/platform/graph_base.hpp
index 0b997770..c880c7a2 100644
--- a/include/cru/platform/graph_base.hpp
+++ b/include/cru/platform/graph_base.hpp
@@ -229,6 +229,15 @@ struct TextRange final {
gsl::index GetEnd() const { return position + count; }
+ TextRange Normalize() const {
+ auto result = *this;
+ if (result.count < 0) {
+ result.position += result.count;
+ result.count = -result.count;
+ }
+ return result;
+ }
+
gsl::index position = 0;
gsl::index count = 0;
};