1 /* 2 This file is part of the Okteta Core library, made within the KDE community. 3 4 SPDX-FileCopyrightText: 2007, 2009 Friedrich W. H. Kossebau <kossebau@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 7 */ 8 9 #ifndef OKTETA_BOOKMARK_HPP 10 #define OKTETA_BOOKMARK_HPP 11 12 // lib 13 #include "oktetacore_export.hpp" 14 #include "address.hpp" 15 #include "size.hpp" 16 // Qt 17 #include <QString> 18 19 namespace Okteta { 20 21 // TODO: do we need the invalid status? 22 class OKTETACORE_EXPORT Bookmark 23 { 24 private: 25 static constexpr Address InvalidAddress = -1; 26 27 public: 28 Bookmark(Address offset); // krazy:exclude=explicit 29 Bookmark(); 30 31 public: 32 bool operator==(const Bookmark& other) const; 33 34 public: 35 Address offset() const; 36 QString name() const; 37 bool isValid() const; 38 39 public: 40 void move(Size offset); 41 void setName(const QString& name); 42 void setOffset(Address offset); 43 44 private: 45 Address mOffset = InvalidAddress; 46 QString mName; 47 }; 48 Bookmark(Address offset)49inline Bookmark::Bookmark(Address offset) : mOffset(offset) {} 50 inline Bookmark::Bookmark() = default; operator ==(const Bookmark & other) const51inline bool Bookmark::operator==(const Bookmark& other) const { return mOffset == other.mOffset; } isValid() const52inline bool Bookmark::isValid() const { return mOffset != InvalidAddress; } offset() const53inline Address Bookmark::offset() const { return mOffset; } name() const54inline QString Bookmark::name() const { return mName; } 55 move(Size offset)56inline void Bookmark::move(Size offset) { mOffset += offset; } setName(const QString & name)57inline void Bookmark::setName(const QString& name) { mName = name; } setOffset(Address offset)58inline void Bookmark::setOffset(Address offset) { mOffset = offset; } 59 60 } 61 62 Q_DECLARE_TYPEINFO(Okteta::Bookmark, Q_MOVABLE_TYPE); 63 64 #endif 65