mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add get_name_prefix
This commit is contained in:
parent
64d24fb65b
commit
bc2dcf0410
@ -177,6 +177,34 @@ set_name(const string &name) {
|
||||
#endif // DO_PSTATS
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AsyncTask::get_name_prefix
|
||||
// Access: Published
|
||||
// Description: Returns the initial part of the name, up to but not
|
||||
// including any trailing digits following a hyphen or
|
||||
// underscore.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string AsyncTask::
|
||||
get_name_prefix() const {
|
||||
string name = get_name();
|
||||
size_t trimmed = name.size();
|
||||
size_t p = trimmed;
|
||||
while (true) {
|
||||
while (p > 0 && isdigit(name[p - 1])) {
|
||||
--p;
|
||||
}
|
||||
if (p > 0 && (name[p - 1] == '-' || name[p - 1] == '_')) {
|
||||
--p;
|
||||
trimmed = p;
|
||||
} else {
|
||||
p = trimmed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return name.substr(0, trimmed);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AsyncTask::set_task_chain
|
||||
// Access: Published
|
||||
|
@ -86,6 +86,7 @@ PUBLISHED:
|
||||
|
||||
void set_name(const string &name);
|
||||
INLINE void clear_name();
|
||||
string get_name_prefix() const;
|
||||
|
||||
INLINE AtomicAdjust::Integer get_task_id() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user