mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 13:34:58 +00:00
add shared_string.hpp
This commit is contained in:
parent
4ef8c6e469
commit
61eaf0a32f
@ -421,6 +421,7 @@
|
|||||||
<Unit filename="..\..\src\sha1.cpp" />
|
<Unit filename="..\..\src\sha1.cpp" />
|
||||||
<Unit filename="..\..\src\sha1.hpp" />
|
<Unit filename="..\..\src\sha1.hpp" />
|
||||||
<Unit filename="..\..\src\shared_object.hpp" />
|
<Unit filename="..\..\src\shared_object.hpp" />
|
||||||
|
<Unit filename="..\..\src\shared_string.hpp" />
|
||||||
<Unit filename="..\..\src\show_dialog.cpp" />
|
<Unit filename="..\..\src\show_dialog.cpp" />
|
||||||
<Unit filename="..\..\src\show_dialog.hpp" />
|
<Unit filename="..\..\src\show_dialog.hpp" />
|
||||||
<Unit filename="..\..\src\sound.cpp" />
|
<Unit filename="..\..\src\sound.cpp" />
|
||||||
|
@ -452,6 +452,7 @@
|
|||||||
<Unit filename="..\..\src\sha1.cpp" />
|
<Unit filename="..\..\src\sha1.cpp" />
|
||||||
<Unit filename="..\..\src\sha1.hpp" />
|
<Unit filename="..\..\src\sha1.hpp" />
|
||||||
<Unit filename="..\..\src\shared_object.hpp" />
|
<Unit filename="..\..\src\shared_object.hpp" />
|
||||||
|
<Unit filename="..\..\src\shared_string.hpp" />
|
||||||
<Unit filename="..\..\src\show_dialog.cpp" />
|
<Unit filename="..\..\src\show_dialog.cpp" />
|
||||||
<Unit filename="..\..\src\show_dialog.hpp" />
|
<Unit filename="..\..\src\show_dialog.hpp" />
|
||||||
<Unit filename="..\..\src\sound.cpp" />
|
<Unit filename="..\..\src\sound.cpp" />
|
||||||
|
@ -678,6 +678,10 @@
|
|||||||
RelativePath="..\..\src\shared_object.hpp"
|
RelativePath="..\..\src\shared_object.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\shared_string.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\team.cpp"
|
RelativePath="..\..\src\team.cpp"
|
||||||
>
|
>
|
||||||
|
59
src/shared_string.hpp
Normal file
59
src/shared_string.hpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2009 by Chris Hopman <cjhopman@gmail.com>
|
||||||
|
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2
|
||||||
|
or at your option any later version.
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY.
|
||||||
|
|
||||||
|
See the COPYING file for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "shared_object.hpp"
|
||||||
|
#include "tstring.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct shared_string : public shared_object<std::string> {
|
||||||
|
typedef shared_object<std::string> super;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
shared_string(const T& o) : super(o) { }
|
||||||
|
const char* c_str() const {
|
||||||
|
return get().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
operator std::string() const {
|
||||||
|
return super::operator std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
operator t_string() const {
|
||||||
|
return super::operator std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return get().empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t find(const std::string& str, size_t pos = 0) const {
|
||||||
|
return get().find(str, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string substr(size_t pos = 0, size_t n = std::string::npos) const {
|
||||||
|
return get().substr(pos, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size() const {
|
||||||
|
return get().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string::const_iterator begin() const {
|
||||||
|
return get().begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string::const_iterator end() const {
|
||||||
|
return get().end();
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user