New Path, Character and other simple classes, but a renderer is missing so now nothing gets displayed anymore.
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#include "path.hpp"
|
|
#include <cassert>
|
|
#include <sstream>
|
|
#include <ciso646>
|
|
|
|
namespace cloonel {
|
|
namespace {
|
|
///---------------------------------------------------------------------
|
|
///---------------------------------------------------------------------
|
|
std::string GetCleanBasePath (const std::string&& parPath) {
|
|
const size_t pathlen = parPath.size();
|
|
switch (pathlen) {
|
|
case 0:
|
|
return std::string("/");
|
|
case 1:
|
|
return parPath;
|
|
default:
|
|
if (parPath[pathlen - 1] == '/')
|
|
return parPath.substr(0, pathlen - 1);
|
|
else
|
|
return parPath;
|
|
}
|
|
}
|
|
} //unnamed namespace
|
|
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
Path::Path (const char* parBasePath) :
|
|
m_basePath(GetCleanBasePath(std::string(parBasePath)))
|
|
{
|
|
}
|
|
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
std::string Path::GetFullPath (const std::string& parPath) const {
|
|
std::ostringstream oss;
|
|
oss << m_basePath << '/' << parPath;
|
|
return oss.str();
|
|
}
|
|
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
std::string Path::GetFullPath (const char* parPath) const {
|
|
assert(parPath);
|
|
std::ostringstream oss;
|
|
oss << m_basePath << '/' << parPath;
|
|
return oss.str();
|
|
}
|
|
} // namespace cloonel
|