Example #1
0
// einen Token einwerfen
void Game::put(int slot)
{
	// wenn Spiel nicht zuende
	if (!end)
	{
		// Spielertoken einwerfen
		Board::Result result = board->put(slot, getFieldType(false));

		// wenn Einwurf erfolgreich
		if (result != Board::Error)
			// AI Token einwerfen
			end = (result == Board::Win) || (board->put(ai->getSlot(), getFieldType(true)) == Board::Win);
	}
}
Example #2
0
	const T& getUniform( const std::string& name ) const
	{
		vgAssertN( getFieldType(name) == typeid(vgd::field::TSingleField<T>), "Try to get the uniform named '%s' with the wrong type '%s' instead of '%s'.", name.c_str(), typeid(vgd::field::TSingleField<T>).name(), getFieldType(name).name() );
		vgd::field::EditorRO< vgd::field::TSingleField<T> > uniform = getFieldRO< vgd::field::TSingleField<T> >( name );
		const T& value = uniform->getValue();
		return value;
	}
Example #3
0
QVariant LS3Datastore::getFieldDefault(QString field) const {
    switch(getFieldType(field)) {
        case FTInt: return QVariant(0);
        case FTFloat: return QVariant(0.0);
        default: return QVariant(QString(""));
    }
}
void VRMLFile::beginFieldDecl(const Char8  *szFieldType,
                              const UInt32  uiFieldTypeId,
                              const Char8  *szFieldName)
{
    Inherited::beginFieldDecl(szFieldType, uiFieldTypeId, szFieldName);

    getFieldType(szFieldName);

    beginField(szFieldName, uiFieldTypeId);
}
Example #5
0
/*!
 * Update field information using VTKFieldMetaData class
 */
