aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/songloading
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-02-13 13:58:51 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:46 +0100
commita073f3e02752b0483e6a9301cbf02695239c7783 (patch)
tree74f973f6bdc3b5ad9ea53df9061fcf279568ef41 /src/base/songloading
parent2b1073a98ccf6ab97df1c7a05d2d5fe12982da07 (diff)
downloadusdx-a073f3e02752b0483e6a9301cbf02695239c7783.tar.gz
usdx-a073f3e02752b0483e6a9301cbf02695239c7783.tar.xz
usdx-a073f3e02752b0483e6a9301cbf02695239c7783.zip
changed all song paths to boost::filesystem::wpath
all song paths are now wpath so all extensions are also std::wstring and all logging with song filename have to be also std::wstring
Diffstat (limited to 'src/base/songloading')
-rw-r--r--src/base/songloading/songloader.cpp32
-rw-r--r--src/base/songloading/songloader.hpp5
-rw-r--r--src/base/songloading/songloading_strategy.hpp3
-rw-r--r--src/base/songloading/songloading_strategy_txt.cpp13
-rw-r--r--src/base/songloading/songloading_strategy_txt.hpp3
-rw-r--r--src/base/songloading/songloading_strategy_xml.cpp2
-rw-r--r--src/base/songloading/songloading_strategy_xml.hpp3
7 files changed, 26 insertions, 35 deletions
diff --git a/src/base/songloading/songloader.cpp b/src/base/songloading/songloader.cpp
index 9c1401ec..2f3d3508 100644
--- a/src/base/songloading/songloader.cpp
+++ b/src/base/songloading/songloader.cpp
@@ -38,11 +38,11 @@ namespace usdx
Songloader::Songloader(void)
{
// add different strategies to map
- strategies[".txt"] = new SongloadingStrategyTxt();
- strategies[".xml"] = new SongloadingStrategyXml();
+ strategies[L".txt"] = new SongloadingStrategyTxt();
+ strategies[L".xml"] = new SongloadingStrategyXml();
}
- void remove_element(std::pair<std::string, SongloadingStrategy*> e)
+ void remove_element(std::pair<std::wstring, SongloadingStrategy*> e)
{
delete e.second;
e.second = NULL;
@@ -68,18 +68,12 @@ namespace usdx
return instance;
}
- Song *Songloader::load_header(std::string filename)
+ Song *Songloader::load_header(const boost::filesystem::wpath& filename)
{
- std::string extension = "";
-
- size_t found = filename.rfind('.');
- if (found != std::string::npos) {
- extension = filename.substr(found);
- }
-
- std::map<std::string, SongloadingStrategy*>::iterator it = strategies.find(extension);
+ std::wstring ext = extension(filename);
+ std::map<std::wstring, SongloadingStrategy*>::iterator it = strategies.find(ext);
if (it == strategies.end()) {
- LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << extension << "'");
+ LOG4CXX_WARN(log, L"No SongloadingStrategy found for file extension: '" << ext << L"'");
throw NoStrategyException("Unknown file format.");
}
@@ -88,16 +82,10 @@ namespace usdx
Song* Songloader::load_song(Song* song)
{
- std::string extension = "";
-
- size_t found = song->get_filename().rfind('.');
- if (found != std::string::npos) {
- extension = song->get_filename().substr(found);
- }
-
- std::map<std::string, SongloadingStrategy*>::iterator it = strategies.find(extension);
+ std::wstring ext = extension(song->get_filename());
+ std::map<std::wstring, SongloadingStrategy*>::iterator it = strategies.find(ext);
if (it == strategies.end()) {
- LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << extension << "'");
+ LOG4CXX_WARN(log, L"No SongloadingStrategy found for file extension: '" << ext << L"'");
throw NoStrategyException("Unknown file format.");
}
diff --git a/src/base/songloading/songloader.hpp b/src/base/songloading/songloader.hpp
index 57afdefe..0e8a6bd1 100644
--- a/src/base/songloading/songloader.hpp
+++ b/src/base/songloading/songloader.hpp
@@ -28,6 +28,7 @@
#define SONGLOADER_HPP
#include <map>
+#include <boost/filesystem.hpp>
#include <log4cxx/logger.h>
#include "songloading_strategy.hpp"
#include "song.hpp"
@@ -49,7 +50,7 @@ namespace usdx
Songloader(void);
- std::map<std::string, SongloadingStrategy*> strategies;
+ std::map<std::wstring, SongloadingStrategy*> strategies;
/**
* Singleton
@@ -61,7 +62,7 @@ namespace usdx
virtual ~Songloader(void);
- Song* load_header(std::string filename);
+ Song* load_header(const boost::filesystem::wpath& filename);
Song* load_song(Song* song);
};
};
diff --git a/src/base/songloading/songloading_strategy.hpp b/src/base/songloading/songloading_strategy.hpp
index 5cded02d..48e115b7 100644
--- a/src/base/songloading/songloading_strategy.hpp
+++ b/src/base/songloading/songloading_strategy.hpp
@@ -28,6 +28,7 @@
#define SONGLOADING_STRATEGY_HPP
#include <string>
+#include <boost/filesystem.hpp>
#include "song.hpp"
namespace usdx
@@ -41,7 +42,7 @@ namespace usdx
virtual ~SongloadingStrategy() {};
virtual Song* load_song(Song* song) = 0;
- virtual Song* load_header(const std::string& filename) = 0;
+ virtual Song* load_header(const boost::filesystem::wpath& filename) = 0;
};
};
diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp
index efcc3740..7560a9c2 100644
--- a/src/base/songloading/songloading_strategy_txt.cpp
+++ b/src/base/songloading/songloading_strategy_txt.cpp
@@ -81,7 +81,7 @@ namespace usdx
Song* SongloadingStrategyTxt::load_song(Song *song)
{
- LOG4CXX_DEBUG(log, "Starting loading song from file: " << song->get_filename());
+ LOG4CXX_DEBUG(log, L"Starting loading song from file: " << song->get_filename());
File file(song->get_filename());
@@ -109,8 +109,8 @@ namespace usdx
else if (type == L'E') {
// song end
if (file.stream().eof()) {
- LOG4CXX_WARN(log, "End marker found in line " << line_number <<
- " before end of file: '" << song->get_filename() << "'.");
+ LOG4CXX_WARN(log, L"End marker found in line " << line_number <<
+ L" before end of file: '" << song->get_filename() << L"'.");
}
return false;
@@ -126,8 +126,7 @@ namespace usdx
}
else {
LOG4CXX_WARN(log, L"Unknown line in song: '" << line <<
- L"' in file: " << std::wstring(song->get_filename().begin(),
- song->get_filename().end()) <<
+ L"' in file: " << song->get_filename() <<
L" at line " << line_number);
}
}
@@ -190,7 +189,7 @@ namespace usdx
song->new_note(type, beat, length, height, lyric);
}
- Song* SongloadingStrategyTxt::load_header(const std::string& filename)
+ Song* SongloadingStrategyTxt::load_header(const boost::filesystem::wpath& filename)
{
File file(filename);
std::wstring line;
@@ -223,7 +222,7 @@ namespace usdx
}
if (! notes_found) {
- LOG4CXX_WARN(log, "Song: '" << filename << "' has no notes. Ignoring!");
+ LOG4CXX_WARN(log, L"Song: '" << filename << L"' has no notes. Ignoring!");
throw "No notes.";
}
diff --git a/src/base/songloading/songloading_strategy_txt.hpp b/src/base/songloading/songloading_strategy_txt.hpp
index a285042f..13851e6e 100644
--- a/src/base/songloading/songloading_strategy_txt.hpp
+++ b/src/base/songloading/songloading_strategy_txt.hpp
@@ -28,6 +28,7 @@
#define SONGLOADING_STRATEGY_TXT_HPP
#include <string>
+#include <boost/filesystem.hpp>
#include <log4cxx/logger.h>
#include "songloading_strategy.hpp"
#include "utils/file.hpp"
@@ -55,7 +56,7 @@ namespace usdx
virtual ~SongloadingStrategyTxt();
virtual Song* load_song(Song* song);
- virtual Song* load_header(const std::string& filename);
+ virtual Song* load_header(const boost::filesystem::wpath& filename);
};
};
diff --git a/src/base/songloading/songloading_strategy_xml.cpp b/src/base/songloading/songloading_strategy_xml.cpp
index f7fea886..bae799a7 100644
--- a/src/base/songloading/songloading_strategy_xml.cpp
+++ b/src/base/songloading/songloading_strategy_xml.cpp
@@ -42,7 +42,7 @@ namespace usdx
return song;
}
- Song* SongloadingStrategyXml::load_header(const std::string& filename)
+ Song* SongloadingStrategyXml::load_header(const boost::filesystem::wpath& filename)
{
return NULL;
}
diff --git a/src/base/songloading/songloading_strategy_xml.hpp b/src/base/songloading/songloading_strategy_xml.hpp
index a01f9c11..76e3f76e 100644
--- a/src/base/songloading/songloading_strategy_xml.hpp
+++ b/src/base/songloading/songloading_strategy_xml.hpp
@@ -27,6 +27,7 @@
#ifndef SONGLOADING_STRATEGY_XML_HPP
#define SONGLOADING_STRATEGY_XML_HPP
+#include <boost/filesystem.hpp>
#include "songloading_strategy.hpp"
namespace usdx
@@ -38,7 +39,7 @@ namespace usdx
virtual ~SongloadingStrategyXml(void);
virtual Song* load_song(Song* song);
- virtual Song* load_header(const std::string& filename);
+ virtual Song* load_header(const boost::filesystem::wpath& filename);
};
};