Commit 9f053e53 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

Fix xml parsing of SDFBlocks.

parent 130beaa6
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ char* ConfigurationFile::getLine() throw(PacketExceptionIO*)
char* ConfigurationFile::getLine(const char* s) throw(PacketExceptionIO*)
{
    char* line;

    try
    {
        line = this->getLine();
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include "Field.h"
#include "Utility.h"

//#define DEBUG 1

using namespace PacketLib;

static FieldType** filedTypeList = 0;
@@ -92,7 +94,7 @@ Field::Field(std::string name, std::string typeStr, std::string dim, std::string
		type->dimension = atoi(dim.c_str());
		type->type = Field::typeStringToEnum[typeStr];
#ifdef DEBUG
		std::cout << "Adding field '" << name << "' at index " << i << ", " << type->dimension << " bits type " << typeStr << " (" << type->type << ")" << std::endl;
		std::cout << "Adding field '" << name << "', " << type->dimension << " bits type " << typeStr << " (" << type->type << ")" << std::endl;
#endif

        if(prVal.compare("none") != 0)
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

using namespace PacketLib;

#undef DEBUG

InputPacketStream::InputPacketStream() : PacketStream()
{
+0 −46
Original line number Diff line number Diff line
@@ -64,52 +64,6 @@ Packet::~Packet()
    delete[] identifiers;
}

const std::string fixed32[] = { "uint32", "int32", "float" };
const std::string fixed64[] = { "uint64", "int64", "double" };

void cachePhysicalIndexes(pugi::xml_node node, std::map<pugi::xml_node, int>& physicalIndex)
{
	int index = 0;
	for(pugi::xml_node_iterator it=node.begin(); it != node.end(); ++it)
	{
		if(string(it->name()).compare("field") != 0)
			continue;

		physicalIndex[*it] = index;

		// if 32bits fields
		string typeStr = it->attribute("type").value();
		bool found = false;
		for(unsigned int i=0; i<3; i++)
		{
			if(typeStr.compare(fixed32[i]) == 0)
			{
				index+=2;
				found = true;
				break;
			}
		}
		if(found)
			continue;

		// if 64bits fields
		for(unsigned int i=0; i<3; i++)
		{
			if(typeStr.compare(fixed64[i]) == 0)
			{
				index+=4;
				found = true;
				break;
			}
		}
		if(found)
			continue;

		// else (<= 16bits fields)
		index++;
	}
}

void Packet::createPacketType(pugi::xml_document& doc, pugi::xml_node hNode, int plPhysicalIndex, int plSize, pugi::xml_node pNode, bool isprefix, word dimprefix, std::map<pugi::xml_node, int>& physicalIndex)
{
	name = pNode.attribute("name").value();
+3 −5
Original line number Diff line number Diff line
@@ -25,10 +25,6 @@

using namespace PacketLib;





PacketStream::PacketStream(string fileNameConfig)
{
	filenameConfig = realpath(fileNameConfig.c_str(), NULL);
@@ -158,7 +154,9 @@ void PacketStream::cachePhysicalIndexes(pugi::xml_node node, std::map<pugi::xml_
	{
		if(string(it->name()).compare("field") != 0)
			continue;

#ifdef DEBUG
		std::cout << "Physical index of " << it->attribute("name").value() << " is " << index << std::endl;
#endif
		physicalIndex[*it] = index;

		// if 32bits fields
Loading