本文整理汇总了C++中NamedString类的典型用法代码示例。如果您正苦于以下问题:C++ NamedString类的具体用法?C++ NamedString怎么用?C++ NamedString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NamedString类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
// Convert this message to a string representation
void MGCPMessage::toString(String& dest) const
{
// Construct first line
dest << name() << " " << transactionId();
if (isCommand())
dest << " " << endpointId() << " " << m_version;
else if (m_comment)
dest << " " << m_comment;
dest << "\r\n";
// Append message parameters
unsigned int n = params.count();
for (unsigned int i = 0; i < n; i++) {
NamedString* ns = params.getParam(i);
if (!ns)
continue;
dest << ns->name() << ": " << *ns << "\r\n";
}
// Append SDP(s)
for (ObjList* obj = sdp.skipNull(); obj; obj = obj->skipNext()) {
String s;
MimeSdpBody* tmp = static_cast<MimeSdpBody*>(obj->get());
for (ObjList* o = tmp->lines().skipNull(); o; o = o->skipNext()) {
NamedString* ns = static_cast<NamedString*>(o->get());
if (*ns)
s << ns->name() << "=" << *ns << "\r\n";
}
if (s)
dest << "\r\n" << s;
}
}
示例2: getParam
void CallInfo::fillParam(NamedList& target, const String& name, bool clear)
{
NamedString* param = getParam(name);
if (param)
target.setParam(name,param->c_str());
else if (clear)
target.clearParam(name);
}
示例3: length
void CallInfo::fillParams(NamedList& target)
{
unsigned int n = length();
for (unsigned int i = 0; i < n; i++) {
NamedString* param = getParam(i);
if (param)
target.setParam(param->name(),param->c_str());
}
}
示例4: msgEscape
void Message::commonEncode(String& str) const
{
str << msgEscape() << ":" << m_return.msgEscape();
unsigned n = length();
for (unsigned i = 0; i < n; i++) {
NamedString *s = getParam(i);
if (s)
str << ":" << s->name().msgEscape('=') << "=" << s->msgEscape();
}
}
示例5: statusParams
void RegistModule::statusParams(String& str)
{
NamedString* names;
str.append("critical=",",") << s_critical;
for (unsigned int i=0; i < s_statusaccounts.count(); i++) {
names = s_statusaccounts.getParam(i);
if (names)
str << "," << names->name() << "=" << names->at(0);
}
}
示例6: getIndex
int NamedList::getIndex(const String& name) const
{
const ObjList *p = &m_params;
for (int i=0; p; p=p->next(),i++) {
NamedString *s = static_cast<NamedString *>(p->get());
if (s && (s->name() == name))
return i;
}
return -1;
}
示例7: XDebug
NamedString* NamedList::getParam(const String& name) const
{
XDebug(DebugInfo,"NamedList::getParam(\"%s\")",name.c_str());
const ObjList *p = m_params.skipNull();
for (; p; p=p->skipNext()) {
NamedString *s = static_cast<NamedString *>(p->get());
if (s->name() == name)
return s;
}
return 0;
}
示例8: copyParam
bool CallInfo::copyParam(const NamedList& original, const String& name, bool clear)
{
NamedString* param = original.getParam(name);
if (param) {
setParam(name,param->c_str());
return true;
}
else if (clear)
clearParam(name);
return false;
}
示例9: Message
// Create a notify message, fill it with notifier, event, subscription data
// and additional parameters
Message* EventNotify::message(const String& notifier, Array& subscriptions,
unsigned int row, NamedList& params)
{
Message* notify = new Message("resource.notify");
notify->addParam("notifier",notifier);
notify->addParam("event",m_event);
copyParams2(*notify,&subscriptions,row);
unsigned int n = params.count();
for (unsigned int i = 0; i < n; i++) {
NamedString* ns = params.getParam(i);
if (ns)
notify->addParam(ns->name(),*ns);
}
return notify;
}
示例10: setFaxDivert
// Copy parameters required for automatic fax call diversion
void ToneConsumer::setFaxDivert(const Message& msg)
{
m_target = msg.getParam("notify");
if (m_id.null())
m_id = m_target;
NamedString* divert = msg.getParam("fax_divert");
if (!divert)
return;
m_detFax = true;
// if divert is empty or false disable diverting
if (divert->null() || !divert->toBoolean(true))
m_faxDivert.clear();
else {
m_faxDivert = *divert;
m_faxCaller = msg.getValue("fax_caller",msg.getValue("caller",m_faxCaller));
m_faxCalled = msg.getValue("fax_called",msg.getValue("called",m_faxCalled));
}
}
示例11: appendParam
// Append a parameter to a buffer
// Truncate it or set error if fail is true and parameter length exceeds maxLen
// Return: 0 if the parameter is missing
// -1 if the parameter is too long
// 1 on success
int appendParam(ObjList& msg, NamedList& params, unsigned char value,
unsigned char maxLen, bool fail)
{
NamedString* ns = params.getParam(lookup(value,ETSIModem::s_msgParams));
if (!ns)
return 0;
unsigned char len = ns->length();
if (len > maxLen) {
if (fail) {
params.setParam("error",ns->name() + "-too-long");
return -1;
}
len = maxLen;
}
DataBlock* data = new DataBlock;
unsigned char a[2] = {value,len};
FSKModem::addRaw(*data,a,sizeof(a));
FSKModem::addRaw(*data,(void*)ns->c_str(),len);
msg.append(data);
return 1;
}
示例12: debug
bool MessageDispatcher::dispatch(Message& msg)
{
#ifdef XDEBUG
Debugger debug("MessageDispatcher::dispatch","(%p) (\"%s\")",&msg,msg.c_str());
#endif
#ifndef NDEBUG
u_int64_t t = Time::now();
#endif
bool retv = false;
ObjList *l = &m_handlers;
Lock mylock(this);
for (; l; l=l->next()) {
MessageHandler *h = static_cast<MessageHandler*>(l->get());
if (h && (h->null() || *h == msg)) {
if (h->filter() && (*(h->filter()) != msg.getValue(h->filter()->name())))
continue;
unsigned int c = m_changes;
unsigned int p = h->priority();
if (trackParam() && h->trackName()) {
NamedString* tracked = msg.getParam(trackParam());
if (tracked)
tracked->append(h->trackName(),",");
else
msg.addParam(trackParam(),h->trackName());
}
// mark handler as unsafe to destroy / uninstall
h->m_unsafe++;
mylock.drop();
#ifdef DEBUG
u_int64_t tm = Time::now();
#endif
retv = h->receivedInternal(msg) || retv;
#ifdef DEBUG
tm = Time::now() - tm;
if (m_warnTime && (tm > m_warnTime))
Debug(DebugInfo,"Message '%s' [%p] passed through %p in " FMT64U " usec",
msg.c_str(),&msg,h,tm);
#endif
if (retv && !msg.broadcast())
break;
mylock.acquire(this);
if (c == m_changes)
continue;
// the handler list has changed - find again
NDebug(DebugAll,"Rescanning handler list for '%s' [%p] at priority %u",
msg.c_str(),&msg,p);
ObjList* l2 = &m_handlers;
for (l = l2; l; l=l->next()) {
MessageHandler *mh = static_cast<MessageHandler*>(l->get());
if (!mh)
continue;
if (mh == h)
// exact match - silently continue where we left
break;
// gone past last handler priority - exit with last handler
if ((mh->priority() > p) || ((mh->priority() == p) && (mh > h))) {
Debug(DebugAll,"Handler list for '%s' [%p] changed, skipping from %p (%u) to %p (%u)",
msg.c_str(),&msg,h,p,mh,mh->priority());
// l will advance in the outer for loop so use previous
l = l2;
break;
}
l2 = l;
}
if (!l)
break;
}
}
mylock.drop();
msg.dispatched(retv);
#ifndef NDEBUG
t = Time::now() - t;
if (m_warnTime && (t > m_warnTime)) {
unsigned n = msg.length();
String p;
for (unsigned i = 0; i < n; i++) {
NamedString *s = msg.getParam(i);
if (s)
p << "\n ['" << s->name() << "']='" << *s << "'";
}
Debug("Performance",DebugMild,"Message %p '%s' retval '%s' returned %s in " FMT64U " usec%s",
&msg,msg.c_str(),msg.retValue().c_str(),retv ? "true" : "false",t,p.safe());
}
#endif
l = &m_hooks;
for (; l; l=l->next()) {
MessagePostHook *h = static_cast<MessagePostHook*>(l->get());
if (h)
h->dispatched(msg,retv);
}
return retv;
}
示例13: debug
bool MessageDispatcher::dispatch(Message& msg)
{
#ifdef XDEBUG
Debugger debug("MessageDispatcher::dispatch","(%p) (\"%s\")",&msg,msg.c_str());
#endif
#ifndef NDEBUG
u_int64_t t = Time::now();
#endif
bool retv = false;
ObjList *l = &m_handlers;
m_mutex.lock();
for (; l; l=l->next()) {
MessageHandler *h = static_cast<MessageHandler*>(l->get());
if (h && (h->null() || *h == msg)) {
if (h->filter() && (*(h->filter()) != msg.getValue(h->filter()->name())))
continue;
unsigned int c = m_changes;
unsigned int p = h->priority();
m_mutex.unlock();
#ifdef DEBUG
u_int64_t tm = Time::now();
#endif
retv = h->received(msg);
#ifdef DEBUG
tm = Time::now() - tm;
if (m_warnTime && (tm > m_warnTime))
Debug(DebugInfo,"Message '%s' [%p] passed through %p in " FMT64U " usec",
msg.c_str(),&msg,h,tm);
#endif
if (retv)
break;
m_mutex.lock();
if (c == m_changes)
continue;
// the handler list has changed - find again
NDebug(DebugAll,"Rescanning handler list for '%s' [%p] at priority %u",
msg.c_str(),&msg,p);
for (l = &m_handlers; l; l=l->next()) {
MessageHandler *mh = static_cast<MessageHandler*>(l->get());
if (!mh)
continue;
if (mh == h)
// exact match - silently continue where we left
break;
// gone past last handler priority - exit with last handler
if ((mh->priority() > p) || ((mh->priority() == p) && (mh > h))) {
Debug(DebugAll,"Handler list for '%s' [%p] changed, skipping from %p (%u) to %p (%u)",
msg.c_str(),&msg,h,p,mh,mh->priority());
break;
}
}
}
}
if (!l)
m_mutex.unlock();
msg.dispatched(retv);
#ifndef NDEBUG
t = Time::now() - t;
if (m_warnTime && (t > m_warnTime)) {
unsigned n = msg.length();
String p;
for (unsigned i = 0; i < n; i++) {
NamedString *s = msg.getParam(i);
if (s)
p << "\n ['" << s->name() << "']='" << *s << "'";
}
Debug("Performance",DebugMild,"Message %p '%s' retval '%s' returned %s in " FMT64U " usec%s",
&msg,msg.c_str(),msg.retValue().c_str(),retv ? "true" : "false",t,p.safe());
}
#endif
l = &m_hooks;
for (; l; l=l->next()) {
MessagePostHook *h = static_cast<MessagePostHook*>(l->get());
if (h)
h->dispatched(msg,retv);
}
return retv;
}