mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
add findstring
This commit is contained in:
parent
79a876bcb1
commit
d6340a6941
@ -838,6 +838,8 @@ r_expand_variable(const string &str, size_t &vp,
|
||||
return expand_length(params);
|
||||
} else if (funcname == "substr") {
|
||||
return expand_substr(params);
|
||||
} else if (funcname == "findstring") {
|
||||
return expand_findstring(params);
|
||||
} else if (funcname == "dir") {
|
||||
return expand_dir(params);
|
||||
} else if (funcname == "notdir") {
|
||||
@ -1515,6 +1517,8 @@ expand_shell(const string ¶ms) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPScope::expand_standardize
|
||||
// Access: Private
|
||||
@ -2099,6 +2103,31 @@ expand_subst(const string ¶ms) {
|
||||
return str;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPScope::expand_findstrnig
|
||||
// Access: Private
|
||||
// Description: Expands the "findstring" function variable.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string PPScope::
|
||||
expand_findstring(const string ¶ms) {
|
||||
// Split the string up into tokens based on the commas.
|
||||
vector<string> tokens;
|
||||
tokenize_params(params, tokens, true);
|
||||
|
||||
if (tokens.size() != 2) {
|
||||
cerr << "findstring requires two parameters.\n";
|
||||
return string();
|
||||
}
|
||||
string str = tokens.back();
|
||||
const string &srchstr = tokens[0];
|
||||
size_t q = 0;
|
||||
size_t p = str.find(srchstr, q);
|
||||
if(p == string::npos)
|
||||
str = "";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPScope::expand_wordsubst
|
||||
// Access: Private
|
||||
|
@ -94,6 +94,7 @@ private:
|
||||
string expand_standardize(const string ¶ms);
|
||||
string expand_length(const string ¶ms);
|
||||
string expand_substr(const string ¶ms);
|
||||
string expand_findstring(const string ¶ms);
|
||||
string expand_dir(const string ¶ms);
|
||||
string expand_notdir(const string ¶ms);
|
||||
string expand_suffix(const string ¶ms);
|
||||
|
Loading…
x
Reference in New Issue
Block a user