Replaced boolstr with toString specialisation for bool;
fixed translations in current user. Otherwise many many cosmetic only changes. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@15071 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
dafc30b2d0
commit
9ee06a5fe0
@ -95,7 +95,7 @@ void SingleAchievement::load(XMLNode * input)
|
|||||||
void SingleAchievement::save(std::ofstream & out)
|
void SingleAchievement::save(std::ofstream & out)
|
||||||
{
|
{
|
||||||
out << " <achievement id=\"" << m_id << "\" "
|
out << " <achievement id=\"" << m_id << "\" "
|
||||||
<< "achieved=\"" << StringUtils::boolstr(m_achieved) << "\"";
|
<< "achieved=\"" << StringUtils::toString(m_achieved) << "\"";
|
||||||
if(!m_achieved)
|
if(!m_achieved)
|
||||||
{
|
{
|
||||||
out << " value=\"" << StringUtils::toString(m_progress) << "\"";
|
out << " value=\"" << StringUtils::toString(m_progress) << "\"";
|
||||||
@ -153,12 +153,16 @@ void MapAchievement::load(XMLNode * input)
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
void MapAchievement::save(std::ofstream & out)
|
void MapAchievement::save(std::ofstream & out)
|
||||||
{
|
{
|
||||||
out << " <achievement id=\"" << m_id << "\" achieved=\"" << StringUtils::boolstr(m_achieved) << "\">\n";
|
out << " <achievement id=\"" << m_id << "\" achieved=\""
|
||||||
|
<< StringUtils::toString(m_achieved) << "\">\n";
|
||||||
if(!m_achieved)
|
if(!m_achieved)
|
||||||
{
|
{
|
||||||
std::map<std::string, int>::iterator iter;
|
std::map<std::string, int>::iterator i;
|
||||||
for ( iter = m_progress_map.begin(); iter != m_progress_map.end(); ++iter ) {
|
for ( i = m_progress_map.begin(); i != m_progress_map.end(); ++i )
|
||||||
out << " <entry key=\"" << iter->first.c_str() << "\" value=\"" << StringUtils::toString(iter->second) << "\"/>\n";
|
{
|
||||||
|
out << " <entry key=\"" << i->first.c_str()
|
||||||
|
<< "\" value=\"" << StringUtils::toString(i->second)
|
||||||
|
<< "\"/>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << " </achievement>\n";
|
out << " </achievement>\n";
|
||||||
@ -178,7 +182,8 @@ int MapAchievement::getValue(const std::string & key)
|
|||||||
void MapAchievement::reset()
|
void MapAchievement::reset()
|
||||||
{
|
{
|
||||||
std::map<std::string, int>::iterator iter;
|
std::map<std::string, int>::iterator iter;
|
||||||
for ( iter = m_progress_map.begin(); iter != m_progress_map.end(); ++iter ) {
|
for ( iter = m_progress_map.begin(); iter != m_progress_map.end(); ++iter )
|
||||||
|
{
|
||||||
iter->second = 0;
|
iter->second = 0;
|
||||||
}
|
}
|
||||||
} // reset
|
} // reset
|
||||||
|
@ -112,7 +112,7 @@ void AchievementsSlot::createFreshSlot()
|
|||||||
void AchievementsSlot::save(std::ofstream & out)
|
void AchievementsSlot::save(std::ofstream & out)
|
||||||
{
|
{
|
||||||
out << " <slot user_id=\"" << m_id.c_str()
|
out << " <slot user_id=\"" << m_id.c_str()
|
||||||
<< "\" online=\"" << StringUtils::boolstr(m_online)
|
<< "\" online=\"" << StringUtils::toString(m_online)
|
||||||
<< "\"> \n";
|
<< "\"> \n";
|
||||||
std::map<uint32_t, Achievement*>::const_iterator i;
|
std::map<uint32_t, Achievement*>::const_iterator i;
|
||||||
for(i = m_achievements.begin(); i != m_achievements.end(); i++)
|
for(i = m_achievements.begin(); i != m_achievements.end(); i++)
|
||||||
|
@ -93,8 +93,14 @@ void Challenge::setSolved(RaceManager::Difficulty d)
|
|||||||
void Challenge::save(std::ofstream& writer)
|
void Challenge::save(std::ofstream& writer)
|
||||||
{
|
{
|
||||||
writer << " <" << m_data->getId().c_str() << ">\n"
|
writer << " <" << m_data->getId().c_str() << ">\n"
|
||||||
<< " <easy solved=\"" << StringUtils::boolstr(isSolved(RaceManager::DIFFICULTY_EASY)) << "\"/>\n"
|
<< " <easy solved=\""
|
||||||
<< " <medium solved=\"" << StringUtils::boolstr(isSolved(RaceManager::DIFFICULTY_MEDIUM)) << "\"/>\n"
|
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_EASY))
|
||||||
<< " <hard solved=\"" << StringUtils::boolstr(isSolved(RaceManager::DIFFICULTY_HARD)) << "\"/>\n"
|
<< "\"/>\n"
|
||||||
|
<< " <medium solved=\""
|
||||||
|
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_MEDIUM))
|
||||||
|
<< "\"/>\n"
|
||||||
|
<< " <hard solved=\""
|
||||||
|
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_HARD))
|
||||||
|
<< "\"/>\n"
|
||||||
<< " </" << m_data->getId().c_str() << ">\n";
|
<< " </" << m_data->getId().c_str() << ">\n";
|
||||||
} // save
|
} // save
|
||||||
|
@ -1187,7 +1187,10 @@ void PostProcessing::render()
|
|||||||
drawQuad(cam, m_material);
|
drawQuad(cam, m_material);
|
||||||
|
|
||||||
// Blur
|
// Blur
|
||||||
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1), irr_driver->getRTT(RTT_QUARTER2), 4. / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1),
|
||||||
|
irr_driver->getRTT(RTT_QUARTER2),
|
||||||
|
4.f / UserConfigParams::m_width,
|
||||||
|
4.f / UserConfigParams::m_height);
|
||||||
|
|
||||||
// Calculate the sun's position in texcoords
|
// Calculate the sun's position in texcoords
|
||||||
const core::vector3df pos = sun->getPosition();
|
const core::vector3df pos = sun->getPosition();
|
||||||
|
@ -949,7 +949,7 @@ int handleCmdLine()
|
|||||||
if (try_login)
|
if (try_login)
|
||||||
{
|
{
|
||||||
irr::core::stringw s;
|
irr::core::stringw s;
|
||||||
Online::CurrentUser::SignInRequest* request =
|
Online::XMLRequest* request =
|
||||||
Online::CurrentUser::get()->requestSignIn(login, password, false, false);
|
Online::CurrentUser::get()->requestSignIn(login, password, false, false);
|
||||||
request->executeNow();
|
request->executeNow();
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -52,82 +52,100 @@ namespace Online
|
|||||||
US_SIGNING_OUT
|
US_SIGNING_OUT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class SignInRequest : public XMLRequest
|
class SignInRequest : public XMLRequest
|
||||||
{
|
{
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
SignInRequest(bool manage_memory = false) : XMLRequest(manage_memory) {}
|
SignInRequest(bool manage_memory = false)
|
||||||
};
|
: XMLRequest(manage_memory, /*priority*/10) {}
|
||||||
|
}; // SignInRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class SignOutRequest : public XMLRequest
|
class SignOutRequest : public XMLRequest
|
||||||
{
|
{
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
SignOutRequest() : XMLRequest(true) {}
|
SignOutRequest() : XMLRequest(true,/*priority*/10) {}
|
||||||
};
|
}; // SignOutRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class ServerCreationRequest : public XMLRequest {
|
class ServerCreationRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
uint32_t m_created_server_id;
|
uint32_t m_created_server_id;
|
||||||
public:
|
public:
|
||||||
ServerCreationRequest() : XMLRequest() {}
|
ServerCreationRequest() : XMLRequest() {}
|
||||||
const uint32_t getCreatedServerID() const { assert(isDone()); return m_created_server_id;}
|
const uint32_t getCreatedServerID() const
|
||||||
};
|
{
|
||||||
|
assert(isDone());
|
||||||
|
return m_created_server_id;
|
||||||
|
} // getCreatedServerID
|
||||||
|
}; // ServerCreationRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
class ServerJoinRequest : public XMLRequest {
|
class ServerJoinRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
ServerJoinRequest() : XMLRequest() {}
|
ServerJoinRequest() : XMLRequest() {}
|
||||||
};
|
}; // ServerJoinRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class SetAddonVoteRequest : public XMLRequest {
|
class SetAddonVoteRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
SetAddonVoteRequest() : XMLRequest() {}
|
SetAddonVoteRequest() : XMLRequest() {}
|
||||||
};
|
}; // SetAddonVoteRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class FriendRequest : public XMLRequest {
|
class FriendRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
FriendRequest() : XMLRequest(true) {}
|
FriendRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // FriendRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class AcceptFriendRequest : public XMLRequest {
|
class AcceptFriendRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
AcceptFriendRequest() : XMLRequest(true) {}
|
AcceptFriendRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // AcceptFriendRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class DeclineFriendRequest : public XMLRequest {
|
class DeclineFriendRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
DeclineFriendRequest() : XMLRequest(true) {}
|
DeclineFriendRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // DeclineFriendRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class RemoveFriendRequest : public XMLRequest {
|
class RemoveFriendRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
RemoveFriendRequest() : XMLRequest(true) {}
|
RemoveFriendRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // RemoveFriendRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class CancelFriendRequest : public XMLRequest {
|
class CancelFriendRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
CancelFriendRequest() : XMLRequest(true) {}
|
CancelFriendRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // CancelFriendRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class PollRequest : public XMLRequest {
|
class PollRequest : public XMLRequest {
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
PollRequest() : XMLRequest(true) {}
|
PollRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // PollRequest
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
class ChangePasswordRequest : public XMLRequest
|
class ChangePasswordRequest : public XMLRequest
|
||||||
{
|
{
|
||||||
virtual void callback ();
|
virtual void callback ();
|
||||||
public:
|
public:
|
||||||
ChangePasswordRequest() : XMLRequest(true) {}
|
ChangePasswordRequest() : XMLRequest(true) {}
|
||||||
};
|
}; // ChangePasswordRequest
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -136,7 +154,7 @@ namespace Online
|
|||||||
UserState m_state;
|
UserState m_state;
|
||||||
Profile * m_profile;
|
Profile * m_profile;
|
||||||
|
|
||||||
bool getSaveSession() const { return m_save_session; }
|
bool saveSession() const { return m_save_session; }
|
||||||
|
|
||||||
CurrentUser();
|
CurrentUser();
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ namespace Online{
|
|||||||
assert(CurrentUser::get()->isRegisteredUser() && !m_is_current_user);
|
assert(CurrentUser::get()->isRegisteredUser() && !m_is_current_user);
|
||||||
AchievementsRequest * request = new AchievementsRequest();
|
AchievementsRequest * request = new AchievementsRequest();
|
||||||
request->setServerURL("client-user.php");
|
request->setServerURL("client-user.php");
|
||||||
request->addParameter("action",std::string("get-achievements"));
|
request->addParameter("action","get-achievements");
|
||||||
request->addParameter("token", CurrentUser::get()->getToken());
|
request->addParameter("token", CurrentUser::get()->getToken());
|
||||||
request->addParameter("userid", CurrentUser::get()->getID());
|
request->addParameter("userid", CurrentUser::get()->getID());
|
||||||
request->addParameter("visitingid", m_id);
|
request->addParameter("visitingid", m_id);
|
||||||
@ -198,7 +198,7 @@ namespace Online{
|
|||||||
assert(CurrentUser::get()->isRegisteredUser());
|
assert(CurrentUser::get()->isRegisteredUser());
|
||||||
FriendsListRequest * request = new FriendsListRequest();
|
FriendsListRequest * request = new FriendsListRequest();
|
||||||
request->setServerURL("client-user.php");
|
request->setServerURL("client-user.php");
|
||||||
request->addParameter("action",std::string("get-friends-list"));
|
request->addParameter("action","get-friends-list");
|
||||||
request->addParameter("token", CurrentUser::get()->getToken());
|
request->addParameter("token", CurrentUser::get()->getToken());
|
||||||
request->addParameter("userid", CurrentUser::get()->getID());
|
request->addParameter("userid", CurrentUser::get()->getID());
|
||||||
request->addParameter("visitingid", m_id);
|
request->addParameter("visitingid", m_id);
|
||||||
|
@ -76,7 +76,7 @@ namespace Online{
|
|||||||
{
|
{
|
||||||
request = new RefreshRequest();
|
request = new RefreshRequest();
|
||||||
request->setServerURL("client-user.php");
|
request->setServerURL("client-user.php");
|
||||||
request->addParameter("action",std::string("get_server_list"));
|
request->addParameter("action","get_server_list");
|
||||||
if (request_now)
|
if (request_now)
|
||||||
RequestManager::get()->addRequest(request);
|
RequestManager::get()->addRequest(request);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,8 @@ namespace StringUtils
|
|||||||
} // getExtension
|
} // getExtension
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
/** Checks if the input string is not empty. ( = has characters different from a space)
|
/** Checks if the input string is not empty. ( = has characters different
|
||||||
|
* from a space).
|
||||||
*/
|
*/
|
||||||
bool notEmpty(const irr::core::stringw& input)
|
bool notEmpty(const irr::core::stringw& input)
|
||||||
{
|
{
|
||||||
@ -523,7 +524,13 @@ namespace StringUtils
|
|||||||
} // timeToString
|
} // timeToString
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
/** Replaces values in a string.
|
||||||
|
* \param other string in which to replace stuff
|
||||||
|
* \param from pattern to remove from the string
|
||||||
|
* \param to pattern to insert instead
|
||||||
|
* \return a string with all occurrences of \c from replaced by
|
||||||
|
* occurrences of \c to
|
||||||
|
*/
|
||||||
std::string replace(const std::string& other, const std::string& from,
|
std::string replace(const std::string& other, const std::string& from,
|
||||||
const std::string& to)
|
const std::string& to)
|
||||||
{
|
{
|
||||||
@ -725,10 +732,6 @@ namespace StringUtils
|
|||||||
return version;
|
return version;
|
||||||
} // versionToInt
|
} // versionToInt
|
||||||
|
|
||||||
const char* boolstr(bool b)
|
|
||||||
{
|
|
||||||
return (b ? "true" : "false");
|
|
||||||
}
|
|
||||||
} // namespace StringUtils
|
} // namespace StringUtils
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,35 +44,59 @@ namespace StringUtils
|
|||||||
std::string getExtension(const std::string& filename);
|
std::string getExtension(const std::string& filename);
|
||||||
|
|
||||||
bool notEmpty(const irr::core::stringw& input);
|
bool notEmpty(const irr::core::stringw& input);
|
||||||
|
std::string timeToString(float time);
|
||||||
|
std::string toUpperCase(const std::string&);
|
||||||
|
std::string toLowerCase(const std::string&);
|
||||||
|
std::vector<std::string> split(const std::string& s, char c,
|
||||||
|
bool keepSplitChar=false);
|
||||||
|
std::vector<irr::core::stringw> split(const irr::core::stringw& s,
|
||||||
|
char c, bool keepSplitChar=false);
|
||||||
|
std::vector<uint32_t> splitToUInt(const std::string& s, char c,
|
||||||
|
bool keepSplitChar=false);
|
||||||
|
std::vector<std::string> splitPath(const std::string& path);
|
||||||
|
std::string replace(const std::string& other, const std::string& from, const std::string& to);
|
||||||
|
|
||||||
|
irr::core::stringw decodeFromHtmlEntities(const std::string& input);
|
||||||
|
|
||||||
|
std::string encodeToHtmlEntities(const irr::core::stringw &output);
|
||||||
|
|
||||||
|
/** Compute a simple hash of a string */
|
||||||
|
unsigned int simpleHash(const char* input);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
std::string toString (const T& any)
|
std::string toString (const T& any)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << any ;
|
oss << any ;
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
} // toString template
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Specialisiation for bools to return 'true' or 'false'/
|
||||||
|
*/
|
||||||
|
static std::string toString(bool b)
|
||||||
|
{
|
||||||
|
return (b ? "true" : "false");
|
||||||
|
} // toString(bool)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
irr::core::stringw toWString (const T& any)
|
irr::core::stringw toWString (const T& any)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << any ;
|
oss << any ;
|
||||||
return oss.str().c_str();
|
return oss.str().c_str();
|
||||||
}
|
} // toWString
|
||||||
|
|
||||||
/** Converts a time in seconds into a string of the form mm:ss:hh (minutes,
|
// ------------------------------------------------------------------------
|
||||||
* seconds, 1/100 seconds.
|
|
||||||
* \param time Time in seconds.
|
|
||||||
*/
|
|
||||||
std::string timeToString(float time);
|
|
||||||
/** Convert the contents in string \a rep to type \a T, if conversion
|
/** Convert the contents in string \a rep to type \a T, if conversion
|
||||||
fails false is returned and the value of \a x is unchanged, if
|
fails false is returned and the value of \a x is unchanged, if
|
||||||
true is returned the conversation was successfull. */
|
true is returned the conversation was successfull. */
|
||||||
template <class T>
|
template <class T>
|
||||||
bool fromString(const std::string& rep, T& x)
|
bool fromString(const std::string& rep, T& x)
|
||||||
{
|
{
|
||||||
// this is necessary so that if "x" is not modified if the conversion fails
|
// Don't modify x" if the conversion fails by using a temp
|
||||||
T temp;
|
T temp;
|
||||||
std::istringstream iss(rep);
|
std::istringstream iss(rep);
|
||||||
iss >> temp;
|
iss >> temp;
|
||||||
@ -86,17 +110,7 @@ namespace StringUtils
|
|||||||
x = temp;
|
x = temp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} // fromString
|
||||||
|
|
||||||
std::string toUpperCase(const std::string&);
|
|
||||||
std::string toLowerCase(const std::string&);
|
|
||||||
std::vector<std::string> split(const std::string& s, char c,
|
|
||||||
bool keepSplitChar=false);
|
|
||||||
std::vector<irr::core::stringw> split(const irr::core::stringw& s,
|
|
||||||
char c, bool keepSplitChar=false);
|
|
||||||
std::vector<uint32_t> splitToUInt(const std::string& s, char c,
|
|
||||||
bool keepSplitChar=false);
|
|
||||||
std::vector<std::string> splitPath(const std::string& path);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
@ -113,22 +127,25 @@ namespace StringUtils
|
|||||||
* and this is in the best case very confusing for translators (which get
|
* and this is in the best case very confusing for translators (which get
|
||||||
* to see two strings instead of one sentence, see xgettext manual
|
* to see two strings instead of one sentence, see xgettext manual
|
||||||
* for why this is a bad idea)
|
* for why this is a bad idea)
|
||||||
* In order to accomodate translations even more, you can use formats %0, %1, %2, etc...
|
* In order to accomodate translations even more, you can use formats
|
||||||
* where %0 is replaced by the first argument, %1 by the second argument, etc...
|
* %0, %1, %2, etc..., where %0 is replaced by the first argument, %1 by
|
||||||
* This allows translated strings to not necessarily insert the words in the same order as
|
* the second argument, etc... This allows translated strings to not
|
||||||
* in english.
|
* necessarily insert the words in the same order as in English.
|
||||||
* \param s String in which all %s or %d are replaced.
|
* \param s String in which all %s or %d are replaced.
|
||||||
* \param all_vals Value(s) to replace all %s or %d with.
|
* \param all_vals Value(s) to replace all %s or %d with.
|
||||||
*/
|
*/
|
||||||
std::string insertValues(const std::string &s, std::vector<std::string>& all_vals);
|
std::string insertValues(const std::string &s,
|
||||||
|
std::vector<std::string>& all_vals);
|
||||||
|
|
||||||
/** This no-op is useful when using variadic arguments, so that we may support the case with 0 variadic arguments */
|
/** This no-op is useful when using variadic arguments, so that we may
|
||||||
|
* support the case with 0 variadic arguments */
|
||||||
template <class T1>
|
template <class T1>
|
||||||
T1 insertValues(const T1& s) { return s; }
|
T1 insertValues(const T1& s) { return s; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Same as above but for wide-strings */
|
/** Same as above but for wide-strings */
|
||||||
irr::core::stringw insertValues(const irr::core::stringw &s, std::vector<irr::core::stringw>& all_vals);
|
irr::core::stringw insertValues(const irr::core::stringw &s,
|
||||||
|
std::vector<irr::core::stringw>& all_vals);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Note: the order in which the templates are specified is important, since
|
// Note: the order in which the templates are specified is important, since
|
||||||
@ -148,8 +165,9 @@ namespace StringUtils
|
|||||||
dummy << v5; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v5; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
dummy << v6; all_vals.push_back(dummy.str());
|
dummy << v6; all_vals.push_back(dummy.str());
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v6)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template <class T1, class T2, class T3, class T4, class T5>
|
template <class T1, class T2, class T3, class T4, class T5>
|
||||||
std::string insertValues(const std::string &s, const T1 &v1,
|
std::string insertValues(const std::string &s, const T1 &v1,
|
||||||
const T2 &v2, const T3 &v3, const T4 &v4,
|
const T2 &v2, const T3 &v3, const T4 &v4,
|
||||||
@ -163,8 +181,9 @@ namespace StringUtils
|
|||||||
dummy << v4; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v4; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
dummy << v5; all_vals.push_back(dummy.str());
|
dummy << v5; all_vals.push_back(dummy.str());
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v5)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template <class T1, class T2, class T3, class T4>
|
template <class T1, class T2, class T3, class T4>
|
||||||
std::string insertValues(const std::string &s, const T1 &v1,
|
std::string insertValues(const std::string &s, const T1 &v1,
|
||||||
const T2 &v2, const T3 &v3, const T4 &v4)
|
const T2 &v2, const T3 &v3, const T4 &v4)
|
||||||
@ -176,8 +195,9 @@ namespace StringUtils
|
|||||||
dummy << v3; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v3; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
dummy << v4; all_vals.push_back(dummy.str());
|
dummy << v4; all_vals.push_back(dummy.str());
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v4)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Shortcut insert_values taking three values, see above for
|
/** Shortcut insert_values taking three values, see above for
|
||||||
* full docs.
|
* full docs.
|
||||||
* \param s String in which all %s or %d are replaced.
|
* \param s String in which all %s or %d are replaced.
|
||||||
@ -193,7 +213,7 @@ namespace StringUtils
|
|||||||
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
dummy << v3; all_vals.push_back(dummy.str());
|
dummy << v3; all_vals.push_back(dummy.str());
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v3)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Note: the order in which the templates are specified is important, since
|
// Note: the order in which the templates are specified is important, since
|
||||||
@ -213,7 +233,7 @@ namespace StringUtils
|
|||||||
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
|
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, v2)
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Shortcut insert_values taking three values, see above for
|
/** Shortcut insert_values taking three values, see above for
|
||||||
* full docs.
|
* full docs.
|
||||||
@ -228,7 +248,7 @@ namespace StringUtils
|
|||||||
dummy << v1; all_vals.push_back(dummy.str()); dummy.str("");
|
dummy << v1; all_vals.push_back(dummy.str()); dummy.str("");
|
||||||
|
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -245,7 +265,7 @@ namespace StringUtils
|
|||||||
all_vals.push_back( irr::core::stringw(v5) );
|
all_vals.push_back( irr::core::stringw(v5) );
|
||||||
all_vals.push_back( irr::core::stringw(v6) );
|
all_vals.push_back( irr::core::stringw(v6) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v6)
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -262,7 +282,7 @@ namespace StringUtils
|
|||||||
all_vals.push_back( irr::core::stringw(v4) );
|
all_vals.push_back( irr::core::stringw(v4) );
|
||||||
all_vals.push_back( irr::core::stringw(v5) );
|
all_vals.push_back( irr::core::stringw(v5) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v5)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -276,7 +296,7 @@ namespace StringUtils
|
|||||||
all_vals.push_back( irr::core::stringw(v3) );
|
all_vals.push_back( irr::core::stringw(v3) );
|
||||||
all_vals.push_back( irr::core::stringw(v4) );
|
all_vals.push_back( irr::core::stringw(v4) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v4)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -290,7 +310,7 @@ namespace StringUtils
|
|||||||
all_vals.push_back( irr::core::stringw(v2) );
|
all_vals.push_back( irr::core::stringw(v2) );
|
||||||
all_vals.push_back( irr::core::stringw(v3) );
|
all_vals.push_back( irr::core::stringw(v3) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, ..., v3)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -302,7 +322,7 @@ namespace StringUtils
|
|||||||
all_vals.push_back( irr::core::stringw(v1) );
|
all_vals.push_back( irr::core::stringw(v1) );
|
||||||
all_vals.push_back( irr::core::stringw(v2) );
|
all_vals.push_back( irr::core::stringw(v2) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1, v2)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -312,7 +332,7 @@ namespace StringUtils
|
|||||||
std::vector<irr::core::stringw> all_vals;
|
std::vector<irr::core::stringw> all_vals;
|
||||||
all_vals.push_back( irr::core::stringw(v1) );
|
all_vals.push_back( irr::core::stringw(v1) );
|
||||||
return insertValues(s, all_vals);
|
return insertValues(s, all_vals);
|
||||||
}
|
} // insertValues(s, v1)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -323,7 +343,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
irr::core::stringw s(chars);
|
irr::core::stringw s(chars);
|
||||||
return insertValues(s, v1, v2, v3, v4, v5);
|
return insertValues(s, v1, v2, v3, v4, v5);
|
||||||
}
|
} // insertValues(s, v1, ..., v5)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -333,7 +353,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
irr::core::stringw s(chars);
|
irr::core::stringw s(chars);
|
||||||
return insertValues(s, v1, v2, v3);
|
return insertValues(s, v1, v2, v3);
|
||||||
}
|
} // insertValues(s, v1, ..., v3)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -343,7 +363,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
irr::core::stringw s(chars);
|
irr::core::stringw s(chars);
|
||||||
return insertValues(s, v1, v2);
|
return insertValues(s, v1, v2);
|
||||||
}
|
} // insertValues(s, v1, v2)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for wide strings */
|
/** Like the other ones above but for wide strings */
|
||||||
@ -352,7 +372,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
irr::core::stringw s(chars);
|
irr::core::stringw s(chars);
|
||||||
return insertValues(s, v1);
|
return insertValues(s, v1);
|
||||||
}
|
} // insertValues(s, v1)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for C strings */
|
/** Like the other ones above but for C strings */
|
||||||
@ -362,7 +382,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
std::string s(chars);
|
std::string s(chars);
|
||||||
return insertValues(s, v1, v2, v3);
|
return insertValues(s, v1, v2, v3);
|
||||||
}
|
} // insertValues(s, v1, ..., v3)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for C strings */
|
/** Like the other ones above but for C strings */
|
||||||
@ -372,7 +392,7 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
std::string s(chars);
|
std::string s(chars);
|
||||||
return insertValues(s, v1, v2);
|
return insertValues(s, v1, v2);
|
||||||
}
|
} // insertValues(s, v1, v2)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Like the other ones above but for C strings */
|
/** Like the other ones above but for C strings */
|
||||||
@ -381,8 +401,9 @@ namespace StringUtils
|
|||||||
{
|
{
|
||||||
std::string s(chars);
|
std::string s(chars);
|
||||||
return insertValues(s, v1);
|
return insertValues(s, v1);
|
||||||
}
|
} // insertValues(s, v1)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool parseString(const char* input, T* output)
|
bool parseString(const char* input, T* output)
|
||||||
{
|
{
|
||||||
@ -395,30 +416,15 @@ namespace StringUtils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} // parseString
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool parseString(const std::string& input, T* output)
|
bool parseString(const std::string& input, T* output)
|
||||||
{
|
{
|
||||||
return parseString(input.c_str(), output);
|
return parseString(input.c_str(), output);
|
||||||
}
|
} // parseString
|
||||||
|
|
||||||
/**
|
|
||||||
* \param other string in which to replace stuff
|
|
||||||
* \param from pattern to remove from the string
|
|
||||||
* \param to pattern to insert instead
|
|
||||||
* \return a string with all occurrences of \c from replaced by occurrences of \c to
|
|
||||||
*/
|
|
||||||
std::string replace(const std::string& other, const std::string& from, const std::string& to);
|
|
||||||
|
|
||||||
irr::core::stringw decodeFromHtmlEntities(const std::string& input);
|
|
||||||
|
|
||||||
std::string encodeToHtmlEntities(const irr::core::stringw &output);
|
|
||||||
|
|
||||||
/** Compute a simple hash of a string */
|
|
||||||
unsigned int simpleHash(const char* input);
|
|
||||||
|
|
||||||
const char* boolstr(bool b);
|
|
||||||
} // namespace StringUtils
|
} // namespace StringUtils
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user