void
PresenceMap::decode(Codecs::DataSource & source)
{
  reset();

  uchar byte = 0;
  if(!source.getByte(byte))
  {
    throw EncodingError("[ERR U03] EOF while decoding presence map.");
  }
  size_t pos = 0;
  while((byte & stopBit) == 0)
  {
    appendByte(pos, byte);
    if(!source.getByte(byte))
    {
      throw EncodingError("[ERR U03] EOF while decoding presence map.");
    }
  }
  appendByte(pos, byte);

  if(vout_)
  {
    (*vout_) << "pmap["  <<  byteCapacity_ << "]<-" << std::hex;
    for(size_t iter = 0; iter < pos; ++iter)
    {
      (*vout_) << ' ' << std::setw(2) <<  static_cast<unsigned short>(bits_[iter]);
    }
    (*vout_) << std::dec << std::endl;
  }
}
예제 #2
0
bool
FieldInstruction::decodeAscii(
  Codecs::DataSource & source,
  WorkingBuffer & workingBuffer)
{
  workingBuffer.clear(false);
  uchar byte = 0;
  if(!source.getByte(byte))
  {
    return false;
  }
  while((byte & stopBit) == 0)
  {
    workingBuffer.push(byte);
    if(!source.getByte(byte))
    {
      // todo: exception?
      return false;
    }
  }
  workingBuffer.push(byte & dataBits);
  return true;
}
예제 #3
0
void
FieldInstruction::decodeByteVector(
  Codecs::Context & decoder,
  Codecs::DataSource & source,
  const std::string & name,
  WorkingBuffer & buffer,
  size_t length)
{
  buffer.clear(false, length);
  for(size_t pos = 0;
    pos < length;
    ++pos)
  {
    uchar byte = 0;
    if(!source.getByte(byte))
    {
      decoder.reportFatal("[ERR U03]", "End of file: Too few bytes in ByteVector.", name);
    }
    buffer.push(byte);
  }
}