File indexing completed on 2024-04-14 15:52:43
0001 /* 0002 This file is part of the Okteta Core library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2007, 2009 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef OKTETA_BOOKMARK_HPP 0010 #define OKTETA_BOOKMARK_HPP 0011 0012 // lib 0013 #include "oktetacore_export.hpp" 0014 #include "address.hpp" 0015 #include "size.hpp" 0016 // Qt 0017 #include <QString> 0018 0019 namespace Okteta { 0020 0021 // TODO: do we need the invalid status? 0022 class OKTETACORE_EXPORT Bookmark 0023 { 0024 private: 0025 static constexpr Address InvalidAddress = -1; 0026 0027 public: 0028 Bookmark(Address offset); // krazy:exclude=explicit 0029 Bookmark(); 0030 Bookmark(const Bookmark&) = default; 0031 0032 ~Bookmark() = default; 0033 0034 Bookmark& operator=(const Bookmark&) = default; 0035 0036 public: 0037 bool operator==(const Bookmark& other) const; 0038 0039 public: 0040 Address offset() const; 0041 QString name() const; 0042 bool isValid() const; 0043 0044 public: 0045 void move(Size offset); 0046 void setName(const QString& name); 0047 void setOffset(Address offset); 0048 0049 private: 0050 Address mOffset = InvalidAddress; 0051 QString mName; 0052 }; 0053 0054 inline Bookmark::Bookmark(Address offset) : mOffset(offset) {} 0055 inline Bookmark::Bookmark() = default; 0056 inline bool Bookmark::operator==(const Bookmark& other) const { return mOffset == other.mOffset; } 0057 inline bool Bookmark::isValid() const { return mOffset != InvalidAddress; } 0058 inline Address Bookmark::offset() const { return mOffset; } 0059 inline QString Bookmark::name() const { return mName; } 0060 0061 inline void Bookmark::move(Size offset) { mOffset += offset; } 0062 inline void Bookmark::setName(const QString& name) { mName = name; } 0063 inline void Bookmark::setOffset(Address offset) { mOffset = offset; } 0064 0065 } 0066 0067 Q_DECLARE_TYPEINFO(Okteta::Bookmark, Q_MOVABLE_TYPE); 0068 0069 #endif