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:
King_DuckZ 2014-02-12 00:27:55 +01:00
parent 8b11e76835
commit bcc0937726
13 changed files with 179 additions and 27 deletions

49
src/path.cpp Normal file
View 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