Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
kome::core::ResourceBundle Class Reference

resource bundle class More...

#include <ResourceBundle.h>

Public Member Functions

std::string searchResource (const char *name, const char *module, const char *ext)
 searches resource file More...
 

Static Public Member Functions

static ResourceBundlegetInstance ()
 gets resource bundle object (This is the only object) More...
 

Protected Member Functions

 ResourceBundle ()
 constructor
 
virtual ~ResourceBundle ()
 destructor
 
std::string searchResource (const char *path, const char *name, const char *module, const char *ext)
 searches resource file More...
 

Detailed Description

resource bundle class

Definition at line 23 of file ResourceBundle.h.

Member Function Documentation

static ResourceBundle & kome::core::ResourceBundle::getInstance ( )
static

gets resource bundle object (This is the only object)

Returns
resource bundle object

Definition at line 106 of file ResourceBundle.cpp.

106  {
107  // create instance (This is the only object.)
108  static ResourceBundle rb;
109 
110  return rb;
111 }
resource bundle class
std::string kome::core::ResourceBundle::searchResource ( const char *  name,
const char *  module,
const char *  ext 
)

searches resource file

Parameters
[in]nameresource name
[in]modulemodule name
[in]extfile extension
Returns
resource file path

Definition at line 42 of file ResourceBundle.cpp.

42  {
43  // manager
45 
46  // return object
47 // std::string res = searchResource( msppMgr.getMsppDir(), name, module, ext );
48  std::string res = searchResource( getplugindir().c_str(), name, module, ext ); // @date 2013.06.25 <Mod> M.Izumi
49 
50  return res;
51 }
static MsppManager & getInstance()
gets MsppManager object (This is the only object.)
Mass++ manager class.
Definition: MsppManager.h:28
std::string getplugindir()
gets mspp plugin paths
std::string searchResource(const char *name, const char *module, const char *ext)
searches resource file

Here is the call graph for this function:

std::string kome::core::ResourceBundle::searchResource ( const char *  path,
const char *  name,
const char *  module,
const char *  ext 
)
protected

searches resource file

Parameters
[in]pathsearch path
[in]nameresource name
[in]modulemodule name
[in]extfile extension
Returns
resource file path

Definition at line 53 of file ResourceBundle.cpp.

58  {
59  // return object
60  std::string res;
61 
62  // create string object
63  std::string n = tolowercase( name );
64  std::string m = tolowercase( module );
65  std::string e = tolowercase( ext );
66 
67  if( path == NULL || n.empty() ) {
68  return res;
69  }
70 
71  // path object
72  boost::filesystem::path p( path, boost::filesystem::native );
73  boost::filesystem::directory_iterator end;
74 
75  // check path
76  if( !boost::filesystem::exists( p ) ) {
77  return res;
78  }
79 
80  // search
81  if( boost::filesystem::is_directory( p ) ) { // directory
82  for( boost::filesystem::directory_iterator it( p ); it != end && res.empty(); it++ ) {
83  boost::filesystem::path child = boost::filesystem::absolute( *it );
84  res = searchResource( child.string().c_str(), name, module, ext );
85  }
86  }
87  else { // file
88  std::string absPath = boost::filesystem::absolute( p ).string();
89 
90  std::string fileName = tolowercase( getfilename( absPath.c_str() ).c_str() );
91  std::string fileExt = tolowercase( getext( absPath.c_str() ).c_str() );
92  std::string fileDir = tolowercase( getdir( absPath.c_str() ).c_str() );
93 
94  // check
95  if( fileName.find( n ) != fileName.npos
96  && ( m.empty() || fileDir.find( m ) != fileDir.npos )
97  && ( e.empty() || fileExt.compare( e ) == 0 ) ) {
98  res = absPath;
99  }
100  }
101 
102  return res;
103 }
std::string getfilename(const char *path)
get file name
#define NULL
Definition: CoreMacros.h:18
std::string tolowercase(const char *s)
convert all of the characters in the string given to lower case
std::string getdir(const char *path)
get dir that the file exists
std::string searchResource(const char *name, const char *module, const char *ext)
searches resource file
std::string getext(const char *path)
get the extension of the file

Here is the call graph for this function:


The documentation for this class was generated from the following files: