Cleanup restoring last position
[LibreOffice.git] / sw / inc / nodeoffset.hxx
blob035925855b31f8b77e767dca8ce41032e2a65398
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #pragma once
11 #include <sal/config.h>
12 #include "swdllapi.h"
13 #include <o3tl/strong_int.hxx>
14 #include <iostream>
16 typedef o3tl::strong_int<sal_Int32, struct Tag_SwNodeOffset> SwNodeOffset;
18 /* Just to make it easier to write arithmetic with these types */
19 template <typename T>
20 inline typename std::enable_if<std::is_signed<T>::value, SwNodeOffset>::type
21 operator+(SwNodeOffset a, T n)
23 return a + SwNodeOffset(n);
26 /* Just to make it easier to write arithmetic with these types */
27 template <typename T>
28 inline typename std::enable_if<std::is_signed<T>::value, SwNodeOffset>::type
29 operator-(SwNodeOffset a, T n)
31 return a - SwNodeOffset(n);
34 inline SwNodeOffset abs(const SwNodeOffset& a) { return a > SwNodeOffset(0) ? a : -a; }
35 inline SwNodeOffset min(const SwNodeOffset& a, const SwNodeOffset& b) { return a > b ? a : b; }
37 constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32);
39 SW_DLLPUBLIC std::ostream& operator<<(std::ostream& s, const SwNodeOffset& index);
41 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */