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:
@@ -105,7 +105,7 @@ void SGPath::concat( const string& p ) {
|
|||||||
|
|
||||||
|
|
||||||
// Get the file part of the path (everything after the last path sep)
|
// 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);
|
int index = path.rfind(SG_PATH_SEP);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return path.substr(index + 1);
|
return path.substr(index + 1);
|
||||||
@@ -116,7 +116,7 @@ string SGPath::file() {
|
|||||||
|
|
||||||
|
|
||||||
// get the directory part of the path.
|
// get the directory part of the path.
|
||||||
string SGPath::dir() {
|
string SGPath::dir() const {
|
||||||
int index = path.rfind(SG_PATH_SEP);
|
int index = path.rfind(SG_PATH_SEP);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return path.substr(0, index);
|
return path.substr(0, index);
|
||||||
@@ -126,7 +126,7 @@ string SGPath::dir() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the base part of the path (everything but the extension.)
|
// get the base part of the path (everything but the extension.)
|
||||||
string SGPath::base() {
|
string SGPath::base() const {
|
||||||
int index = path.rfind(".");
|
int index = path.rfind(".");
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return path.substr(0, index);
|
return path.substr(0, index);
|
||||||
@@ -136,7 +136,7 @@ string SGPath::base() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the extention (everything after the final ".")
|
// get the extention (everything after the final ".")
|
||||||
string SGPath::extension() {
|
string SGPath::extension() const {
|
||||||
int index = path.rfind(".");
|
int index = path.rfind(".");
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return path.substr(index + 1);
|
return path.substr(index + 1);
|
||||||
|
|||||||
@@ -98,25 +98,25 @@ public:
|
|||||||
* Get the file part of the path (everything after the last path sep)
|
* Get the file part of the path (everything after the last path sep)
|
||||||
* @return file string
|
* @return file string
|
||||||
*/
|
*/
|
||||||
string file();
|
string file() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the directory part of the path.
|
* Get the directory part of the path.
|
||||||
* @return directory string
|
* @return directory string
|
||||||
*/
|
*/
|
||||||
string dir();
|
string dir() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the base part of the path (everything but the extension.)
|
* Get the base part of the path (everything but the extension.)
|
||||||
* @return the base string
|
* @return the base string
|
||||||
*/
|
*/
|
||||||
string base();
|
string base() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extention part of the path (everything after the final ".")
|
* Get the extention part of the path (everything after the final ".")
|
||||||
* @return the extention string
|
* @return the extention string
|
||||||
*/
|
*/
|
||||||
string extension();
|
string extension() const;
|
||||||
|
|
||||||
/** Get the path string
|
/** Get the path string
|
||||||
* @return path string
|
* @return path string
|
||||||
|
|||||||
Reference in New Issue
Block a user