⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs-utf-8.cc

📁 编译工具
💻 CC
📖 第 1 页 / 共 2 页
字号:
		  DATA_CONVERSION_BadInput,		  (CORBA::CompletionStatus)stream.completion());}voidTCS_C_UTF_8::marshalString(cdrStream& stream,			   _CORBA_ULong len,			   const omniCodeSet::UniChar* us){  omniCodeSetUtil::BufferC b;  omniCodeSet::UniChar     uc;  for (_CORBA_ULong i=0; i<=len; i++) {    uc = us[i];    if      (uc < 0x0080) {      b.insert(uc);    }    else if (uc < 0x0800) {      b.insert(0xc0 | ((uc & 0x07c0) >>  6));      b.insert(0x80 | ((uc & 0x003f)      ));    }    else if (uc < 0xd800) {      b.insert(0xe0 | ((uc & 0xf000) >> 12));      b.insert(0x80 | ((uc & 0x0fc0) >>  6));      b.insert(0x80 | ((uc & 0x003f)      ));    }    else if (uc < 0xdc00) {      // Surrogate pair      _CORBA_ULong lc = (uc - 0xd800) << 10;      if (++i == len) {	// No second half to surrogate pair	OMNIORB_THROW(DATA_CONVERSION, 		      DATA_CONVERSION_BadInput,		      (CORBA::CompletionStatus)stream.completion());      }      uc = us[i];      if (uc < 0xdc00 || uc > 0xdfff) {	// Value is not a valid second half to a surrogate pair	OMNIORB_THROW(DATA_CONVERSION, 		      DATA_CONVERSION_BadInput,		      (CORBA::CompletionStatus)stream.completion());      }      lc = lc + uc - 0xdc00 + 0x10000;      b.insert(0xf0 | ((lc & 0x001c0000) >> 18));      b.insert(0x80 | ((lc & 0x0003f000) >> 12));      b.insert(0x80 | ((lc & 0x00000fc0) >>  6));      b.insert(0x80 | ((lc & 0x000000ef)      ));    }    else if (uc < 0xe000) {      // Second half of surrogate pair not allowed on its own      OMNIORB_THROW(DATA_CONVERSION, 		    DATA_CONVERSION_BadInput,		    (CORBA::CompletionStatus)stream.completion());    }    else {      b.insert(0xe0 | ((uc & 0xf000) >> 12));      b.insert(0x80 | ((uc & 0x0fc0) >>  6));      b.insert(0x80 | ((uc & 0x003f)      ));    }  }  _CORBA_ULong mlen = b.length();  mlen >>= stream;  stream.put_octet_array((const _CORBA_Octet*)b.buffer(), mlen);}omniCodeSet::UniCharTCS_C_UTF_8::unmarshalChar(cdrStream& stream){  _CORBA_Char c;  c = stream.unmarshalOctet();  if (c < 0x80)    return c;  else    OMNIORB_THROW(DATA_CONVERSION, 		  DATA_CONVERSION_BadInput,		  (CORBA::CompletionStatus)stream.completion());  return 0; // For broken compilers}_CORBA_ULongTCS_C_UTF_8::unmarshalString(cdrStream& stream,			     _CORBA_ULong bound, omniCodeSet::UniChar*& us){  _CORBA_ULong len; len <<= stream;  if (len == 0) {    if (orbParameters::strictIIOP) {      if (omniORB::trace(1)) {	omniORB::logger l;	l << "Error: received an invalid zero length string.\n";      }      OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		    (CORBA::CompletionStatus)stream.completion());    }    else {      if (omniORB::trace(1)) {	omniORB::logger l;	l << "Warning: received an invalid zero length string."	  << " Substituted with a proper empty string.\n";      }    }  }  if (bound && len-1 > bound)    OMNIORB_THROW(MARSHAL, MARSHAL_StringIsTooLong, 		  (CORBA::CompletionStatus)stream.completion());  if (!stream.checkInputOverrun(1, len))    OMNIORB_THROW(MARSHAL, MARSHAL_PassEndOfMessage,		  (CORBA::CompletionStatus)stream.completion());  omniCodeSetUtil::BufferU ub;  CORBA::ULong         	   lc;  _CORBA_Char          	   c;  int                  	   bytes;  CORBA::Octet         	   error = 0;  for (_CORBA_ULong i=0; i < len; i++) {    c   = stream.unmarshalOctet();    bytes = utf8Count[c];    lc    = c & utf8Mask[c];    // This switch is an attempt to avoid overhead in pipelined    // processors. Cases 3, 2 and 1 should drop through with no    // branching code.    switch (bytes) {    case 6: OMNIORB_THROW(DATA_CONVERSION, 			  DATA_CONVERSION_BadInput,			  (CORBA::CompletionStatus)stream.completion());    case 5:    case 4: OMNIORB_THROW(DATA_CONVERSION, 			  DATA_CONVERSION_BadInput,			  (CORBA::CompletionStatus)stream.completion());    case 3:      c = stream.unmarshalOctet(); i++;      lc = (lc << 6) | (c & 0x3f); error |= (c & 0xc0) ^ 0x80;    case 2:      c = stream.unmarshalOctet(); i++;      lc = (lc << 6) | (c & 0x3f); error |= (c & 0xc0) ^ 0x80;    case 1:      c = stream.unmarshalOctet(); i++;      lc = (lc << 6) | (c & 0x3f); error |= (c & 0xc0) ^ 0x80;    }    if (lc <= 0xffff) {      // Single unicode char      ub.insert(lc);    }    else {      // Surrogate pair      lc -= 0x10000;      ub.insert((lc >> 10)    + 0xd800);      ub.insert((lc &  0x3ff) + 0xdc00);    }    // By testing the error here, rather than immediately after the    // switch, we might avoid stalling the pipeline waiting for error    // to become available.    if (error) {      // At least one extension byte was not of the form 10xxxxxx      OMNIORB_THROW(DATA_CONVERSION, 		    DATA_CONVERSION_BadInput,		    (CORBA::CompletionStatus)stream.completion());    }  }  if (lc != 0) // Check for null-terminator    OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		  (CORBA::CompletionStatus)stream.completion());  us = ub.extract();  return ub.length() - 1;}_CORBA_BooleanTCS_C_UTF_8::fastMarshalChar(cdrStream&          stream,			     omniCodeSet::NCS_C* ncs,			     _CORBA_Char         c){  if (ncs->id() == id()) { // Null transformation    stream.marshalOctet(c);    return 1;  }  return 0;}_CORBA_BooleanTCS_C_UTF_8::fastMarshalString(cdrStream&          stream,			       omniCodeSet::NCS_C* ncs,			       _CORBA_ULong        bound,			       _CORBA_ULong        len,			       const char*         s){  if (ncs->id() == id()) { // Null transformation    if (bound && len > bound)      OMNIORB_THROW(MARSHAL, MARSHAL_StringIsTooLong, 		    (CORBA::CompletionStatus)stream.completion());    _CORBA_ULong mlen = len + 1;    mlen >>= stream;    stream.put_octet_array((const _CORBA_Octet*)s, mlen);    return 1;  }  else if (ncs->kind() == omniCodeSet::CS_8bit) { // Simple 8 bit code set    const omniCodeSet::UniChar* toU = ((omniCodeSet::NCS_C_8bit*)ncs)->toU();    omniCodeSetUtil::BufferC b;    omniCodeSet::UniChar     uc;    while (*s) {      uc = toU[(_CORBA_Char)*s++];      if      (uc < 0x0080) {	b.insert(uc);      }      else if (uc < 0x0800) {	b.insert(0xc0 | ((uc & 0x07c0) >>  6));	b.insert(0x80 | ((uc & 0x003f)      ));      }      else if (uc < 0xd800) {	b.insert(0xe0 | ((uc & 0xf000) >> 12));	b.insert(0x80 | ((uc & 0x0fc0) >>  6));	b.insert(0x80 | ((uc & 0x003f)      ));      }      else if (uc < 0xe000) {	// Surrogate pairs shouldn't happen	OMNIORB_THROW(DATA_CONVERSION, 		      DATA_CONVERSION_BadInput,		      (CORBA::CompletionStatus)stream.completion());      }      else {	b.insert(0xe0 | ((uc & 0xf000) >> 12));	b.insert(0x80 | ((uc & 0x0fc0) >>  6));	b.insert(0x80 | ((uc & 0x003f)      ));      }    }    b.insert(0); // Null terminator    _CORBA_ULong mlen = b.length();    if (bound && mlen-1 > bound)      OMNIORB_THROW(MARSHAL, MARSHAL_StringIsTooLong, 		    (CORBA::CompletionStatus)stream.completion());    mlen >>= stream;    stream.put_octet_array((const _CORBA_Octet*)b.buffer(), mlen);    return 1;  }  return 0;}_CORBA_BooleanTCS_C_UTF_8::fastUnmarshalChar(cdrStream&          stream,			       omniCodeSet::NCS_C* ncs,			       _CORBA_Char&        c){  if (ncs->id() == id()) { // Null transformation    c = stream.unmarshalOctet();    return 1;  }  return 0;}_CORBA_BooleanTCS_C_UTF_8::fastUnmarshalString(cdrStream&          stream,				 omniCodeSet::NCS_C* ncs,				 _CORBA_ULong        bound,				 _CORBA_ULong&       len,				 char*&              s){  if (ncs->id() == id()) { // Null transformation    _CORBA_ULong mlen; mlen <<= stream;    if (mlen == 0) {      if (orbParameters::strictIIOP) {	if (omniORB::trace(1)) {	  omniORB::logger l;	  l << "Error: received an invalid zero length string.\n";	}	OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		      (CORBA::CompletionStatus)stream.completion());      }      else {	if (omniORB::trace(1)) {	  omniORB::logger l;	  l << "Warning: received an invalid zero length string."	    << " Substituted with a proper empty string.\n";	}      }    }    if (bound && mlen-1 > bound)      OMNIORB_THROW(MARSHAL, MARSHAL_StringIsTooLong, 		    (CORBA::CompletionStatus)stream.completion());    if (!stream.checkInputOverrun(1, mlen))      OMNIORB_THROW(MARSHAL, MARSHAL_PassEndOfMessage,		    (CORBA::CompletionStatus)stream.completion());    s = omniCodeSetUtil::allocC(mlen);    omniCodeSetUtil::HolderC h(s);    stream.get_octet_array((_CORBA_Octet*)s, mlen);    if (s[mlen-1] != '\0')       OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		    (CORBA::CompletionStatus)stream.completion());    h.drop();    len = mlen - 1;    return 1;  }  else if (ncs->kind() == omniCodeSet::CS_8bit) { // Simple 8-bit set    const _CORBA_Char** fromU = ((omniCodeSet::NCS_C_8bit*)ncs)->fromU();    _CORBA_ULong mlen; mlen <<= stream;    if (mlen == 0) {      if (orbParameters::strictIIOP) {	if (omniORB::trace(1)) {	  omniORB::logger l;	  l << "Error: received an invalid zero length string.\n";	}	OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		      (CORBA::CompletionStatus)stream.completion());      }      else {	if (omniORB::trace(1)) {	  omniORB::logger l;	  l << "Warning: received an invalid zero length string."	    << " Substituted with a proper empty string.\n";	}      }    }    if (bound && mlen-1 > bound)      OMNIORB_THROW(MARSHAL, MARSHAL_StringIsTooLong, 		    (CORBA::CompletionStatus)stream.completion());    if (!stream.checkInputOverrun(1, mlen))      OMNIORB_THROW(MARSHAL, MARSHAL_PassEndOfMessage,		    (CORBA::CompletionStatus)stream.completion());    omniCodeSetUtil::BufferC        b; // *** Could initialise to mlen here    omniCodeSet::UniChar 	    uc;    _CORBA_Char          	    c;    int                  	    bytes;    CORBA::Octet         	    error = 0;    for (_CORBA_ULong i=0; i < mlen; i++) {      c   = stream.unmarshalOctet();      bytes = utf8Count[c];      uc    = c & utf8Mask[c];      // This switch is an attempt to avoid overhead in pipelined      // processors. Cases 2 and 1 should drop through with no      // branching code.      switch (bytes) {      case 6: OMNIORB_THROW(DATA_CONVERSION, 			    DATA_CONVERSION_BadInput,			    (CORBA::CompletionStatus)stream.completion());      case 5:      case 4:      case 3: OMNIORB_THROW(DATA_CONVERSION, 			    DATA_CONVERSION_BadInput,			    (CORBA::CompletionStatus)stream.completion());      case 2:	c = stream.unmarshalOctet(); i++;	uc = (uc << 6) | (c & 0x3f); error |= (c & 0xc0) ^ 0x80;      case 1:	c = stream.unmarshalOctet(); i++;	uc = (uc << 6) | (c & 0x3f); error |= (c & 0xc0) ^ 0x80;      }      c = fromU[(uc & 0xff00) >> 8][uc & 0x00ff];      if (uc && !c) OMNIORB_THROW(DATA_CONVERSION, 				  DATA_CONVERSION_BadInput,				  (CORBA::CompletionStatus)stream.completion());      b.insert(c);      if (error) {	// At least one extension byte was not of the form 10xxxxxx	OMNIORB_THROW(DATA_CONVERSION, 		      DATA_CONVERSION_BadInput,		      (CORBA::CompletionStatus)stream.completion());      }    }    if (uc != 0) // Check for null-terminator      OMNIORB_THROW(MARSHAL, MARSHAL_StringNotEndWithNull, 		    (CORBA::CompletionStatus)stream.completion());    s   = b.extract();    len = b.length() - 1;    return 1;  }  return 0;}//// Initialiser//static NCS_C_UTF_8 _NCS_C_UTF_8;static TCS_C_UTF_8 _TCS_C_UTF_8_11(omniCodeSetUtil::GIOP11);static TCS_C_UTF_8 _TCS_C_UTF_8_12(omniCodeSetUtil::GIOP12);class CS_UTF_8_init {public:  CS_UTF_8_init() {    omniCodeSet::registerNCS_C(&_NCS_C_UTF_8);    omniCodeSet::registerTCS_C(&_TCS_C_UTF_8_11);    omniCodeSet::registerTCS_C(&_TCS_C_UTF_8_12);  }};static CS_UTF_8_init _CS_UTF_8_init;OMNI_NAMESPACE_END(omni)OMNI_EXPORT_LINK_FORCE_SYMBOL(CS_UTF_8);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -