本文整理汇总了C++中Msg::set_payload方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::set_payload方法的具体用法?C++ Msg::set_payload怎么用?C++ Msg::set_payload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg::set_payload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_well_known
bool Casan::get_well_known (Msg &out)
{
char *buf ;
size_t size ;
reslist *rl ;
size_t avail ;
bool reset ;
reset = false ;
out.content_format (reset, option::cf_text_plain) ;
avail = out.avail_space () ;
buf = (char *) malloc (avail) ;
size = 0 ;
for (rl = reslist_ ; rl != NULL ; rl = rl->next)
{
int len ;
if (size > 0) // separator "," between resources
{
if (size + 2 < avail)
{
buf [size++] = ',' ;
buf [size] = '\0' ;
}
else break ; // too large
}
len = rl->res->well_known (buf + size, avail - size) ;
if (len == -1)
break ;
size += len - 1 ; // exclude '\0'
}
out.set_payload ((uint8_t *) buf, size) ;
free (buf) ;
/*
* Did all resources fitted in the message, or do we left the loop
* before its term?
*/
if (rl != NULL)
{
DBG1 (F (B_RED "Resource '")) ;
DBG1 (rl->res->name ()) ;
DBG1 (F ("' do not fit in buffer of ")) ;
DBG1 (avail) ;
DBGLN1 (F (" bytes" C_RESET)) ;
}
return rl == NULL ; // true if all res are in the message
}