Improve const correctness

This commit is contained in:
Martchus 2018-12-23 18:57:03 +01:00
parent a25282b3d1
commit e29457dfd0
2 changed files with 4 additions and 6 deletions

View File

@ -136,9 +136,8 @@ void Entry::setParent(NodeEntry *parent, int index)
/*! /*!
* \brief Returns an indication whether the instance is an indirect child of the specified \a entry. * \brief Returns an indication whether the instance is an indirect child of the specified \a entry.
* \todo Make \a entry const in v4.
*/ */
bool Entry::isIndirectChildOf(NodeEntry *entry) const bool Entry::isIndirectChildOf(const NodeEntry *entry) const
{ {
if (!parent()) { if (!parent()) {
return false; return false;
@ -348,9 +347,8 @@ void NodeEntry::replaceChild(size_t at, Entry *newChild)
* if the entry specified by the provided \a path does not exist. The parent of the entry * if the entry specified by the provided \a path does not exist. The parent of the entry
* to be created must exist. Specify nullptr if no entries should be created (default). * to be created must exist. Specify nullptr if no entries should be created (default).
* \returns Returns the entry if found (or created); otherwise nullptr is returned. * \returns Returns the entry if found (or created); otherwise nullptr is returned.
* \todo Use dedicated flags or at least make \a creationType const in v4.
*/ */
Entry *NodeEntry::entryByPath(list<string> &path, bool includeThis, EntryType *creationType) Entry *NodeEntry::entryByPath(list<string> &path, bool includeThis, const EntryType *creationType)
{ {
if (path.empty()) { if (path.empty()) {
return nullptr; return nullptr;

View File

@ -41,7 +41,7 @@ public:
NodeEntry *parent() const; NodeEntry *parent() const;
void setParent(NodeEntry *parent, int index = -1); void setParent(NodeEntry *parent, int index = -1);
int index() const; int index() const;
bool isIndirectChildOf(NodeEntry *entry) const; bool isIndirectChildOf(const NodeEntry *entry) const;
std::list<std::string> path() const; std::list<std::string> path() const;
void path(std::list<std::string> &res) const; void path(std::list<std::string> &res) const;
virtual void make(std::ostream &stream) const = 0; virtual void make(std::ostream &stream) const = 0;
@ -126,7 +126,7 @@ public:
const std::vector<Entry *> &children() const; const std::vector<Entry *> &children() const;
void deleteChildren(int begin, int end); void deleteChildren(int begin, int end);
void replaceChild(std::size_t at, Entry *newChild); void replaceChild(std::size_t at, Entry *newChild);
Entry *entryByPath(std::list<std::string> &path, bool includeThis = true, EntryType *creationType = nullptr); Entry *entryByPath(std::list<std::string> &path, bool includeThis = true, const EntryType *creationType = nullptr);
bool isExpandedByDefault() const; bool isExpandedByDefault() const;
void setExpandedByDefault(bool expandedByDefault); void setExpandedByDefault(bool expandedByDefault);
void make(std::ostream &stream) const override; void make(std::ostream &stream) const override;