TibrvMsg* TibrvMsg::detach() { if ((_detached == TIBRV_TRUE) || (_status != TIBRV_OK)) return NULL; // allocate new object TibrvMsg * newmsg = new TibrvMsg(); if (newmsg == NULL) return NULL; // detach if not yet detached if (_detached == TIBRV_FALSE) // this is redundand but may be needed { TibrvStatus status; if (_msg != NULL) { if ((status = tibrvMsg_Detach(_msg)) != TIBRV_OK) { delete newmsg; return NULL; } } _detached = TIBRV_TRUE; } newmsg->attach(_msg,TIBRV_TRUE); // invalidate this handle so we won't try to delete it _msg=NULL; _status = TIBRV_NOT_INITIALIZED; _detached = TIBRV_TRUE; return newmsg; }
TibrvStatus TibrvMsg::createCopy(TibrvMsg& copy) { _create(); if (_status != TIBRV_OK) return _status; tibrvMsg newmsg; tibrv_status status = tibrvMsg_CreateCopy(_msg,&newmsg); if (status == TIBRV_OK) copy.attach(newmsg,TIBRV_TRUE); return status; }
TibrvStatus TibrvMsg::getMsg(const char* fieldName, TibrvMsg& subMessage, tibrv_u16 fieldId) { _create(); if (_status != TIBRV_OK) return TibrvStatus(_status); TibrvStatus status; tibrvMsg msg; status = tibrvMsg_GetMsgEx(_msg,fieldName,&msg,fieldId); if (status != TIBRV_OK) return status; subMessage.attach(msg); return TIBRV_OK; }