当前位置: 首页>>代码示例>>C++>>正文


C++ BinaryStream类代码示例

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


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

示例1: TestArray

void TestBinaryStream::TestArray()
{
	Registry R;
	R.AddClass<Array>("Array");
	R.AddClass<int>("int");

	Pointer<Array> A = R.New<Array>();
	A->Append(R.New(0));
	A->Append(R.New(1));
	A->Append(R.New(2));
	A->Append(R.New(3));

	BinaryStream S;
	S.SetRegistry(&R);

	S << A;
	Object Q;
	S >> Q;

	KAI_TEST_FALSE(S.CanRead(1));
	KAI_TEST_EQUIV(Q.GetTypeNumber(), Type::Traits<Array>::Number);
	const Array &B = ConstDeref<Array>(Q);
	KAI_TEST_EQUIV(B.Size(), 4);
	KAI_TEST_EQUIV(ConstDeref<int>(B.At(0)), 0);
	KAI_TEST_EQUIV(ConstDeref<int>(B.At(1)), 1);
	KAI_TEST_EQUIV(ConstDeref<int>(B.At(2)), 2);
	KAI_TEST_EQUIV(ConstDeref<int>(B.At(3)), 3);
}
开发者ID:kalineh,项目名称:KAI,代码行数:28,代码来源:TestBinaryStream.cpp

