libmoost
/home/mhx/git/github/libmoost/include/moost/utils/assert.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef FM_LAST_MOOST_UTILS_ASSERT_H_
00029 #define FM_LAST_MOOST_UTILS_ASSERT_H_
00030 
00031 #include <string>
00032 #include <sstream>
00033 #include <stdexcept>
00034 
00035 #include <boost/filesystem/path.hpp>
00036 
00037 namespace moost { namespace utils {
00038 
00039 void assert_absolute_path(const boost::filesystem::path& path, const std::string& what = "", bool accept_empty_path = true)
00040 {
00041    if (!((path.empty() && accept_empty_path) || path.has_root_directory()))
00042    {
00043       std::ostringstream msg;
00044 
00045       if (!what.empty())
00046       {
00047          msg << what << ": ";
00048       }
00049 
00050       msg << "\"" << path << "\"" << " is not an absolute path";
00051 
00052       throw std::runtime_error(msg.str());
00053    }
00054 }
00055 
00056 } }
00057 
00058 #endif