示例#1
0
      bool UccSession::classifyMessage (BufferType& buff, TypeId& type, KeyType& key)
      {
        bool found = AbsSessionType::classifyMessage(buff, type, key);
        if ((!found) && (!m_buffer.empty()))
        {
          SizeType parsedSize = 0;
          SizeType structureSize = 0;
          gvr::utils::Json json;
          unsigned char flag = 0;
          switch (IUccClassifyMessage::parseToStructure(m_buffer,parsedSize,structureSize,flag,json))
          {
          case IClassifyMessageType::Integrity::CComplete:
          case IClassifyMessageType::Integrity::CUnknown:
            {
              if (parsedSize)
              {
                if (m_buffer.size() > parsedSize)
                {
                  buff.reserve(parsedSize);
                  buff.assign(m_buffer.begin(),m_buffer.begin()+(parsedSize));

                  SizeType remainingSize = (m_buffer.size()-parsedSize);
                  BufferType remainingBuffer;
                  remainingBuffer.reserve(remainingSize);
                  remainingBuffer.assign(m_buffer.begin()+(parsedSize),m_buffer.end());
                  m_buffer.swap(remainingBuffer);
                }
                else
                {
                  m_buffer.swap(buff);
                  m_buffer.clear();
                }
                type = UccMessageAny::GetTypeId();
                key = UccMessageAny::CDefaultKey;
                found = true;
              }
              else
              {
                m_buffer.clear();
              }
            }
            break;
          case IClassifyMessageType::Integrity::CIncomplete:
            break;
          default:
            {
              m_buffer.clear();
            }
            break;
          }
        }
        return found;
      }
示例#2
0
void DataSetter::SetData(void* data, size_t elementSize, size_t offset, size_t numElements)
{
	m_ElementSize = elementSize;
	m_Offset = offset;
	m_NumElements = numElements;

	unsigned char* first = (unsigned char*)data + (offset * numElements);
	unsigned char* last = first + (numElements * elementSize);
	m_Data.assign(first, last);
}