예제 #1
0
void ManyFields::serialize(carbon::CarbonProtocolWriter& writer) const {
  writer.writeStructBegin();
  writer.writeField(1 /* field id */, buf1());
  writer.writeField(2 /* field id */, buf2());
  writer.writeField(3 /* field id */, buf3());
  writer.writeField(4 /* field id */, buf4());
  writer.writeField(5 /* field id */, buf5());
  writer.writeField(6 /* field id */, buf6());
  writer.writeField(7 /* field id */, buf7());
  writer.writeField(8 /* field id */, buf8());
  writer.writeField(9 /* field id */, buf9());
  writer.writeField(10 /* field id */, buf10());
  writer.writeField(11 /* field id */, buf11());
  writer.writeField(12 /* field id */, buf12());
  writer.writeField(13 /* field id */, buf13());
  writer.writeField(14 /* field id */, buf14());
  writer.writeField(15 /* field id */, buf15());
  writer.writeField(16 /* field id */, buf16());
  writer.writeField(17 /* field id */, buf17());
  writer.writeField(18 /* field id */, buf18());
  writer.writeField(19 /* field id */, buf19());
  writer.writeField(20 /* field id */, buf20());
  writer.writeField(21 /* field id */, buf21());
  writer.writeField(22 /* field id */, buf22());
  writer.writeField(23 /* field id */, buf23());
  writer.writeField(24 /* field id */, buf24());
  writer.writeField(25 /* field id */, buf25());
  writer.writeField(26 /* field id */, buf26());
  writer.writeField(27 /* field id */, buf27());
  writer.writeField(28 /* field id */, buf28());
  writer.writeField(29 /* field id */, buf29());
  writer.writeField(30 /* field id */, buf30());
  writer.writeField(31 /* field id */, buf31());
  writer.writeField(32 /* field id */, buf32());
  writer.writeField(33 /* field id */, buf33());
  writer.writeField(34 /* field id */, buf34());
  writer.writeField(35 /* field id */, buf35());
  writer.writeField(36 /* field id */, buf36());
  writer.writeField(37 /* field id */, buf37());
  writer.writeField(38 /* field id */, buf38());
  writer.writeField(39 /* field id */, buf39());
  writer.writeField(40 /* field id */, buf40());
  writer.writeFieldStop();
  writer.writeStructEnd();
}
예제 #2
0
void StringTestCase::ScopedBuffers()
{
    // wxString relies on efficient buffers, verify they work as they should

    const char *literal = "Hello World!";

    // non-owned buffer points to the string passed to it
    wxScopedCharBuffer sbuf = wxScopedCharBuffer::CreateNonOwned(literal);
    CPPUNIT_ASSERT( sbuf.data() == literal );

    // a copy of scoped non-owned buffer still points to the same string
    wxScopedCharBuffer sbuf2(sbuf);
    CPPUNIT_ASSERT( sbuf.data() == sbuf2.data() );

    // but assigning it to wxCharBuffer makes a full copy
    wxCharBuffer buf(sbuf);
    CPPUNIT_ASSERT( buf.data() != literal );
    CPPUNIT_ASSERT_EQUAL( literal, buf.data() );

    wxCharBuffer buf2 = sbuf;
    CPPUNIT_ASSERT( buf2.data() != literal );
    CPPUNIT_ASSERT_EQUAL( literal, buf.data() );

    // Check that extending the buffer keeps it NUL-terminated.
    size_t len = 10;

    wxCharBuffer buf3(len);
    CPPUNIT_ASSERT_EQUAL('\0', buf3.data()[len]);

    wxCharBuffer buf4;
    buf4.extend(len);
    CPPUNIT_ASSERT_EQUAL('\0', buf4.data()[len]);

    wxCharBuffer buf5(5);
    buf5.extend(len);
    CPPUNIT_ASSERT_EQUAL('\0', buf5.data()[len]);
}
예제 #3
0
void ManyFields::deserialize(carbon::CarbonProtocolReader& reader) {
  reader.readStructBegin();
  while (true) {
    const auto pr = reader.readFieldHeader();
    const auto fieldType = pr.first;
    const auto fieldId = pr.second;

    if (fieldType == carbon::FieldType::Stop) {
      break;
    }

    switch (fieldId) {
      case 1: {
        reader.readField(buf1(), fieldType);
        break;
      }
      case 2: {
        reader.readField(buf2(), fieldType);
        break;
      }
      case 3: {
        reader.readField(buf3(), fieldType);
        break;
      }
      case 4: {
        reader.readField(buf4(), fieldType);
        break;
      }
      case 5: {
        reader.readField(buf5(), fieldType);
        break;
      }
      case 6: {
        reader.readField(buf6(), fieldType);
        break;
      }
      case 7: {
        reader.readField(buf7(), fieldType);
        break;
      }
      case 8: {
        reader.readField(buf8(), fieldType);
        break;
      }
      case 9: {
        reader.readField(buf9(), fieldType);
        break;
      }
      case 10: {
        reader.readField(buf10(), fieldType);
        break;
      }
      case 11: {
        reader.readField(buf11(), fieldType);
        break;
      }
      case 12: {
        reader.readField(buf12(), fieldType);
        break;
      }
      case 13: {
        reader.readField(buf13(), fieldType);
        break;
      }
      case 14: {
        reader.readField(buf14(), fieldType);
        break;
      }
      case 15: {
        reader.readField(buf15(), fieldType);
        break;
      }
      case 16: {
        reader.readField(buf16(), fieldType);
        break;
      }
      case 17: {
        reader.readField(buf17(), fieldType);
        break;
      }
      case 18: {
        reader.readField(buf18(), fieldType);
        break;
      }
      case 19: {
        reader.readField(buf19(), fieldType);
        break;
      }
      case 20: {
        reader.readField(buf20(), fieldType);
        break;
      }
      case 21: {
        reader.readField(buf21(), fieldType);
        break;
      }
      case 22: {
        reader.readField(buf22(), fieldType);
        break;
      }
      case 23: {
        reader.readField(buf23(), fieldType);
        break;
      }
      case 24: {
        reader.readField(buf24(), fieldType);
        break;
      }
      case 25: {
        reader.readField(buf25(), fieldType);
        break;
      }
      case 26: {
        reader.readField(buf26(), fieldType);
        break;
      }
      case 27: {
        reader.readField(buf27(), fieldType);
        break;
      }
      case 28: {
        reader.readField(buf28(), fieldType);
        break;
      }
      case 29: {
        reader.readField(buf29(), fieldType);
        break;
      }
      case 30: {
        reader.readField(buf30(), fieldType);
        break;
      }
      case 31: {
        reader.readField(buf31(), fieldType);
        break;
      }
      case 32: {
        reader.readField(buf32(), fieldType);
        break;
      }
      case 33: {
        reader.readField(buf33(), fieldType);
        break;
      }
      case 34: {
        reader.readField(buf34(), fieldType);
        break;
      }
      case 35: {
        reader.readField(buf35(), fieldType);
        break;
      }
      case 36: {
        reader.readField(buf36(), fieldType);
        break;
      }
      case 37: {
        reader.readField(buf37(), fieldType);
        break;
      }
      case 38: {
        reader.readField(buf38(), fieldType);
        break;
      }
      case 39: {
        reader.readField(buf39(), fieldType);
        break;
      }
      case 40: {
        reader.readField(buf40(), fieldType);
        break;
      }
      default: {
        reader.skip(fieldType);
        break;
      }
    }
  }
  reader.readStructEnd();
}