From cf3ac50e3c76e3aa0d9e5c30ba4e83e6a4c4d85d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 8 Oct 2003 21:01:50 +0000 Subject: add String::lastChar() method svn-id: r10684 --- common/str.cpp | 4 ++++ common/str.h | 1 + 2 files changed, 5 insertions(+) diff --git a/common/str.cpp b/common/str.cpp index 416b4d828f..0d2d3613f5 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -140,6 +140,10 @@ String &String::operator += (char c) { return *this; } +char lastChar() const { + return (_len > 0) ? _str[_len-1] : 0; +} + void String::deleteLastChar() { if (_len > 0) { ensureCapacity(_len - 1, true); diff --git a/common/str.h b/common/str.h index af318ee3d0..a4570bead8 100644 --- a/common/str.h +++ b/common/str.h @@ -108,6 +108,7 @@ public: return _str[idx]; } + char lastChar() const; void deleteLastChar(); void deleteChar(int p); void clear(); -- cgit v1.2.3