mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Log: Refine context id
This commit is contained in:
parent
742826a655
commit
7052a1fafb
2 changed files with 38 additions and 18 deletions
|
@ -23,4 +23,32 @@
|
||||||
|
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
|
_SrsContextId::_SrsContextId()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
_SrsContextId::_SrsContextId(std::string v)
|
||||||
|
{
|
||||||
|
v_ = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
_SrsContextId::_SrsContextId(const _SrsContextId& cp)
|
||||||
|
{
|
||||||
|
v_ = cp.v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* _SrsContextId::c_str()
|
||||||
|
{
|
||||||
|
return v_.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _SrsContextId::empty()
|
||||||
|
{
|
||||||
|
return v_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _SrsContextId::compare(const _SrsContextId& to)
|
||||||
|
{
|
||||||
|
return v_.compare(to.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,30 +117,22 @@ typedef SrsCplxError* srs_error_t;
|
||||||
// The context ID, it default to a string object, we can also use other objects.
|
// 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.
|
// @remark User can directly user string as SrsContextId, we user struct to ensure the context is an object.
|
||||||
#if 1
|
#if 1
|
||||||
struct _SrsContextId
|
class _SrsContextId
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
std::string v_;
|
std::string v_;
|
||||||
_SrsContextId() {
|
public:
|
||||||
}
|
_SrsContextId();
|
||||||
_SrsContextId(std::string v) {
|
_SrsContextId(std::string v);
|
||||||
v_ = v;
|
_SrsContextId(const _SrsContextId& cp);
|
||||||
}
|
public:
|
||||||
_SrsContextId(const _SrsContextId& cp) {
|
const char* c_str();
|
||||||
v_ = cp.v_;
|
bool empty();
|
||||||
}
|
|
||||||
const char* c_str() {
|
|
||||||
return v_.c_str();
|
|
||||||
}
|
|
||||||
bool empty() {
|
|
||||||
return v_.empty();
|
|
||||||
}
|
|
||||||
// Compare the two context id. @see http://www.cplusplus.com/reference/string/string/compare/
|
// Compare the two context id. @see http://www.cplusplus.com/reference/string/string/compare/
|
||||||
// 0 They compare equal
|
// 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 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.
|
// >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) {
|
int compare(const _SrsContextId& to);
|
||||||
return v_.compare(to.v_);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
typedef _SrsContextId SrsContextId;
|
typedef _SrsContextId SrsContextId;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue