Exemplo n.º 1
0
SepaHeader* SepaHandler::buildHeader(XmlNode* headerNode)
{
    SepaHeader* sepaHeader = new SepaHeader();
    if (XmlNode* creationDateNode = headerNode->first_node(Constants::CREATION_DATE))
    {
        decodeField(sepaHeader->creationDate, creationDateNode);
    }
    else
    {
        sepaHeader->creationDate = boost::posix_time::second_clock::local_time();
    }

    if (XmlNode* settlementDateNode = headerNode->first_node(Constants::INTERBANK_SETTLEMENT_DATE))
    {
        decodeField(sepaHeader->settlementDate, settlementDateNode);
    }
    else
    {
        sepaHeader->settlementDate = boost::posix_time::second_clock::local_time();
    }

    if (XmlNode* messageIdNode = headerNode->first_node(Constants::MESSAGE_ID))
    {
        decodeField(sepaHeader->messageId, messageIdNode);
    }
    return sepaHeader;
}
uint32_t MamaRecordedMessageCodec::decodeMsg(char* buffer, MamaMsg* mm)
{
	uint32_t buffer_size = 0;
	// include buffer size in initialization of return integer
	uint32_t r = 4;
	int i = 0;
	int i_limit = 50;

	// Establish the buffer size...
	memcpy(&buffer_size, buffer, 4);
	buffer += 4;
	//prinft("Decoding Msg of size [%d]...\n", buffer_size);
	while(r < buffer_size && i < i_limit)
	{
		try
		{
			r += decodeField(buffer, mm);
		}
		catch(MamaStatus& ms)
		{
			// Pretend this field never happened...
			//printf("Skipping decoding of MAMA Field - MAMA exception encountered: %s\n", ms.toString());
		}

		//printf("r = %d [%d]\n", r, buffer_size);
		i++;
	}

	return r;
}