diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2018-05-12 19:57:19 +1000 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-16 09:07:14 +0200 |
commit | 99dbaba70afb91ed3961f9ff627c35bf54d66bef (patch) | |
tree | f9d6ec2dd1ce8d90a561f89c8bfe9a604578b915 /include/tools | |
parent | 8611689f0df73daeebb261b0c06c8a1727c17fe3 (diff) |
tools: test Pair
Change-Id: I03e48c134ec9b8fc53c247ced231f209e1205cb1
Reviewed-on: https://gerrit.libreoffice.org/54189
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/Pair.hxx | 80 | ||||
-rw-r--r-- | include/tools/gen.hxx | 39 |
2 files changed, 81 insertions, 38 deletions
diff --git a/include/tools/Pair.hxx b/include/tools/Pair.hxx new file mode 100644 index 000000000000..87fdd810c88f --- /dev/null +++ b/include/tools/Pair.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLS_PAIR_HXX +#define INCLUDED_TOOLS_PAIR_HXX + +#include <tools/toolsdllapi.h> + +class Point; +class Size; +class SvStream; + +namespace rtl +{ +class OString; +} + +class SAL_WARN_UNUSED Pair +{ +public: + Pair() + : nA(0) + , nB(0) + { + } + Pair(long _nA, long _nB) + : nA(_nA) + , nB(_nB) + { + } + + long A() const { return nA; } + long B() const { return nB; } + + long& A() { return nA; } + long& B() { return nB; } + + TOOLS_DLLPUBLIC rtl::OString toString() const; + TOOLS_DLLPUBLIC friend SvStream& ReadPair(SvStream& rIStream, Pair& rPair); + TOOLS_DLLPUBLIC friend SvStream& WritePair(SvStream& rOStream, const Pair& rPair); + +protected: + long nA; + long nB; +}; + +namespace tools +{ +namespace detail +{ +// Used to implement operator == for subclasses of Pair: +inline bool equal(Pair const& p1, Pair const& p2) { return p1.A() == p2.A() && p1.B() == p2.B(); } + +} // namespace detail +} // namespace tools + +SAL_DLLPUBLIC_EXPORT SvStream& ReadPair(SvStream& rIStream, Point& v); +SAL_DLLPUBLIC_EXPORT SvStream& WritePair(SvStream& rOStream, const Point& v); +SAL_DLLPUBLIC_EXPORT SvStream& ReadPair(SvStream& rIStream, Size& v); +SAL_DLLPUBLIC_EXPORT SvStream& WritePair(SvStream& rOStream, const Size& v); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 90486536c401..1b117a642e6b 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -20,6 +20,7 @@ #define INCLUDED_TOOLS_GEN_HXX #include <tools/toolsdllapi.h> +#include <tools/Pair.hxx> #include <limits.h> #include <algorithm> @@ -34,39 +35,6 @@ namespace rtl enum TriState { TRISTATE_FALSE, TRISTATE_TRUE, TRISTATE_INDET }; -// Pair - -class SAL_WARN_UNUSED Pair -{ -public: - Pair() : nA(0), nB(0) {} - Pair( long _nA, long _nB ) : nA(_nA), nB(_nB) {} - - long A() const { return nA; } - long B() const { return nB; } - - long& A() { return nA; } - long& B() { return nB; } - - TOOLS_DLLPUBLIC rtl::OString toString() const; - TOOLS_DLLPUBLIC friend SvStream& ReadPair( SvStream& rIStream, Pair& rPair ); - TOOLS_DLLPUBLIC friend SvStream& WritePair( SvStream& rOStream, const Pair& rPair ); - -protected: - long nA; - long nB; -}; - -namespace tools { namespace detail { - -// Used to implement operator == for subclasses of Pair: -inline bool equal(Pair const & p1, Pair const & p2) -{ - return p1.A() == p2.A() && p1.B() == p2.B(); -} - -} } - // Point class Size; @@ -744,11 +712,6 @@ inline std::basic_ostream<charT, traits> & operator <<( << "@(" << rectangle.getX() << ',' << rectangle.getY() << ")"; } -inline SvStream& ReadPair( SvStream& rIStream, Point& v ) { return ReadPair(rIStream, v.toPair()); } -inline SvStream& WritePair( SvStream& rOStream, const Point& v ) { return WritePair(rOStream, v.toPair()); } -inline SvStream& ReadPair( SvStream& rIStream, Size& v ) { return ReadPair(rIStream, v.toPair()); } -inline SvStream& WritePair( SvStream& rOStream, const Size& v ) { return WritePair(rOStream, v.toPair()); } - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |