dynamic_library_identifier.h from osgDesigner at Krugle
Show dynamic_library_identifier.h syntax highlighted
#ifndef __GEN_PROG_PLUGIN_DETAIL_DYNAMIC_LIBRARY_IDENTIFIER_H__
#define __GEN_PROG_PLUGIN_DETAIL_DYNAMIC_LIBRARY_IDENTIFIER_H__ 1
// ** standart include
#include <string>
// ** logger include
#include <osg/Notify>
// ** filesystem include
#include <boost/filesystem/path.hpp>
namespace gen_prog
{
namespace plugin
{
namespace detail
{
class dynamic_library_suffix_prefix
{
public:
static const char * suffix()
{
#if defined(WIN32)
#ifdef __CYGWIN__
return (".dll");
#elif defined(__MINGW32__)
return ".dll";
#else
#ifdef _DEBUG
return ("d.dll");
#else
return (".dll");
#endif
#endif
#elif macintosh
return ("");
#elif defined(__hpux__)
return (".sl");
#else
return (".so");
#endif
}
static const char * prefix()
{
#if defined(WIN32)
#ifdef __CYGWIN__
return ("");
#elif defined(__MINGW32__)
return ("");
#else
#ifdef _DEBUG
return ("");
#else
return ("");
#endif
#endif
#elif macintosh
return ("");
#elif defined(__hpux__)
return ("lib");
#else
return ("lib");
#endif
}
};
template < typename DLSP >
class dynamic_library_identifier_helper
{
typedef DLSP suffix_prefix_policy;
public:
typedef boost::filesystem::path path_type;
typedef std::string key_type;
key_type pathToKey(const path_type & dlPath) const
{
if (isValidPath(dlPath) == false) return ("");
key_type dlKey;
std::string fileName = dlPath.leaf();
std::string prefix(suffix_prefix_policy::prefix());
std::string suffix(suffix_prefix_policy::suffix());
if ((fileName.find(prefix) == 0) && (fileName.rfind(suffix) == fileName.size() - suffix.size()))
{
dlKey = fileName;
dlKey.erase(fileName.size() - suffix.size(), suffix.size());
dlKey.erase(0, prefix.size());
}
return (dlKey);
}
bool isValidPath(const path_type & dlPath) const
{ return (dlPath.empty() == false); }
bool isValidKey(const key_type & dlKey) const
{ return (dlKey.empty() == false); }
};
typedef dynamic_library_identifier_helper< dynamic_library_suffix_prefix > dynamic_library_identifier;
}
}
}
#endif // ** __GEN_PROG_PLUGIN_DETAIL_DYNAMIC_LIBRARY_IDENTIFIER_H__ ** //
See more files for this project here