mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Log: Use string compare function
This commit is contained in:
parent
6624b8acca
commit
f551ff5ae8
6 changed files with 22 additions and 12 deletions
|
@ -113,8 +113,10 @@
|
|||
class SrsCplxError;
|
||||
typedef SrsCplxError* srs_error_t;
|
||||
|
||||
// The context ID, it default to a string object, we can also use other objects.
|
||||
#include <string>
|
||||
// The context ID, it default to a string object, we can also use other objects.
|
||||
// @remark User can directly user string as SrsContextId, we user struct to ensure the context is an object.
|
||||
#if 1
|
||||
struct _SrsContextId
|
||||
{
|
||||
std::string v_;
|
||||
|
@ -132,10 +134,18 @@ struct _SrsContextId
|
|||
bool empty() {
|
||||
return v_.empty();
|
||||
}
|
||||
bool equals(const _SrsContextId& to) {
|
||||
return v_ == to.v_;
|
||||
// Compare the two context id. @see http://www.cplusplus.com/reference/string/string/compare/
|
||||
// 0 They compare equal
|
||||
// <0 Either the value of the first character that does not match is lower in the compared string, or all compared characters match but the compared string is shorter.
|
||||
// >0 Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.
|
||||
int compare(const _SrsContextId& to) {
|
||||
return v_.compare(to.v_);
|
||||
}
|
||||
};
|
||||
typedef _SrsContextId SrsContextId;
|
||||
#else
|
||||
// Actually, we can directly user string as SrsContextId.
|
||||
typedef std::string SrsContextId;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue