Esempio n. 1
0
        void testPlainEmpty()
        {
            std::ostringstream out;
            cxxtools::JsonSerializer serializer(out);
            serializer.finish();

            CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "");
        }
void WalletLegacySerializer::deserialize(std::istream& stream, const std::string& password, std::string& cache) {
  StdInputStream stdStream(stream);
  CryptoNote::BinaryInputStreamSerializer serializerEncrypted(stdStream);

  serializerEncrypted.beginObject("wallet");

  uint32_t version;
  serializerEncrypted(version, "version");
  // set serialization version global variable
  CryptoNote::WALLET_LEGACY_SERIALIZATION_VERSION = version;

  Crypto::chacha8_iv iv;
  serializerEncrypted(iv, "iv");

  std::string cipher;
  serializerEncrypted(cipher, "data");

  serializerEncrypted.endObject();

  std::string plain;
  decrypt(cipher, plain, iv, password);

  MemoryInputStream decryptedStream(plain.data(), plain.size()); 
  CryptoNote::BinaryInputStreamSerializer serializer(decryptedStream);

  loadKeys(serializer);
  throwIfKeysMissmatch(account.getAccountKeys().viewSecretKey, account.getAccountKeys().address.viewPublicKey);

  if (account.getAccountKeys().spendSecretKey != NULL_SECRET_KEY) {
    throwIfKeysMissmatch(account.getAccountKeys().spendSecretKey, account.getAccountKeys().address.spendPublicKey);
  } else {
    if (!Crypto::check_key(account.getAccountKeys().address.spendPublicKey)) {
      throw std::system_error(make_error_code(CryptoNote::error::WRONG_PASSWORD));
    }
  }

  bool detailsSaved;

  serializer(detailsSaved, "has_details");

  if (detailsSaved) {
    serializer(transactionsCache, "details");
  }

  serializer.binary(cache, "cache");
}
Esempio n. 3
0
        void testInt()
        {
            std::ostringstream out;
            cxxtools::JsonSerializer serializer(out);
            serializer.serialize(-4711, "value").finish();

            CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "{\"value\":-4711}");
        }
Esempio n. 4
0
        void testPlainInt()
        {
            std::ostringstream out;
            cxxtools::JsonSerializer serializer(out);
            serializer.serialize(-4711).finish();

            CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "-4711");
        }
Esempio n. 5
0
void
AudioSenderPlayerv1::sendOKClang()
{
    serializer().serializeOKClang( transport(),
                                   listener().clangMinVer(),
                                   listener().clangMaxVer() );
    transport() << std::ends << std::flush;
}
Esempio n. 6
0
void SkDebuggerGUI::saveToFile(const SkString& filename) {
    SkFILEWStream file(filename.c_str());
    SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture());

    SkAutoTUnref<SkPixelSerializer> serializer(
            SkImageEncoder::CreatePixelSerializer());
    copy->serialize(&file, serializer);
}
Esempio n. 7
0
void JsonRecordingList::finish()
{
  cxxtools::JsonSerializer serializer(*s->getBasicStream());
  serializer.serialize(serRecordings, "recordings");
  serializer.serialize(serRecordings.size(), "count");
  serializer.serialize(total, "total");
  serializer.finish();
}
static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::EncodingPolicy encodingPolicy)
{
    Vector<SerializedResource> resources;
    PageSerializer serializer(&resources);
    serializer.serialize(page);
    Document* document = page->deprecatedLocalMainFrame()->document();
    return MHTMLArchive::generateMHTMLData(resources, encodingPolicy, document->title(), document->suggestedMIMEType());
}
Esempio n. 9
0
void JsonChannelGroupList::finish()
{  
  cxxtools::JsonSerializer serializer(*s->getBasicStream());
  serializer.serialize(groups, "groups");
  serializer.serialize(Count(), "count");
  serializer.serialize(total, "total");
  serializer.finish();
}
Esempio n. 10
0
ALWAYS_INLINE bool SerializeJsval( JSContext *cx, SerializedData *ser, jsval *val ) {

	jl::Serializer serializer(cx);
	JL_CHK( serializer.Write(cx, *val) );
	JL_CHK( serializer.GetBufferOwnership(&ser->data, &ser->length) );
	return true;
	JL_BAD;
}
Esempio n. 11
0
void
ReliableSession::nak_received(ACE_Message_Block* control)
{
  if (! this->active_) return; // sub send naks, then doesn't receive them.

  const TransportHeader& header =
    this->link_->receive_strategy()->received_header();

  Serializer serializer(
    control, header.swap_bytes());

  MulticastPeer local_peer;
  CORBA::ULong size = 0;
  serializer >> local_peer; // sent as remote_peer
  serializer >> size;

  std::vector<SequenceRange> ranges;

  for (CORBA::ULong i = 0; i < size; ++i) {
    SequenceNumber::Value low;
    serializer >> low;

    SequenceNumber::Value high;
    serializer >> high;

    ranges.push_back (SequenceRange (low, high));
  }

  // Track peer repair requests for later suppression:
  if (local_peer == this->remote_peer_) {
    for (CORBA::ULong i = 0; i < size; ++i) {
      this->nak_peers_.insert(ranges[i]);
    }
    return;
  }

  // Ignore sample if not destined for us:
  if ((local_peer != this->link_->local_peer())        // Not to us.
    || (this->remote_peer_ != header.source_)) return; // Not from the remote peer for this session.

  TransportSendBuffer* send_buffer = this->link_->send_buffer();
  // Broadcast a MULTICAST_NAKACK control sample before resending to suppress
  // repair requests for unrecoverable samples by providing a
  // new low-water mark for affected peers:
  if (!send_buffer->empty() && send_buffer->low() > ranges.begin()->first) {
    send_nakack(send_buffer->low());
  }

  for (CORBA::ULong i = 0; i < size; ++i) {
    bool ret = send_buffer->resend(ranges[i]);
    if (OpenDDS::DCPS::DCPS_debug_level > 0) {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ReliableSession::nak_received")
                            ACE_TEXT (" %d <- %d %d - %d resend result %d\n"),
                            this->link_->local_peer(), this->remote_peer_,
                            ranges[i].first.getValue(), ranges[i].second.getValue(), ret));
    }
  }
}
Esempio n. 12
0
 void test_write_workbook_()
 {
     xlnt::workbook wb;
     xlnt::workbook_serializer serializer(wb);
     auto observed = serializer.write_workbook();
     auto filename = PathHelper::GetDataDirectory("/workbook.xml");
     auto diff = Helper::compare_xml(PathHelper::read_file(filename), observed);
     TS_ASSERT(!diff);
 }
Esempio n. 13
0
void
AudioSenderCoachv1::sendRefereeAudio( const char * msg )
{
    if ( generalPredicate() )
    {
        serializer().serializeRefereeAudio( transport(), M_stadium.time(), msg );
        transport() << std::ends << std::flush;
    }
}
Esempio n. 14
0
void
AudioSenderPlayerv1::sendSelfAudio( const char * msg )
{
    if ( generalPredicate() )
    {
        serializer().serializeSelfAudio( transport(), M_stadium.time(), msg );
        transport() << std::ends << std::flush;
    }
}
void
FullStateSenderPlayerV8::sendBall()
{
    serializer().serializeFSBall( transport(),
                                  stadium().ball().pos().x,
                                  stadium().ball().pos().y,
                                  stadium().ball().vel().x,
                                  stadium().ball().vel().y );
}
Esempio n. 16
0
void LocalSettings::load()
{
    DataSerializer serializer( m_path );

    if ( !serializer.openForReading() )
        return;

    serializer.stream() >> m_data;
}
Esempio n. 17
0
        void testEmptyObject()
        {
            std::ostringstream out;
            cxxtools::JsonSerializer serializer(out);
            serializer.setObject();
            serializer.finish();

            CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "{}");
        }
Esempio n. 18
0
std::string JGenerator::serialize(const JValue &val, const JSchema &schema, JResolver *resolver)
{
	JGenerator serializer(resolver);
	std::string serialized;
	if (!serializer.toString(val, schema, serialized)) {
		serialized = "";
	}
	return serialized;
}
Esempio n. 19
0
void Packet::write(const Object* object)
{
	SetBitFlag(flags, PacketFlags::Binary, true);

	SerializerBinary serializer(AllocatorGetThis(), 0);
	serializer.stream = &ms;

	serializer.save(object);
}
void
InitSenderPlayerV1::sendInit()
{
    serializer().serializeInit( transport(),
                                SideStr( self().side() ),
                                self().unum(),
                                stadium().playmode() );
    transport() << std::ends << std::flush;
}
Esempio n. 21
0
int sockets_sendSerialized(t_socket_client *client, void *data, t_socket_sbuffer *(*serializer)(void*)){
	t_socket_sbuffer *sbuffer = serializer(data);
	if( sbuffer != NULL){
		int ret = sockets_send(client, (void*)sbuffer->serializated_data, sbuffer->size);
		free( sbuffer->serializated_data );
		free( sbuffer );
		return ret;
	}
	return -1;
}
Esempio n. 22
0
void Database::Statement::write(const Serializable &s)
{
	if(mOutputLevel == 0 || s.isInlineSerializable()) s.serialize(*this);
	else {
		String tmp;
		JsonSerializer serializer(&tmp);
		s.serialize(serializer);
		write(tmp);
	}
}
Esempio n. 23
0
        void testMultipleObjects()
        {
            std::ostringstream out;
            cxxtools::JsonSerializer serializer(out);
            serializer.serialize("Hi", "a")
                      .serialize(42, "b")
                      .finish();

            CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "{\"a\":\"Hi\",\"b\":42}");
        }
Esempio n. 24
0
uint8_t*
SharedRGBImage::GetBuffer()
{
  if (!mTextureClient) {
    return nullptr;
  }

  ImageDataSerializer serializer(mTextureClient->GetBuffer());
  return serializer.GetData();
}
Esempio n. 25
0
T serializationOfType(T inValue) {
    std::string filename = SERIALITION_FILE_NAME;
    IvwSerializer serializer(filename);
    serializer.serialize("serializedValue", inValue);
    serializer.writeFile();
    IvwDeserializer deserializer(filename);
    T outValue;
    deserializer.deserialize("serializedValue", outValue);
    return outValue;
}
void WalletSerializer::deserialize(std::istream& stream, const std::string& password, std::string& cache) {
  cryptonote::BinaryInputStreamSerializer serializerEncrypted(stream);

  serializerEncrypted.beginObject("wallet");

  uint32_t version;
  serializerEncrypted(version, "version");

  crypto::chacha8_iv iv;
  serializerEncrypted(iv, "iv");

  std::string cipher;
  serializerEncrypted(cipher, "data");

  serializerEncrypted.endObject();

  std::string plain;
  decrypt(cipher, plain, iv, password);

  std::stringstream decryptedStream(plain);

  cryptonote::BinaryInputStreamSerializer serializer(decryptedStream);

  try
  {
    loadKeys(serializer);
    throwIfKeysMissmatch(account.get_keys().m_view_secret_key, account.get_keys().m_account_address.m_viewPublicKey);
    throwIfKeysMissmatch(account.get_keys().m_spend_secret_key, account.get_keys().m_account_address.m_spendPublicKey);
  }
  catch (std::exception&) {
    throw std::system_error(make_error_code(cryptonote::error::WRONG_PASSWORD));
  }

  bool detailsSaved;

  serializer(detailsSaved, "has_details");

  if (detailsSaved) {
    serializer(transactionsCache, "details");
  }

  serializer.binary(cache, "cache");
}
Esempio n. 27
0
    void test_write_empty_workbook()
    {
        xlnt::workbook wb;
        TemporaryFile file;

        xlnt::excel_serializer serializer(wb);
        serializer.save_workbook(file.GetFilename());
        
        TS_ASSERT(PathHelper::FileExists(file.GetFilename()));
    }
Esempio n. 28
0
 void test_write_workbook_()
 {
     xlnt::workbook wb;
     xlnt::workbook_serializer serializer(wb);
     pugi::xml_document xml;
     serializer.write_workbook(xml);
     auto filename = PathHelper::GetDataDirectory("/workbook.xml");
     auto diff = Helper::compare_xml(PathHelper::read_file(filename), xml);
     TS_ASSERT(!diff);
 }
Esempio n. 29
0
 void test_write_hidden_single_worksheet()
 {
     xlnt::workbook wb;
     auto ws = wb.get_active_sheet();
     ws.set_sheet_state(xlnt::sheet_state::hidden);
     
     xlnt::workbook_serializer serializer(wb);
     
     TS_ASSERT_THROWS(serializer.write_workbook(), xlnt::value_error);
 }
Esempio n. 30
0
bool FBug96Test()
{
    Bug96Test::simpleStruct_6 si;

    si.en(Bug96Test::GREEN);

    // Create the serializer object.
    char *buffer = (char*)calloc(1, si.getMaxSerializedSize());
    eprosima::FastBuffer fbuffer(buffer, si.getMaxSerializedSize());
    EnumerationsSer serializer(fbuffer);

    // Serialize structure.
    try
    {
        serializer << si;
    }
    catch(eprosima::Exception &ex)
    {
        std::cout << "TEST FAILED<FBug96Test>: Serialization. " << ex.what() << std::endl;
        free(buffer);
        return false;
    }

    // Reset serializer object.
    serializer.reset();

    // Object used to deserialize the data.
    Bug96Test::simpleStruct_6 sires;

    // Deserialize structure.
    try
    {
        serializer >> sires;
    }
    catch(eprosima::Exception &ex)
    {
        std::cout << "TEST FAILED<FBug95Test>: Deserialization. " << ex.what() << std::endl;
        free(buffer);
        return false;
    }

    // Compare data.
    bool compareOK = true;

    compareOK &= si.en() == sires.en();

    if(!compareOK)
    {
        std::cout << "TEST FAILED<FBug96Test>: Wrong values" << std::endl;
        free(buffer);
        return false;
    }

    return true;
}