• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Marshal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Marshal函数的典型用法代码示例。如果您正苦于以下问题:C++ Marshal函数的具体用法?C++ Marshal怎么用?C++ Marshal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Marshal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Marshal

long SDMmessage::SendTCP(long ip_addr,long port)
{
	int sock;
	long i;
	long result;
	char buf[3*BUFSIZE];
	char ack[16];
	short error = 0;

	//fill buffer
	i = Marshal(buf);
	if(i < 0)
		return SDM_MESSAGE_SEND_ERROR;
	//send message
	sock = TCPconnect(ip_addr,port);
  if (sock != IP_SOCK_INVALID)
  {
	  result = TCPsend(sock,buf,i);
	  if(buf[0] == SDM_xTEDS || buf[0] == SDM_CancelxTEDS)
	  {
		  TCPrecv(sock,ack,13);
		  error = GET_SHORT(&ack[HEADER_SIZE]);
		  if(error < 0)
      {
			  result = error;
      }
	  }
	  TCPclose (sock);
#ifdef BUILD_WITH_MESSAGE_LOGGING
	  Logger.MessageSent(*this);
#endif
  }
	return result;
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:34,代码来源:SDMmessage.cpp


示例2: unchanged

/*
    Forward a previously received message unchanged (i.e. without changing the timestamp).

    Implementation notes:  Currently, only messages of maximum size BUFSIZE can be forwarded.
    The only message that won't send as expected is SDMxTEDS.  The reason for this is that
    the DM is the only application that should ever receive SDMxTEDS, and it will never use
    this function.

    Params:
    	destination - The component id to which to forward the message
    Returns:
    	long - The length of the message sent or -1 to indicate failure
*/
long SDMmessage::Forward(const SDMComponent_ID& destination)
{
	char buf[BUFSIZE];

	if (MsgName == SDM_xTEDS)
		return -1;

	// Save the old timestamp
	long OldSeconds = sec;
	long OldSubSeconds = subsec;

	// Marshal the message, this call will assign a new timestamp
	const long MessageLength = Marshal(buf);
	if (MessageLength < 0)
		return MessageLength;

	// Reset the old timestamp
	sec = OldSeconds;
	subsec = OldSubSeconds;

	// Remarshal the header, overwriting previous data, body of message is still intact
	MarshalHeaderOldTimeStamp(buf);

	// Now send the message to the destination component id
	int sock = UDPconnect(destination.getAddress(), destination.getPort());
	if (sock < 0)
		return -1;
	long SendResult = UDPsend(sock, buf, MessageLength);
	UDPclose(sock);

#ifdef BUILD_WITH_MESSAGE_LOGGING
	Logger.MessageSent(*this);
#endif
	return SendResult;
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:48,代码来源:SDMmessage.cpp


示例3: main

int
main( int argc, char *argv[] )
{
  tUint8         value[4]  = { 0x42, 0X43, 0X44, 0X45 };
  tUint8         result[4] = { 0x11, 0x12, 0x13, 0x14 };
  unsigned char  buffer[256];

  unsigned int s1 = Marshal( &UserDefinedType, value, buffer );

  if ( s1 != 3 )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(),
                               &UserDefinedType, result, buffer );

  if ( s2 != 3 )
       return 1;

  if ( value[0] != result[0] )
       return 1;

  if ( value[1] != result[1] )
       return 1;

  if ( value[2] != result[2] )
       return 1;

  if ( result[3] != 0x14 )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:32,代码来源:marshal_027.c


示例4: AJ_MarshalArg

AJ_Status AJ_MarshalArg(AJ_Message* msg, AJ_Arg* arg)
{
    AJ_Status status;
    AJ_IOBuffer* ioBuf = &msg->bus->sock.tx;
    uint8_t* argStart = ioBuf->writePtr;

    if (msg->varOffset) {
        /*
         * Marshaling a variant - get the signature from the I/O buffer
         */
        const char* sig = (const char*)(argStart - msg->varOffset);
        msg->varOffset = 0;
        status = Marshal(msg, &sig, arg);
    } else if (msg->outer) {
        /*
         * Marshaling a component of a container use the container's signature
         */
        const char* sig = msg->outer->sigPtr;
        if (!*sig) {
            return AJ_ERR_END_OF_DATA;
        }
        status = Marshal(msg, &sig, arg);
        /*
         * Only advance the signature for struct elements
         */
        if (msg->outer->typeId != AJ_ARG_ARRAY) {
            msg->outer->sigPtr = sig;
        }
    } else {
        const char* sig = msg->signature + msg->sigOffset;
        /*
         * Marshalling anything else use the message signature
         */
        if (!*sig) {
            return AJ_ERR_END_OF_DATA;
        }
        status = Marshal(msg, &sig, arg);
        msg->sigOffset = (uint8_t)(sig - msg->signature);
    }
    if (status == AJ_OK) {
        msg->bodyBytes += (uint16_t)(ioBuf->writePtr - argStart);
    } else {
        AJ_ReleaseReplyContext(msg);
    }
    return status;
}
开发者ID:reignme,项目名称:ajtcl,代码行数:46,代码来源:aj_msg.c


示例5: HpiMarshalReply

int
HpiMarshalReply( cHpiMarshal *m, void *buffer, const void **params )
{
  // the first value is the result.
  SaErrorT err = *(const SaErrorT *)params[0];

  if ( err == SA_OK )
       return MarshalArray( m->m_reply, params, buffer );

  return Marshal( &SaErrorType, &err, buffer );
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:11,代码来源:marshal_hpi.c


示例6: Start

/*
 * Manual page at process.def
 */
INT32 CGEN_PUBLIC CProcess::Start()
{
  const SMic* pMic    = NULL;                                                   // Method invocation context of Start()
  CFunction*  iCaller = NULL;                                                   // Function calling Start()
  CFunction*  iFnc    = NULL;                                                   // Process function
  StkItm*     pStkItm = NULL;                                                   // Stack item
  INT32       nArgs   = 0;                                                      // Number of process function arguments

  // Validate and initialize                                                    // ------------------------------------
  if (m_nState!=0)                                                              // Not virginal
    return IERROR(this,PRC_CANTSTART,"multiple starts not allowed",0,0);        //   Forget it!
  if (!(pMic = CDlpObject_MicGet(_this))) return -1;                            // Get method invocation context
  iCaller = (CFunction*)CDlpObject_OfKind("function",pMic->iCaller);            // Get calling CFunction
  if (!iCaller) return -1;                                                      // Must be a function!

  // Initialize process                                                         // ------------------------------------
  sprintf(m_psTmpFile,"%s%ld",dlp_tempnam(NULL,"~dLabPro#process#"),(long)dlp_time());// Initialize temp. file name prefix

  // Marshal arguments                                                          // ------------------------------------
  if (!(pStkItm=iCaller->StackGet(0))) return IERROR(this,PRC_TOOFEWARGS,0,0,0);// Get stack top
  if (pStkItm->nType==T_INSTANCE)                                               // Stack top is an instance
    iFnc = (CFunction*)CDlpObject_OfKind("function",pStkItm->val.i);            //   Get function to be called
  if (iFnc)                                                                     // This process is a function call
  {                                                                             // >>
    IFIELD_RESET(CDlpObject,"dto");                                             //   Create data transfer object
    nArgs = CData_GetNRecs(iFnc->m_idArg);                                      //   Get number of function arguments
    Marshal(m_iDto,iCaller,nArgs);                                              //   Marshal arguments for transfer
  }                                                                             // <<
  else                                                                          // This process is a program call
    dlp_strcpy(m_psCmdLine,iCaller->PopString(0));                              //   Get program command line

#ifdef USE_FORK
  if (iFnc)                                                                     // This process is a function call
  {                                                                             // >>
    m_hPid=fork();                                                              //   Fork the process
    if(m_hPid>0){                                                               //   Parent process >>
      m_nState |= PRC_DATASENT;                                                 //     Remember data have been sent
      m_nState |= PRC_RUNNING;                                                  //     Set running flag
      m_hThread = 0;                                                            //     Clear thread handle
      return O_K;                                                               //     Everything is fine
    }                                                                           //   <<
    if(m_hPid==0) return DoJobFork(iCaller,iFnc);                               //   The child process runs the function
    return IERROR(this,PRC_CANTSTART,"fork() failed",0,0);                      //   On error (fid<0) we return
  }                                                                             // <<
#endif
  // Start job in watcher thread                                                // ------------------------------------
  m_hPid = 0;                                                                   // Reset process id
  SendData();                                                                   // Send transfer data
  m_hThread = dlp_create_thread(DoJob,this);                                    // Do the job and watch it

  return O_K;                                                                   // Yo!
}
开发者ID:gitgun,项目名称:dLabPro,代码行数:55,代码来源:prc_impl.cpp


示例7: Marshal

void CachedObjectMgr::GetCacheFileName(PyRep *key, std::string &into)
{
    Buffer data;
    Marshal( key, data );

    Base64::encode( &data[0], data.size(), into, false );

    std::string::size_type epos = into.find('=');
    if(epos != std::string::npos)
        into.resize(epos);

    into += ".cache";
}
开发者ID:Bes666,项目名称:Evemu,代码行数:13,代码来源:CachedObjectMgr.cpp


示例8: Marshal

int CMarshalled::Send(DPNID idTo, DWORD flags)
{
	CDarkMarshalBuffer buff;

	buff.UseDefaultBuffer();
	Marshal(buff);

	int bytes = buff.GetBytesWritten();

	if (g_pDarkNet)
		g_pDarkNet->Send(idTo, buff.GetStartBuffer(), bytes, NULL, flags);

	return bytes;
}
开发者ID:adrikim,项目名称:thiefmp,代码行数:14,代码来源:Marshal.cpp


示例9: RunThreadedConsole

void RunThreadedConsole(HWND excel)
{
	if (hWndConsole)
	{
		::ShowWindow(hWndConsole, SW_SHOWDEFAULT);
		::SetWindowPos(hWndConsole, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
	}
	else
	{
		DWORD dwID;

		Marshal(); // FIXME: do this elsewhere, and once
		UpdateWordList();
		::CreateThread(0, 0, ThreadProc, excel, 0, &dwID);
	}

}
开发者ID:wck01,项目名称:Basic-Excel-R-Toolkit,代码行数:17,代码来源:Console.cpp


示例10: Marshal

Error SNMPVarbindList::Marshal(std::vector
																	 <Byte> &to) {
	to.push_back(type());

	// get the length of the elements
	int len = 0;
	for (auto it = varbinds_.begin(); it != varbinds_.end(); it++) {
		len += it->length();
	}
	to.push_back(len);

	for (auto it = varbinds_.begin(); it != varbinds_.end(); it++) {
		it->Marshal(to);
	}

	return Error::None;
}
开发者ID:gelidus,项目名称:isasnmp,代码行数:17,代码来源:SNMPPacket.cpp


示例11: MarshalArray

int
MarshalArray( const cMarshalType **types, 
	      const void **data, void *b )
{
  int            i;
  int            size = 0;
  unsigned char *buffer = b;

  for( i = 0; types[i]; i++ )
     {
       int s = Marshal( types[i], data[i], buffer );

       if ( s < 0 )
	    return -1;

       size   += s;
       buffer += s;
     }

  return size;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:21,代码来源:marshal.c


示例12: main

int
main( int argc, char *argv[] )
{
  tInt8         value = 0xfa;
  tInt8         result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Int8Type, &value, buffer );

  if ( s1 != sizeof( tInt8 ) )
       return 1;

  unsigned int s2 = Demarshal( G_BYTE_ORDER, &Marshal_Int8Type, &result, buffer );

  if ( s2 != sizeof( tInt8 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:openhpitest,代码行数:22,代码来源:marshal_004.c


示例13: main

int
main( int argc, char *argv[] )
{
  tUint64       value = 0xfedc12345678abcdLL;
  tUint64       result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Uint64Type, &value, buffer );

  if ( s1 != sizeof( tUint64 ) )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(), &Marshal_Uint64Type, &result, buffer );

  if ( s2 != sizeof( tUint64 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal_003.c


示例14: main

int
main( int argc, char *argv[] )
{
  tFloat64      value = -47.345566;
  tFloat64      result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Float64Type, &value, buffer );

  if ( s1 != sizeof( tFloat64 ) )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(), &Marshal_Float64Type, &result, buffer );

  if ( s2 != sizeof( tFloat64 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal_009.c


示例15: MarshalArray

int
MarshalArray( const cMarshalType **types, const void **data, void *b )
{
  int            size = 0;
  unsigned char *buffer = b;

  int i;
  for( i = 0; types[i]; i++ )
     {
       int cc = Marshal( types[i], data[i], buffer );
       if ( cc < 0 )
	  {
	    CRIT( "MarshalArray[%d]: %s: failure, cc = %d!", i, types[i]->m_name, cc );
	    return cc;
	  }

       size   += cc;
       buffer += cc;
     }

  return size;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal.c


示例16: CheckForThrownException

QStatus NativeAboutObject::GetAnnouncedAboutData(
    /* [in] */ ajn::MsgArg* msgArg)
{
    QStatus status = ER_FAIL;
    if (mAboutDataListenerRef != NULL) {
        AutoPtr<IMap> announceArg;
        ECode ec = mAboutDataListenerRef->GetAnnouncedAboutData((IMap**)&announceArg);
        // check for ErrorReplyBusException exception
        status = CheckForThrownException(ec);
        if (ER_OK == status) {
            if (Marshal("a{sv}", announceArg.Get(), msgArg) == NULL) {
                Logger::E("NativeAboutObject", "GetMsgArgAnnounce() marshaling error");
                return ER_FAIL;
            }
        }
        else {
            Logger::E("NativeAboutObject", "GetAnnouncedAboutData exception with status %s", QCC_StatusText(status));
            return status;
        }
    }
    return status;
}
开发者ID:elastos,项目名称:Elastos5,代码行数:22,代码来源:NativeAboutObject.cpp


示例17: main

int
main( int argc, char *argv[] )
{
    tInt64        value = 0x1234567890abcdefLL;
    tInt64        result;
    unsigned char buffer[256];

    unsigned int s1 = Marshal( &Marshal_Int64Type, &value, buffer );

    if ( s1 != sizeof( tInt64 ) )
        return 1;

    unsigned int s2 = Demarshal( G_BYTE_ORDER, &Marshal_Int64Type, &result, buffer );

    if ( s2 != sizeof( tInt64 ) )
        return 1;

    if ( value != result )
        return 1;

    return 0;
}
开发者ID:openhpi1,项目名称:openhpitest,代码行数:22,代码来源:marshal_007.c


示例18: main

int
main( int argc, char *argv[] )
{
  tInt32         value = 0x42aa1234;
  tInt32         result;
  unsigned char  buffer[256];

  unsigned int s1 = Marshal( &Marshal_Int32Type, &value, buffer );

  if ( s1 != sizeof( tInt32 ) )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(), &Marshal_Int32Type, &result, buffer );

  if ( s2 != sizeof( tInt32 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal_006.c


示例19: CheckValue

static int
CheckValue( cTest *v, cTest *r )
{
  unsigned char buffer[256];
  unsigned int s1 = Marshal( &TestType, v, buffer );
  unsigned int s2 = Demarshal( MarshalByteOrder(), &TestType, r, buffer );

  if ( s1 != s2 )
       return 1;

  if ( v->m_pad1 != r->m_pad1 )
       return 1;

  if ( v->m_mod != r->m_mod )
       return 1;

  if ( v->m_pad2 != r->m_pad2 )
       return 1;

  if ( v->m_pad3 != r->m_pad3 )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:24,代码来源:marshal_025.c


示例20: Marshal

int
Marshal( const cMarshalType *type, const void *d, void *b )
{
  if ( IsSimpleType( type->m_type ) )
       return MarshalSimpleTypes( type->m_type, d, b );

  int                  size   = 0;
  const unsigned char *data   = d;
  unsigned char       *buffer = b;

  switch( type->m_type )
     {
       case eMtArray:
            {
              int i;

              //assert( IsSimpleType( type->m_u.m_array.m_type->m_type ) );

              for( i = 0; i < type->m_u.m_array.m_size; i++ )
                 {
                   int s = Marshal( type->m_u.m_array.m_type, data, buffer );

		   if ( s < 0 )
			return -1;

                   data   += s;
                   buffer += s;
                   size   += s;
                 }
            }
            break;

       case eMtStruct:
	    {
	      int i;
 
	      for( i = 0; type->m_u.m_struct.m_elements[i].m_type == eMtStructElement; i++ )
		 {
		   cMarshalType *struct_element = &type->m_u.m_struct.m_elements[i];
                   assert( struct_element->m_type == eMtStructElement );

                   cMarshalType *st_type = struct_element->m_u.m_struct_element.m_type;

                   int s = 0;

                   if ( st_type->m_type == eMtUnion )
                      {
                        // the mod must be before this entry.
                        // this is a limitation of demarshaling of unions
                        assert( st_type->m_u.m_union.m_offset < i );
			const cMarshalType *mod = FindUnionModifierType( type, st_type, data );

			if ( mod )
			   {
			     s = Marshal( mod, data + struct_element->m_u.m_struct_element.m_offset, buffer );

			     if ( s < 0 )
				  return -1;
			   }
			else
			     return -1;
                      }
                   else if ( st_type->m_type == eMtVarArray )
                      {
                        // the array size must be before this entry.
                        // this is a limitation of demarshaling of var arrays
                        assert( st_type->m_u.m_var_array.m_size < i );

			int array_size = FindArraySize( type, st_type, data );

                        // only simple types can be array elements
                        assert( IsSimpleType( st_type->m_u.m_var_array.m_type->m_type ) );

                        unsigned char *bb = buffer;
                        const unsigned char *dd = data + struct_element->m_u.m_struct_element.m_offset;
                        tUint32 j;

                        for( j = 0; j < array_size; j++ )
                           {
                             int si = Marshal( st_type->m_u.m_var_array.m_type,
					       dd, bb );

			     if ( si < 0 )
				  return -1;

                             bb += si;
                             dd += si;
                             s  += si;
                           }
                      }
                   else
		      {
                        s = Marshal( st_type, data + struct_element->m_u.m_struct_element.m_offset,
                                     buffer );

			if ( s < 0 )
			     return -1;
		      }

		   buffer += s;
//.........这里部分代码省略.........
开发者ID:openhpi1,项目名称:testrepo,代码行数:101,代码来源:marshal.c



注:本文中的Marshal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MatCreate函数代码示例发布时间:2022-05-30
下一篇:
C++ MarkWholeScreenDirty函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap