diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-09-27 00:41:47 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-09-27 13:45:19 -0400 |
commit | ae99d0ce6081d54373b06c618c64567fa03ba028 (patch) | |
tree | 10318cc28eab2d60b4e3de20df3a01bcd5a6e7f8 /svtools | |
parent | ccc779769153ce61f658776f6c2847eb4242e3bd (diff) |
const correctness.
Change-Id: I7303a31d415d23c50d6b7b8a6b071c260cb00bb0
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/treelist.hxx | 9 | ||||
-rw-r--r-- | svtools/source/contnr/treelist.cxx | 22 |
2 files changed, 18 insertions, 13 deletions
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx index 6c1fc0a610a7..b43110af0654 100644 --- a/svtools/inc/svtools/treelist.hxx +++ b/svtools/inc/svtools/treelist.hxx @@ -75,7 +75,7 @@ private: public: SvTreeEntryList(); - SvTreeEntryList(SvTreeEntryList& rList); + SvTreeEntryList(const SvTreeEntryList& rList); void DestroyAll(); void push_back(SvListEntry* pItem); @@ -85,12 +85,13 @@ public: void replace(SvListEntry* pNew, SvListEntry* pOld); void clear(); - bool empty(); + bool empty() const; - size_t size(); - size_t GetPos(SvListEntry* pItem); + size_t size() const; + size_t GetPos(const SvListEntry* pItem) const; SvListEntry* operator[](size_t i); + const SvListEntry* operator[](size_t i) const; SvListEntry* First(); SvListEntry* Next(); SvListEntry* last(); diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index 78fb0b6824c5..0d8087917f30 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -84,17 +84,17 @@ void SvTreeEntryList::clear() maEntryList.clear(); } -bool SvTreeEntryList::empty() +bool SvTreeEntryList::empty() const { return maEntryList.empty(); } -size_t SvTreeEntryList::size() +size_t SvTreeEntryList::size() const { return maEntryList.size(); } -size_t SvTreeEntryList::GetPos( SvListEntry* pItem ) +size_t SvTreeEntryList::GetPos(const SvListEntry* pItem) const { for ( size_t i = 0, n = maEntryList.size(); i < n; ++i ) { if ( maEntryList[ i ] == pItem ) { @@ -104,9 +104,14 @@ size_t SvTreeEntryList::GetPos( SvListEntry* pItem ) return (size_t)~0; } -SvListEntry* SvTreeEntryList::operator[]( size_t i ) +SvListEntry* SvTreeEntryList::operator[](size_t i) { - return i < maEntryList.size() ? maEntryList[ i ] : NULL; + return i < maEntryList.size() ? maEntryList[i] : NULL; +} + +const SvListEntry* SvTreeEntryList::operator[](size_t i) const +{ + return i < maEntryList.size() ? maEntryList[i] : NULL; } SvListEntry* SvTreeEntryList::First() @@ -135,13 +140,12 @@ void SvTreeEntryList::DestroyAll() } } -SvTreeEntryList::SvTreeEntryList(SvTreeEntryList& rList) +SvTreeEntryList::SvTreeEntryList(const SvTreeEntryList& rList) { maEntryList.clear(); maCurrent = 0; - for ( size_t i = 0, n = rList.size(); i < n; ++i ) { - maEntryList.push_back( rList[ i ] ); - } + for ( size_t i = 0, n = rList.size(); i < n; ++i ) + maEntryList.push_back(const_cast<SvListEntry*>(rList[i])); } SvListEntry::SvListEntry() |