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.
This commit is contained in:
curt
2003-02-28 01:02:26 +00:00
parent 1dac4b2dc1
commit b63464d239
2 changed files with 8 additions and 8 deletions

View File

@@ -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);

View File

@@ -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