summaryrefslogtreecommitdiff
path: root/src/strfnd.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-07-30 19:31:33 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-07-30 19:31:33 +0300
commit9b294ffa7a1f3cf7ee19111b7e5f4882f130dd21 (patch)
treeb16b2e56eec4fecd961d848b2a6a2e34ce5926ab /src/strfnd.h
parent4b0c3e435715479ce13df7319298884b1589be22 (diff)
downloadminetest-9b294ffa7a1f3cf7ee19111b7e5f4882f130dd21.tar.gz
minetest-9b294ffa7a1f3cf7ee19111b7e5f4882f130dd21.tar.bz2
minetest-9b294ffa7a1f3cf7ee19111b7e5f4882f130dd21.zip
Added message of the day and made it properly configurable using /#setting (not saved to config file yet)
Diffstat (limited to 'src/strfnd.h')
-rw-r--r--src/strfnd.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/strfnd.h b/src/strfnd.h
index 2be92d43b..e3d380e37 100644
--- a/src/strfnd.h
+++ b/src/strfnd.h
@@ -74,6 +74,56 @@ public:
}
};
+class WStrfnd{
+ std::wstring tek;
+ unsigned int p;
+public:
+ void start(std::wstring niinq){
+ tek = niinq;
+ p=0;
+ }
+ unsigned int where(){
+ return p;
+ }
+ void to(unsigned int i){
+ p = i;
+ }
+ std::wstring what(){
+ return tek;
+ }
+ std::wstring next(std::wstring plop){
+ //std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
+ size_t n;
+ std::wstring palautus;
+ if (p < tek.size())
+ {
+ //std::cout<<"\tp<tek.size()"<<std::endl;
+ if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"")
+ {
+ //std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
+ n = tek.size();
+ }
+ else
+ {
+ //std::cout<<"\t\tn != string::npos"<<std::endl;
+ }
+ palautus = tek.substr(p, n-p);
+ p = n + plop.length();
+ }
+ //else
+ //std::cout<<"\tp>=tek.size()"<<std::endl;
+ //std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
+ return palautus;
+ }
+ bool atend(){
+ if(p>=tek.size()) return true;
+ return false;
+ }
+ WStrfnd(std::wstring s){
+ start(s);
+ }
+};
+
inline std::string trim(const std::string &s)
{
std::string str = s;