From: curt Date: Fri, 28 Feb 2003 01:02:26 +0000 (+0000) Subject: Bernie Bright: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b63464d23982dda01458fbe4b411e878a4feeea8;p=simgear.git Bernie Bright: Could the file(), dir(), base() and extension() functions be made const member functions. As it stands they cannot be applied to const reference/pointer values which limits their usefulness. Curt: Yes. --- diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index f18543a7..dc9be8eb 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -105,7 +105,7 @@ void SGPath::concat( const string& p ) { // Get the file part of the path (everything after the last path sep) -string SGPath::file() { +string SGPath::file() const { int index = path.rfind(SG_PATH_SEP); if (index >= 0) { return path.substr(index + 1); @@ -116,7 +116,7 @@ string SGPath::file() { // get the directory part of the path. -string SGPath::dir() { +string SGPath::dir() const { int index = path.rfind(SG_PATH_SEP); if (index >= 0) { return path.substr(0, index); @@ -126,7 +126,7 @@ string SGPath::dir() { } // get the base part of the path (everything but the extension.) -string SGPath::base() { +string SGPath::base() const { int index = path.rfind("."); if (index >= 0) { return path.substr(0, index); @@ -136,7 +136,7 @@ string SGPath::base() { } // get the extention (everything after the final ".") -string SGPath::extension() { +string SGPath::extension() const { int index = path.rfind("."); if (index >= 0) { return path.substr(index + 1); diff --git a/simgear/misc/sg_path.hxx b/simgear/misc/sg_path.hxx index 045f584a..9b0e5939 100644 --- a/simgear/misc/sg_path.hxx +++ b/simgear/misc/sg_path.hxx @@ -98,25 +98,25 @@ public: * Get the file part of the path (everything after the last path sep) * @return file string */ - string file(); + string file() const; /** * Get the directory part of the path. * @return directory string */ - string dir(); + string dir() const; /** * Get the base part of the path (everything but the extension.) * @return the base string */ - string base(); + string base() const; /** * Get the extention part of the path (everything after the final ".") * @return the extention string */ - string extension(); + string extension() const; /** Get the path string * @return path string