void VTKField::importMetaData( const VTKFieldMetaData &data){ 

    if( data.getSize() != -1 ){
        setDataType( VTKTypes::whichType(data.getType()) );

        if( getFieldType() == VTKFieldType::SCALAR ){
            setElements( data.getSize() ) ;

        } else if (getFieldType() == VTKFieldType::VECTOR) {
            setElements( data.getSize() /3 ) ;

        } else if (getFieldType() == VTKFieldType::CONSTANT) {
            setElements( data.getSize() / components  );

        } else if (getFieldType() == VTKFieldType::VARIABLE) {
            setElements( data.getSize() );
        }

    };

    return ;
};
static QString getFieldType(QString xmlType, unsigned bits, QString otherType, const QMap<QString, QString>& extraTypes)
{
    Q_UNUSED(bits);
    Q_UNUSED(otherType);
    if (xmlType == "unsigned") return "unsigned";
    else if (xmlType == "signed") return "int";
    else if (xmlType == "float" || xmlType == "fixed") return "double";
    else if (xmlType == "bool") return "bool";
    else if (xmlType == "bytestring" || xmlType == "unicodestring" || xmlType == "unicodechars") return "QString";
    else if (xmlType == "blob") return "QByteArray";
    else if (xmlType == "uuid") return "QUuid";
    else if (extraTypes.contains(xmlType)) return getFieldType(extraTypes[xmlType], bits, otherType, extraTypes);
    return "ERROR";
}
Example #7
0
// startet das Spiel
void Game::run()
{
	// Spielkomponenten initialisieren
	init();

	// wenn AI startet
	if (AI_STARTS)
		// Spalte berechnen und Token einwerfen
		board->put(ai->getSlot(), getFieldType(true));

	// solange Spiel nicht zuende
	while (!quit)
	{
		// Spielkomponenten aktualisieren und zeichnen
		update();
		draw();

		window.flip(1);
		CL_KeepAlive::process();
	}
}
Example #8
0
int main(int argc, char** argv)
{
	string* addr = new string("127.0.0.1");
	uint16_t port = 7766;

	//Determines whether the program is executed in the sender or receiver role
	m_nPID = atoi(argv[1]);
	//the number of OTs that are performed. Has to be initialized to a certain minimum size due to
	uint64_t numOTs = 1000000;
	//bitlength of the values that are transferred - NOTE that when bitlength is not 1 or a multiple of 8, the endianness has to be observed
	uint32_t bitlength = 8;

	uint32_t runs = 1;

	//Use elliptic curve cryptography in the base-OTs
	m_eFType = ECC_FIELD;
	//The symmetric security parameter (80, 112, 128)
	uint32_t m_nSecParam = 128;

	//Number of threads that will be used in OT extension
	m_nNumOTThreads = 1;

	//Specifies which OT flavor should be used
	snd_ot_flavor stype = Snd_OT;
	rec_ot_flavor rtype = Rec_OT;


	m_nBaseOTs = 190;
	m_nChecks = 380;

	m_bUseMinEntCorAssumption = false;

	m_eProt = IKNP;

	read_test_options(&argc, &argv, &m_nPID, &numOTs, &bitlength, &m_nSecParam, addr, &port, &m_eProt, &stype, &rtype,
			&m_nNumOTThreads, &m_nBaseOTs, &m_nChecks, &m_bUseMinEntCorAssumption, &runs);

	/*int32_t read_test_options(int32_t* argcp, char*** argvp, uint32_t* role, uint64_t* numots, uint32_t* bitlen,
			uint32_t* secparam, string* address, uint16_t* port, ot_ext_prot* protocol, snd_ot_flavor* sndflav,
			rec_ot_flavor* rcvflav, uint32_t* nthreads, uint32_t* nbaseots, uint32_t* nchecks, bool* usemecr, uint32_t* runs) {*/

	crypto *crypt = new crypto(m_nSecParam, (uint8_t*) m_cConstSeed[m_nPID]);


	if(m_nPID == SERVER_ID) //Play as OT sender
	{
		InitOTSender(addr->c_str(), port, crypt);

		CBitVector delta, X1, X2;

		//The masking function with which the values that are sent in the last communication step are processed
		m_fMaskFct = new XORMasking(bitlength, delta);

		//creates delta as an array with "numOTs" entries of "bitlength" bit-values and fills delta with random values
		delta.Create(numOTs, bitlength, crypt);

		//Create X1 and X2 as two arrays with "numOTs" entries of "bitlength" bit-values and resets them to 0
		X1.Create(numOTs, bitlength, crypt);
		X2.Create(numOTs, bitlength, crypt);

#ifndef BATCH
		cout << getProt(m_eProt) << " Sender performing " << numOTs << " " << getSndFlavor(stype) << " / " <<
				getRecFlavor(rtype) << " extensions on " << bitlength << " bit elements with " <<	m_nNumOTThreads << " threads, " <<
				getFieldType(m_eFType) << " and" << (m_bUseMinEntCorAssumption ? "": " no" ) << " min-ent-corr-robustness " <<
				runs << " times" << endl;
#endif
		for(uint32_t i = 0; i < runs; i++) {
			ObliviouslySend(X1, X2, numOTs, bitlength, stype, rtype, crypt);
		}
	}
	else //Play as OT receiver
	{
		InitOTReceiver(addr->c_str(), port, crypt);

		CBitVector choices, response;

		//The masking function with which the values that are sent in the last communication step are processed
		m_fMaskFct = new XORMasking(bitlength);

		//Create the bitvector choices as a bitvector with numOTs entries
		choices.Create(numOTs, crypt);

		//Pre-generate the respose vector for the results
		response.Create(numOTs, bitlength);
		response.Reset();

		/* 
		 * The inputs of the receiver in G_OT, C_OT and R_OT are the same. The only difference is the version
		 * variable that has to match the version of the sender. 
		*/
#ifndef BATCH
		cout << getProt(m_eProt) << " Receiver performing " << numOTs << " " << getSndFlavor(stype) << " / " <<
				getRecFlavor(rtype) << " extensions on " << bitlength << " bit elements with " <<	m_nNumOTThreads << " threads, " <<
				getFieldType(m_eFType) << " and" << (m_bUseMinEntCorAssumption ? "": " no" ) << " min-ent-corr-robustness " <<
				runs << " times" << endl;
#endif
		for(uint32_t i = 0; i < runs; i++) {
			ObliviouslyReceive(choices, response, numOTs, bitlength, stype, rtype, crypt);
		}
	}

	//Cleanup();
	delete crypt;

	return 1;
}
Example #9
0
SkFieldType SkAnimator::getFieldType(const char* id, const char* fieldID) {
    const SkMemberInfo* field = getField(id, fieldID);
    return getFieldType(field);
}
Example #10
0
void CVRMLFieldData::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();

	CX3DParser::printIndent(indent);
	fprintf(fp, "[%s]", CVRMLFieldData::getFieldTypeName(getFieldType()));

	switch (getFieldType())
	{
	case BOOLEAN_DATA:
		{
			CVRMLBooleanData *boolData = (CVRMLBooleanData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%s\n", boolData->getValue() ? "TRUE" : "FALSE");
		}
		break;

	case INT_DATA:
		{
			CVRMLIntData *intData = (CVRMLIntData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%d\n", intData->getValue());
		}
		break;

	case FLOAT_DATA:
		{
			CVRMLFloatData *floatData = (CVRMLFloatData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%f\n", floatData->getValue());
		}
		break;

	case DOUBLE_DATA:
		{
			CVRMLDoubleData *doubleData = (CVRMLDoubleData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%f\n", doubleData->getValue());
		}
		break;

	case STRING_DATA:
		{
			CVRMLStringData *stringData = (CVRMLStringData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%s\n", stringData->getValue());
		}
		break;

	case NODE_DATA:
		{
			CVRMLNodeData *nodeData = (CVRMLNodeData *)this;

			fprintf(fp, "\n");

			jobject vrmlNode = ((CVRMLNodeData *)nodeData)->getValue();
			CX3DNode *node = CX3DNodeFactory::createNode(vrmlNode);
			if (node)
			{
				node->print(indent+1);
				delete node;
			}
			else
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "NULL\n");
			}
		}
		break;

	case BOOLEAN_ARRAY_DATA:
		{
			CVRMLBooleanArrayData *boolArrayData = (CVRMLBooleanArrayData *)this;

			int n = boolArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %s\n", i, boolArrayData->getValue(i) ? "TRUE" : "FALSE");
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case INT_ARRAY_DATA:
		{
			CVRMLIntArrayData *intArrayData = (CVRMLIntArrayData *)this;

			int n = intArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %d\n", i, intArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case FLOAT_ARRAY_DATA:
		{
			CVRMLFloatArrayData *floatArrayData = (CVRMLFloatArrayData *)this;

			int n = floatArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %f\n", i, floatArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case DOUBLE_ARRAY_DATA:
		{
			CVRMLDoubleArrayData *doubleArrayData = (CVRMLDoubleArrayData *)this;

			int n = doubleArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %f\n", i, doubleArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case STRING_ARRAY_DATA:
		{
			CVRMLStringArrayData *stringArrayData = (CVRMLStringArrayData *)this;

			int n = stringArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %s\n", i, stringArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case NODE_ARRAY_DATA:
		{
			CVRMLNodeArrayData *nodeArrayData = (CVRMLNodeArrayData *)this;

			int n = nodeArrayData->count();
			fprintf(fp, " (n=%d)\n", n);
			
			for (int i=0; i<nodeArrayData->count(); i++)
			{
				jobject vrmlNode = nodeArrayData->getValue(i);
				CX3DNode *node = CX3DNodeFactory::createNode(vrmlNode);
				if (node)
				{
					node->print(indent+1);
					delete node;
				}
				else
				{
					CX3DParser::printIndent(indent+1);
					fprintf(fp, "NULL\n");
				}
			}
		}
		break;
	}
}
Example #11
0
GFF4Struct::FieldType GFF4Struct::getFieldType(uint32 field) const {
	bool isList;
	return getFieldType(field, isList);
}
Example #12
0
/* EventIn methods */
STDMETHODIMP GvField::getType(int *type)
{
	*type = getFieldType();
	return S_OK;
}
Example #13
0
int main(int argc, char **argv) {
    const char *addr = "127.0.0.1";
    int port = 7766;

    if (argc != 2) {
        cout
            << "Please call with 0 if acting as server or 1 if acting as client"
            << endl;
        return 0;
    }

    // Determines whether the program is executed in the sender or receiver role
    m_nPID = atoi(argv[1]);
    cout << "Playing as role: " << m_nPID << endl;
    assert(m_nPID >= 0 && m_nPID <= 1);

    // The symmetric security parameter (80, 112, 128)
    uint32_t m_nSecParam = 128;

    crypto *crypt = new crypto(m_nSecParam, (uint8_t *)m_cConstSeed[m_nPID]);

    uint32_t m_nBaseOTs = 190;
    uint32_t m_nChecks = 380;

    ot_ext_prot lastprot = PROT_LAST;
    field_type lastfield = FIELD_LAST;

    if (m_nPID == SERVER_ID) // Play as OT sender
    {
        InitSender(addr, port);

        OTExtSnd *sender = NULL;
        for (uint32_t i = 0; i < m_nTests; i++) {
            if (lastprot != tests[i].prot || lastfield != tests[i].ftype) {
                // if(sender) delete sender;
                sender = InitOTExtSnd(tests[i].prot, m_nBaseOTs, m_nChecks,
                                      tests[i].usemecr, tests[i].ftype, crypt);
                lastprot = tests[i].prot;
                lastfield = tests[i].ftype;
            }

            cout << "Test " << i << ": " << getProt(tests[i].prot) << " Sender "
                 << tests[i].numots << " " << getSndFlavor(tests[i].sflavor)
                 << " / " << getRecFlavor(tests[i].rflavor) << " on "
                 << tests[i].bitlen << " bits with " << tests[i].nthreads
                 << " threads, " << getFieldType(tests[i].ftype) << " and"
                 << (tests[i].usemecr ? "" : " no") << " MECR" << endl;

            run_test_sender(tests[i].numots, tests[i].bitlen, tests[i].sflavor,
                            tests[i].rflavor, tests[i].nthreads, crypt, sender);
        }
        delete sender;
    } else // Play as OT receiver
    {
        InitReceiver(addr, port);

        OTExtRec *receiver = NULL;
        for (uint32_t i = 0; i < m_nTests; i++) {
            if (lastprot != tests[i].prot || lastfield != tests[i].ftype) {
                // if(receiver) delete receiver;
                receiver =
                    InitOTExtRec(tests[i].prot, m_nBaseOTs, m_nChecks,
                                 tests[i].usemecr, tests[i].ftype, crypt);
                lastprot = tests[i].prot;
                lastfield = tests[i].ftype;
            }

            cout << "Test " << i << ": " << getProt(tests[i].prot)
                 << " Receiver " << tests[i].numots << " "
                 << getSndFlavor(tests[i].sflavor) << " / "
                 << getRecFlavor(tests[i].rflavor) << " on " << tests[i].bitlen
                 << " bits with " << tests[i].nthreads << " threads, "
                 << getFieldType(tests[i].ftype) << " and"
                 << (tests[i].usemecr ? "" : " no") << " MECR" << endl;

            run_test_receiver(tests[i].numots, tests[i].bitlen,
                              tests[i].sflavor, tests[i].rflavor,
                              tests[i].nthreads, crypt, receiver);
        }
        delete receiver;
    }

    Cleanup();
    delete crypt;

    return 1;
}
Example #14
0
void odkFormReader::extractFields(QDomNode child, QString tableName, TtableDef &parentTable, QString groupCode, QString xmlCode)
{
    QDomElement item;
    QDomNode node;
    QDomNode childNode;

    QString fieldCode;
    QString fieldName;
    QString fieldOutput;
    QString fieldType;
    QStringList ftypes;
    QStringList ftsizes;

    QString sameTable;
    QString grpCode;

    QString childName;
    QString mselptable;
    QString repeatXMLCode;
    QString fieldXMLCode;


    TtableDef table;
    TtableDef tempTable;
    int pos;

    tableIndex++;
    int tindex;
    tindex = tableIndex;

    bool fieldinmselt;

    TfieldDef fsurveyID;
    TfieldDef foriginID;



    if ((tableName.toLower() != parentTable.name.toLower()) || (parentTable.fields.count() == 0)) //We are not processing a group
    {
        //qDebug() << "Table: " + tableName.toLower() + " Parent: " + parentTable.name.toLower() + ". Fields: " + QString::number(parentTable.fields.count());

        if (tableName.toLower() == mTable.toLower())
        {
            table.name = tableName;
            table.desc = "Main survey Table - Change this description";
            table.xmlCode = xmlCode;
            table.parentTable = "NULL";

            /*fsurveyID.name = "surveyid";
            fsurveyID.desc = "Survey ID (UUID)";
            fsurveyID.type = "varchar";
            fsurveyID.size = 80;
            fsurveyID.decSize = 0;
            fsurveyID.section = "main";
            fsurveyID.rField = "";
            fsurveyID.rTable = "";
            fsurveyID.key = false;
            fsurveyID.xmlCode = "NONE";
            table.fields.append(fsurveyID);

            foriginID.name = "originid";
            foriginID.desc = "Origin ID: formhub or aggregate";
            foriginID.type = "varchar";
            foriginID.size = 15;
            foriginID.decSize = 0;
            foriginID.section = "main";
            foriginID.rField = "";
            foriginID.rTable = "";
            foriginID.key = false;
            foriginID.xmlCode = "NONE";
            table.fields.append(foriginID);*/

        }
        else
        {
            table.name = tableName;
            table.xmlCode = xmlCode;
            table.parentTable = parentTable.name;
            table.desc = "Repeat " + tableName + " - Change this description";
            /*
            //Add the key fields of the parent
            for (pos = 0; pos <= parentTable.fields.count()-1;pos++)
            {
                if (parentTable.fields[pos].key == true)
                {
                    TfieldDef parentKeyField;
                    parentKeyField.name = parentTable.fields[pos].name;
                    parentKeyField.desc = parentTable.fields[pos].desc;
                    parentKeyField.key = true;
                    parentKeyField.type = parentTable.fields[pos].type;
                    parentKeyField.size = parentTable.fields[pos].size;
                    parentKeyField.decSize = parentTable.fields[pos].decSize;
                    parentKeyField.rTable = parentTable.name;
                    parentKeyField.rField = parentTable.fields[pos].name;
                    parentKeyField.xmlCode = "NONE";
                    table.fields.append(parentKeyField);
                }
            }*/

            /*TfieldDef KeyField;
            KeyField.name = tableName + "_rowid";
            KeyField.section = "main";
            KeyField.desc = "Unique row ID";
            KeyField.key = true;
            KeyField.type = "int";
            KeyField.size = 3;
            KeyField.decSize = 0;
            KeyField.rTable = "";
            KeyField.rField = "";
            KeyField.xmlCode = "NONE";
            table.fields.append(KeyField);*/

        }
    }



    node = child;
    while (!node.isNull())
    {
        item = node.toElement();
        if ((item.tagName() == "input") || (item.tagName() == "select1") || (item.tagName() == "select"))
        {
            childNode = item.firstChild();
            fieldCode = item.attribute("ref","CodeNotFound!");
            fieldName = getItemLabel(childNode);
            fieldOutput = getItemOutput(childNode);
            if (fieldOutput != "NONE")
            {
                if (getFieldType(fieldOutput) != "Unknown")
                    fieldCode = fieldOutput;
            }

            fieldName = fieldName.replace("\r","");
            fieldName = fieldName.replace("\n","");
            fieldName = fieldName.replace("\t","");
            fieldName = fieldName.replace("'","");
            fieldName = fieldName.replace(";","");

            fieldType = getFieldType(fieldCode);

            fieldXMLCode = fieldCode.replace("/" + surveyID + "/","");

            pos = fieldCode.lastIndexOf("/");
            fieldCode = fieldCode.right(fieldCode.length()-pos-1);

            fieldCode = fieldCode.replace("-","_");
            fieldCode = fieldCode.replace("'","");
            fieldCode = fieldCode.replace(";","");

            //qDebug() << fieldCode;
            //qDebug() << MainField.toLower();


            if (fieldType != "READONLY")
            {
                TfieldDef field;

                field.name = fieldCode;
                field.xmlCode = fieldXMLCode;
                field.section = groupCode;
                field.desc = fieldName;
                //if (fieldCode.toLower() == MainField.toLower())
                //    field.key = true;
                //else
                    field.key = false;

                ftypes = fieldType.split("|",QString::SkipEmptyParts);
                if (ftypes.count() > 1)
                {
                    field.type = ftypes[0];
                    ftsizes =  ftypes[1].split(",",QString::SkipEmptyParts);
                    if (ftsizes.count() > 1)
                    {
                        field.size = ftsizes[0].toInt();
                        field.decSize = ftsizes[1].toInt();
                    }
                    else
                    {
                        field.size = ftsizes[0].toInt();
                        field.decSize = 0;
                    }
                }
                else
                    field.type = fieldType;

                field.rTable = "";
                field.rField = "";
                fieldinmselt = false;

                if (item.tagName() == "select1")
                {
                    if ((isLookUpYesNo(getSelectValues(item)) == false) || ((isLookUpYesNo(getSelectValues(item)) == true) && (ignoreYesNo == false)))
                    {

                        TtableDef lktable;


                        lktable.lkpValues.append(getSelectValues(item));



                        if (areValuesStrings(lktable.lkpValues))
                        {
                            //qDebug() << lktable.name;
                            field.type = "varchar";
                            field.size = getMaxValueLength(lktable.lkpValues);
                            field.decSize = 0;
                        }

                        lktable.name = "lkp" + fieldCode;
                        lktable.desc = "Lookup table [" + fieldName + "]";
                        lktable.pos = -1;
                        lktable.islookup = true;

                        TfieldDef lkpCode;
                        lkpCode.name = fieldCode + "_cod";
                        lkpCode.desc = "Code";
                        lkpCode.key = true;
                        lkpCode.type = field.type;
                        lkpCode.size = field.size;
                        lkpCode.decSize = field.decSize;
                        lktable.fields.append(lkpCode);

                        TfieldDef lkpDesc;
                        lkpDesc.name = fieldCode + "_des";
                        lkpDesc.desc = "Description";
                        lkpDesc.key = false;
                        lkpDesc.type = "varchar";
                        lkpDesc.size = 255;
                        lkpDesc.decSize = 0;
                        lktable.fields.append(lkpDesc);



                        sameTable = isLkpDuplicated(lktable);

                        if (sameTable.isEmpty())
                        {
                            tables.append(lktable);
                            field.rTable = lktable.name;
                            field.rField = fieldCode + "_cod";
                        }
                        else
                        {
                            field.rTable = sameTable;
                            field.rField = getKeyField(sameTable);
                            //qDebug() << lktable.name + " = " + sameTable + ". " + sameTable + " used instead";
                        }
                    }
                }
                if (item.tagName() == "select")
                {

                    //We change the field type to be varchar(255) and add it to the main table so stores values separated by space. The by a separate process we split the values in the child tables.
                    field.type = "varchar";
                    field.size = 255;
                    field.decSize = 0;

                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                        table.fields.append(field);
                    else
                        parentTable.fields.append(field); //If we are processing a group then the field goes to the parent

                    //Then we change it back to a select type
                    field.type = "int";
                    field.size = 9;


                    //*********************Creates a new table to store the multiselect in different rows**************************

                    TtableDef mselTable;
                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                    {
                        mselptable = table.name;
                        tempTable = table;
                    }
                    else
                    {
                        mselptable = parentTable.name;
                        tempTable = parentTable;
                    }

                    mselTable.name =  mselptable + "_msel_" + fieldCode;
                    mselTable.desc = "Table for multiple select of field " + fieldCode;
                    mselTable.islookup = false;
                    tableIndex++;
                    mselTable.pos = tableIndex;
                    mselTable.xmlCode = "NONE";

                    //Move the keys to the multi select table
                    for (pos = 0; pos <= tempTable.fields.count()-1;pos++)
                    {
                        if (tempTable.fields[pos].key == true)
                        {
                            TfieldDef mselKeyField;
                            mselKeyField.name = tempTable.fields[pos].name;
                            mselKeyField.desc = tempTable.fields[pos].desc;
                            mselKeyField.key = true;
                            mselKeyField.type = tempTable.fields[pos].type;
                            mselKeyField.size = tempTable.fields[pos].size;
                            mselKeyField.decSize = tempTable.fields[pos].decSize;
                            mselKeyField.rTable = tempTable.name;
                            mselKeyField.rField = tempTable.fields[pos].name;
                            mselTable.fields.append(mselKeyField);
                        }
                    }

                    //************************* Creates the lookup table *********************************

                    if ((isLookUpYesNo(getSelectValues(item)) == false) || ((isLookUpYesNo(getSelectValues(item)) == true) && (ignoreYesNo == false)))
                    {

                        TtableDef lktable;


                        lktable.lkpValues.append(getSelectValues(item));



                        if (areValuesStrings(lktable.lkpValues))
                        {
                            //qDebug() << lktable.name;
                            field.type = "varchar";
                            field.size = getMaxValueLength(lktable.lkpValues);
                            field.decSize = 0;
                        }

                        lktable.name = "lkp" + fieldCode;
                        lktable.desc = "Lookup table [" + fieldName + "]";
                        lktable.pos = -1;
                        lktable.islookup = true;

                        TfieldDef lkpCode;
                        lkpCode.name = fieldCode + "_cod";
                        lkpCode.desc = "Code";
                        lkpCode.key = true;
                        lkpCode.type = field.type;
                        lkpCode.size = field.size;
                        lkpCode.decSize = field.decSize;
                        lktable.fields.append(lkpCode);

                        TfieldDef lkpDesc;
                        lkpDesc.name = fieldCode + "_des";
                        lkpDesc.desc = "Description";
                        lkpDesc.key = false;
                        lkpDesc.type = "varchar";
                        lkpDesc.size = 255;
                        lkpDesc.decSize = 0;
                        lktable.fields.append(lkpDesc);



                        sameTable = isLkpDuplicated(lktable);

                        if (sameTable.isEmpty())
                        {
                            tables.append(lktable);
                            field.rTable = lktable.name;
                            field.rField = fieldCode + "_cod";
                        }
                        else
                        {
                            field.rTable = sameTable;
                            field.rField = getKeyField(sameTable);
                            //qDebug() << lktable.name + " = " + sameTable + ". " + sameTable + " used instead";
                        }
                    }

                    fieldinmselt = true;
                    field.key = true;
                    mselTable.fields.append(field);
                    tables.append(mselTable);

                }
                if (fieldinmselt == false)
                {
                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                        table.fields.append(field);
                    else
                        parentTable.fields.append(field); //If we are processing a group then the field goes to the parent
                }

            }
        }
        else
        {
            if (item.tagName() == "group")
            {
                grpCode = item.attribute("ref","/GRPNotKnown");
                pos = grpCode.lastIndexOf("/");
                grpCode = grpCode.right(grpCode.length()-pos-1);
                grpCode = grpCode;
                //qDebug() << "Group:" + item.attribute("ref","/GRPNotKnown");
                //qDebug() << "Group table:" + table.name;

                if (!table.name.isEmpty())
                    extractFields(item.firstChild(),table.name,table,grpCode,xmlCode); //Recursive call for group
                else
                    extractFields(item.firstChild(),parentTable.name,parentTable,grpCode,xmlCode); //Recursive call for group
            }
            if (item.tagName() == "repeat")
            {
                childName = item.attribute("nodeset","unknowrepeat");

                repeatXMLCode = childName.replace("/" + surveyID + "/","");

                pos = childName.lastIndexOf("/");
                childName = childName.right(childName.length()-pos-1);
                if (!table.name.isEmpty())
                    extractFields(item.firstChild(),childName,table,"main",repeatXMLCode); //Recursive call for repeat
                else
                    extractFields(item.firstChild(),childName,parentTable,"main",repeatXMLCode); //Recursive call for repeat
            }
        }


        node = node.nextSibling();
    }

    if (tableName.toLower() != parentTable.name.toLower())
    {
        table.pos = tindex;
        table.islookup = false;
        tables.append(table);
    }

}
static QMap<QString, Field> getFields(QDomElement record, bool* foundStrings = 0)
{
    QDomNodeList types = record.elementsByTagName("type");
    QMap<QString, QString> extraTypes;
    QMap<QString, QString> extraTypesDefaults;
    for (int i = 0; i < types.size(); i++) {
        QDomElement e = types.at(i).toElement();
        extraTypes[e.attribute("name")] = e.attribute("type");
        if (e.elementsByTagName("enum").size() > 0)
            extraTypesDefaults[e.attribute("name")] = e.elementsByTagName("enum").at(0).toElement().attribute("name");
    }

    QDomNodeList fields = record.elementsByTagName("field");
    QMap<QString, Field> map;
    for (int i = 0; i < fields.size(); i++) {
        QDomElement e = fields.at(i).toElement();
        QString name = e.attribute("name");
        if (!name.startsWith("reserved")) {
            map[name] = Field(name, getFieldType(e.attribute("type"), e.attribute("size").toUInt(), map[name].type, extraTypes));
            if (foundStrings && map[name].type == "QString") *foundStrings = true;
            if (hasParentNode(e, "array")) {
                map[name].isArray = true;
            }
            if (e.elementsByTagName("enum").size() > 0) {
                map[name].isEnum = true;
                map[name].type = ucFirst(name);
                map[name].defaultValue = e.elementsByTagName("enum").at(0).toElement().attribute("name");
            }
            if (extraTypes.contains(e.attribute("type"))) {
                map[name].isEnum = true;
                map[name].type = e.attribute("type");
                map[name].defaultValue = extraTypesDefaults[e.attribute("type")];
            }
            if (e.hasAttribute("default"))
                map[name].defaultValue = e.attribute("default");
        }
    }
    for (int i = 0; i < fields.size(); i++) {
        QDomElement e = fields.at(i).toElement();
        if (e.hasAttribute("length")) {
            QString name = e.attribute("length");
            if (map.contains(name)) {
                map[name].isStringLength = true;
                map[name].lengthFor = e.attribute("name");
            }
        }
    }
    QDomNodeList arrays = record.elementsByTagName("array");
    for (int i = 0; i < arrays.size(); i++) {
        QDomElement e = arrays.at(i).toElement();
        QString name = e.attribute("length");
        if (map.contains(name)) {
            Field& field = map[name];
            field.isArrayLength = true;
            QDomNodeList afields = e.elementsByTagName("field");
            for (int j = 0; j < afields.size(); j++) {
                QDomElement af = afields.at(j).toElement();
                QString fname = af.attribute("name");
                if (!fname.startsWith("reserved"))
                    field.arrayFields.append(map[fname]);
            }
        }
    }
    return map;
}