New code, WiP.
New Path, Character and other simple classes, but a renderer is missing so now nothing gets displayed anymore.
This commit is contained in:
parent
8b11e76835
commit
bcc0937726
13 changed files with 179 additions and 27 deletions
49
src/path.cpp
Normal file
49
src/path.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#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
|
Loading…
Add table
Add a link
Reference in a new issue