示例2: LoadBinAC

    O3DGCErrorCode    LoadBinAC(Vector<long> & data,
                                const BinaryStream & bstream,
                                unsigned long & iterator) 
    {
        size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 8;
        size_t size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Bit_Model bModel;
#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(size_t i = 0; i < size; ++i)
        {
            data.PushBack(acd.decode(bModel));
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
        return O3DGC_OK;
    }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:32,代码来源:o3dgcTriangleFans.cpp

示例3: LoadUIntAC

    O3DGCErrorCode    LoadUIntAC(Vector<long> & data,
                                 const unsigned long M,
                                 const BinaryStream & bstream,
                                 unsigned long & iterator) 
    {
        unsigned long sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
        unsigned long size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        long minValue   = bstream.ReadUInt32Bin(iterator);
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Data_Model mModelValues(M+1);
#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(unsigned long i = 0; i < size; ++i)
        {
            data.PushBack(acd.decode(mModelValues)+minValue);
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
        return O3DGC_OK;
    }
开发者ID:1vanK,项目名称:Urho3D,代码行数:34,代码来源:o3dgcTriangleFans.cpp

示例4: FromMsgExecReply

Message FromMsgExecReply(const MsgExecReply& result){
	BinaryStream stream;
	stream<<result.exitStatus;
	stream.Write(result.type);
	stream<<result.output<<result.error<<result.memory<<result.time;
	Message msg;
	msg.type=EXEC_REPLY;
	msg.size=stream.Length();
	msg.body=stream.buffer;
	return msg;
}
开发者ID:yangzhixuan,项目名称:AllKorrect,代码行数:11,代码来源:Message.cpp

示例5: sizeof

typename std::enable_if<std::is_trivially_copyable<T>::value, BinaryStream&>::type operator>>(BinaryStream& stream,
                                                                                              T& value)
{
	std::streamsize r = stream.readHard(&value, sizeof(value));
	if (r != static_cast<std::streamsize>(sizeof(value)))
	{
		stream.setState(std::ios_base::failbit);
	}

	return stream;
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:11,代码来源:binary_stream.hpp

示例6: operator

  bool operator()(BinaryStream const& rBinStrm, TOffset Offset, Operand* pOprd)
  {
    u16 Seg;
    OffType Off;

    rBinStrm.Read(Offset + sizeof(OffType), Seg);
    rBinStrm.Read(Offset, Off);
    pOprd->SetValue(Off);
    pOprd->SetSegValue(Seg);
    pOprd->SetType(OpType | O_SEG_VAL);
    return true;
  }
开发者ID:episeclab,项目名称:medusa,代码行数:12,代码来源:x86_operand.cpp

示例7: IsCompatible

bool GameBoyLoader::IsCompatible(BinaryStream const& rBinStrm)
{
  if (rBinStrm.GetSize() < GAMEBOY_HEADER_OFFSET + sizeof m_GameBoyRom)
    return false;

  if (!rBinStrm.Read(GAMEBOY_HEADER_OFFSET, reinterpret_cast<u8*>(&m_GameBoyRom), sizeof m_GameBoyRom))
    return false;

  if (memcmp(m_GameBoyRom.NintendoLogo, s_NintendoLogo, NINTENDO_LOGO_LEN))
    return false;

  return true;
}
开发者ID:GrimDerp,项目名称:medusa,代码行数:13,代码来源:gameboy_loader.cpp

示例8: LoadIntData

 O3DGCErrorCode    LoadIntData(Vector<long> & data,
                               const BinaryStream & bstream,
                               unsigned long & iterator) 
 {
     bstream.ReadUInt32ASCII(iterator);
     const unsigned long size = bstream.ReadUInt32ASCII(iterator);
     data.Allocate(size);
     data.Clear();
     for(size_t i = 0; i < size; ++i)
     {
         data.PushBack(bstream.ReadIntASCII(iterator));
     }
     return O3DGC_OK;
 }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:14,代码来源:o3dgcTriangleFans.cpp

示例9: LoadIntACEGC

    O3DGCErrorCode    LoadIntACEGC(Vector<long> & data,
                                   const unsigned long M,
                                   const BinaryStream & bstream,
                                   unsigned long & iterator) 
    {
        size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
        size_t size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        long minValue   = bstream.ReadUInt32Bin(iterator) - O3DGC_MAX_LONG;
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Data_Model mModelValues(M+2);
        Static_Bit_Model bModel0;
        Adaptive_Bit_Model bModel1;
        unsigned long value;

#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(size_t i = 0; i < size; ++i)
        {
            value = acd.decode(mModelValues);
            if ( value == M)
            {
                value += acd.ExpGolombDecode(0, bModel0, bModel1);
            }
            data.PushBack(value + minValue);
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
#ifdef DEBUG_VERBOSE
        fflush(g_fileDebugTF);
#endif //DEBUG_VERBOSE
        return O3DGC_OK;
    }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:46,代码来源:o3dgcTriangleFans.cpp

示例10: LoadBinData

 O3DGCErrorCode    LoadBinData(Vector<long> & data,
                               const BinaryStream & bstream,
                               unsigned long & iterator) 
 {
     bstream.ReadUInt32ASCII(iterator);
     const unsigned long size = bstream.ReadUInt32ASCII(iterator);
     long symbol;
     data.Allocate(size * O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0);
     data.Clear();
     for(size_t i = 0; i < size;)
     {
         symbol = bstream.ReadUCharASCII(iterator);
         for(unsigned long h = 0; h < O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0; ++h)
         {
             data.PushBack(symbol & 1);
             symbol >>= 1;
             ++i;
         }
     }
     return O3DGC_OK;
 }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:21,代码来源:o3dgcTriangleFans.cpp

示例11: TestObject

void TestBinaryStream::TestObject()
{
	Registry R;
	R.AddClass<int>("int");

	BinaryStream S;
	S.SetRegistry(&R);

	Pointer<int> N = R.New(42);
	S << N;
	Object Q;
	S >> Q;
	KAI_TEST_FALSE(S.CanRead(1));
	KAI_TEST_EQUIV(Q.GetTypeNumber(), Type::Traits<int>::Number);
	KAI_TEST_EQUIV(ConstDeref<int>(Q), 42);

	S.Clear();
	KAI_TEST_TRUE(S.Empty());

	N.Set("child0", R.New(123));
	S << N;
	Object M;
	S >> M;
	KAI_TEST_FALSE(S.CanRead(1));
	KAI_TEST_EQUIV(ConstDeref<int>(M), 42);
	KAI_TEST_TRUE(M.Has("child0"));
	KAI_TEST_EQUIV(ConstDeref<int>(M.Get("child0")), 123);
}
开发者ID:kalineh,项目名称:KAI,代码行数:28,代码来源:TestBinaryStream.cpp

示例12: mModelValues

    O3DGCErrorCode    CompressedTriangleFans::SaveUIntAC(const Vector<long> & data,
                                                         const unsigned long M,
                                                         BinaryStream & bstream) 
    {
        unsigned long start = bstream.GetSize();     
        const unsigned int NMAX = data.GetSize() * 8 + 100;
        const size_t size       = data.GetSize();
        long minValue = O3DGC_MAX_LONG;
        bstream.WriteUInt32Bin(0);
        bstream.WriteUInt32Bin(size);
        if (size > 0)
        {
    #ifdef DEBUG_VERBOSE
            printf("-----------\nsize %i, start %i\n", size, start);
            fprintf(g_fileDebugTF, "-----------\nsize %i, start %i\n", size, start);
    #endif //DEBUG_VERBOSE

            for(size_t i = 0; i < size; ++i)
            {
                if (minValue > data[i]) 
                {
                    minValue = data[i];
                }
    #ifdef DEBUG_VERBOSE
                printf("%i\t%i\n", i, data[i]);
                fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
    #endif //DEBUG_VERBOSE
            }
            bstream.WriteUInt32Bin(minValue);
            if ( m_sizeBufferAC < NMAX )
            {
                delete [] m_bufferAC;
                m_sizeBufferAC = NMAX;
                m_bufferAC     = new unsigned char [m_sizeBufferAC];
            }
            Arithmetic_Codec ace;
            ace.set_buffer(NMAX, m_bufferAC);
            ace.start_encoder();
            Adaptive_Data_Model mModelValues(M+1);
            for(size_t i = 0; i < size; ++i)
            {
                ace.encode(data[i]-minValue, mModelValues);
            }
            unsigned long encodedBytes = ace.stop_encoder();
            for(size_t i = 0; i < encodedBytes; ++i)
            {
                bstream.WriteUChar8Bin(m_bufferAC[i]);
            }
        }
        bstream.WriteUInt32Bin(start, bstream.GetSize() - start);
        return O3DGC_OK;
    }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:52,代码来源:o3dgcTriangleFans.cpp

示例13: operator

  bool operator()(BinaryStream const& rBinStrm, X86_Bit Bit, TOffset Offset, Instruction& rInsn, Operand* pOprd)
  {
    ConstType ct;

    rBinStrm.Read(Offset, ct);
    pOprd->SetValue(SignExtend<ConstType, Pos>(ct));
    switch (Bit)
    {
    case X86_Bit_16: pOprd->SetType(O_REL16); break;
    case X86_Bit_32: pOprd->SetType(O_REL32); break;
    case X86_Bit_64: pOprd->SetType(O_REL64); break;
    default:         pOprd->SetType(O_NONE);  break;
    }
    pOprd->SetOffset(static_cast<u8>(rInsn.GetLength()));
    rInsn.Length() += sizeof(ct);
    return true;
  }
开发者ID:anat,项目名称:medusa,代码行数:17,代码来源:x86_operand.cpp

示例14: SaveIntData

 O3DGCErrorCode    SaveIntData(const Vector<long> & data,
                               BinaryStream & bstream) 
 {
     unsigned long start = bstream.GetSize();
     bstream.WriteUInt32ASCII(0);
     const size_t size       = data.GetSize();
     bstream.WriteUInt32ASCII(size);
     for(size_t i = 0; i < size; ++i)
     {
         bstream.WriteIntASCII(data[i]);
     }
     bstream.WriteUInt32ASCII(start, bstream.GetSize() - start);
     return O3DGC_OK;
 }
开发者ID:RemiArnaud,项目名称:rest3d,代码行数:14,代码来源:o3dgcTriangleFans.cpp

示例15: FormatCharacter

bool Architecture::FormatCharacter(
  Document      const& rDoc,
  BinaryStream  const& rBinStrm,
  Address       const& rAddr,
  Character     const& rChar,
  std::string        & rStrCell,
  Cell::Mark::List   & rMarks) const
{
  std::ostringstream oss;
  TOffset Off;

  if (!rDoc.ConvertAddressToFileOffset(rAddr, Off))
    return false;

  switch (rChar.GetSubType())
  {
  case Character::AsciiCharacterType: default:
    {
      s8 Char;
      if (!rBinStrm.Read(Off, Char))
        return false;

      switch (Char)
      {
      case '\0': oss << "\\0"; break;
      case '\a': oss << "\\a"; break;
      case '\b': oss << "\\b"; break;
      case '\t': oss << "\\t"; break;
      case '\n': oss << "\\n"; break;
      case '\v': oss << "\\v"; break;
      case '\f': oss << "\\f"; break;
      case '\r': oss << "\\r"; break;
      default:   oss << Char;  break;
      }
    }
  }
  rMarks.push_back(Cell::Mark(Cell::Mark::StringType, 1));
  rStrCell = oss.str();
  return true;
}
开发者ID:anat,项目名称:medusa,代码行数:40,代码来源:architecture.cpp


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