bool UtlXMLStream::readKeyOfHashTable(std::string& sKey) {
		
		int iChar;
		skipBlanks( getInputStream() );

		iChar=readChar(  getInputStream() );
		if (iChar != '<')  {
			return false;
		}

		std::string sTrash;
		if (!readString( getInputStream() , sTrash))
			return false;
		if (strcmp(sTrash.c_str(),"pair"))
			return false;

		std::string sKeyTag;
		if (!readAttribute( sKeyTag , sKey))
			return false;

		if (strcmp(sKeyTag.c_str(),"key"))
			return false;
		
		return true;
	}
Exemple #2
0
HRESULT STDMETHODCALLTYPE ClassesContentHandler::startElement(const wchar_t *pwchNamespaceUri, int cchNamespaceUri,
		const wchar_t *pwchLocalName, int cchLocalName, const wchar_t *pwchQName, int cchQName, ISAXAttributes *pAttributes) {
	std::wstring tag(pwchQName, cchQName);

	/*int cols = -1, rows = -1, type = -1;
	std::wstring buf;
	if (readAttribute(pAttributes, L"cols", buf)) {
		swscanf(buf.c_str(), L"%d", &cols);
	}
	if (readAttribute(pAttributes, L"rows", buf)) {
		swscanf(buf.c_str(), L"%d", &rows);
	}
	if (readAttribute(pAttributes, L"type", buf)) {
		swscanf(buf.c_str(), L"%x", &type);
	}*/

	switch (myState) {
		case READ_NOTHING:
			if (tag.compare(L"classes") == 0) {
				myState = READ_CLASSES;
			} else {
				return E_FAIL;
			}
			break;
		case READ_CLASSES:
			if (tag.compare(L"class") == 0) {
				myState = READ_CLASS;
				std::string name, letter;
				if (!readAttribute(pAttributes, L"name", name)
						|| !readAttribute(pAttributes, L"letter", letter)
						|| letter.length() != 1) {
					return E_FAIL;
				}
				myClasses.push_back(EmoClass(name, letter.at(0)));
			} else {
				return E_FAIL;
			}
			break;
		case READ_CLASS:
			return E_FAIL;
	}
	return S_OK;
}
Exemple #3
0
void DDI::DDIEntity::readNode(rapidxml::xml_node<> *_node) {
    for (rapidxml::xml_attribute<> *attr = _node->first_attribute();
         attr; attr = attr->next_attribute())
    {
        if (!readAttribute(attr->name(), attr->value()))
        {
            out << "[" << getXMLLabel() << "] Unrecognised attribute: " << attr->name() << " (" << attr->value() << ")" << std::endl;
        }
    }
    _contents_ = _node->value();
}
Exemple #4
0
static void
readAttributes(template_t *t, tfile_t *tf)
{
	int nAttrs, i;

	readScalar(nAttrs, tf);
	for (i = 0; i < nAttrs; i++) {
		tmpl_attribute_t *att = _evlTmplAllocAttribute();
		att->ta_index = i;
		readAttribute(att, t, tf);
		t->tm_attributes = _evlAppendToList(t->tm_attributes, att);
	}
}
/** Loads byte attribute by id */
U2ByteArrayAttribute MysqlAttributeDbi::getByteArrayAttribute(const U2DataId& attributeId, U2OpStatus& os) {
    static const QString queryString(buildSelectAttributeQuery("ByteArrayAttribute"));
    U2SqlQuery q(queryString, db, os);
    q.bindDataId(":id", attributeId);

    U2ByteArrayAttribute res;
    readAttribute(q, res);
    CHECK_OP(os, res);
    res.value = q.getBlob(0);
    q.ensureDone();

    return res;
}
Exemple #6
0
bool XmlReader::readPoint(const char* t, QPointF* val)
      {
      if (isTag(name(), t)) {
            while (readAttribute()) {
                  if (tag() == "x")
                        val->setX(realValue());
                  else if (tag() == "y")
                        val->setY(realValue());
                  }
            read();
            return true;
            }
      return false;
      }
Exemple #7
0
bool XmlReader::readSize(const char* t, QSizeF* val)
      {
      if (isTag(name(), t)) {
            while (readAttribute()) {
                  if (tag() == "w")
                        val->setWidth(realValue());
                  else if (tag() == "h")
                        val->setHeight(realValue());
                  }
            read();
            return true;
            }
      return false;
      }
Exemple #8
0
bool XmlReader::readFraction(const char* t, Fraction* val)
      {
      if (isTag(name(), t)) {
            while (readAttribute()) {
                  if (tag() == "z")
                        val->setNumerator(realValue());
                  else if (tag() == "n")
                        val->setDenominator(realValue());
                  }
            read();
            return true;
            }
      return false;
      }
int getDatasetPrecision(int _iDatasetId, int *_piPrec)
{
    int iRet = 0;
    char *pstScilabClass = readAttribute(_iDatasetId, g_SCILAB_CLASS_PREC);

    if (pstScilabClass == NULL)
    {
        return -1;
    }
    else if (strcmp(pstScilabClass, "8") == 0)
    {
        *_piPrec = SCI_INT8;
    }
    else if (strcmp(pstScilabClass, "u8") == 0)
    {
        *_piPrec = SCI_UINT8;
    }
    else if (strcmp(pstScilabClass, "16") == 0)
    {
        *_piPrec = SCI_INT16;
    }
    else if (strcmp(pstScilabClass, "u16") == 0)
    {
        *_piPrec = SCI_UINT16;
    }
    else if (strcmp(pstScilabClass, "32") == 0)
    {
        *_piPrec = SCI_INT32;
    }
    else if (strcmp(pstScilabClass, "u32") == 0)
    {
        *_piPrec = SCI_UINT32;
    }
    else if (strcmp(pstScilabClass, "64") == 0)
    {
        *_piPrec = SCI_INT64;
    }
    else if (strcmp(pstScilabClass, "u64") == 0)
    {
        *_piPrec = SCI_UINT64;
    }
    else
    {
        iRet = 1;
    }

    FREE(pstScilabClass);
    return iRet;
}
	bool UtlXMLStream::readObjectReference(std::string& sTypeName, std::string& sIDAttrName, std::string& sIdentifier) {

		int iChar;
		skipBlanks( getInputStream() );
		iChar=readChar(  getInputStream() );
		if (iChar != '<')  {
			return false;
		}
		
		std::string sTrash;
		// reference
		if (!readString( getInputStream(), sTrash)) 
			return false;
		if (strcmp(sTrash.c_str(),"reference"))
			return false;

		// type 
		if (!readAttribute(sTrash, sTypeName))
			return false;

		// ID
		if (!readAttribute( sIDAttrName, sIdentifier)) 
			return false;
		
		iChar=readChar(  getInputStream() );
		if (iChar != '/')  {
			return false;
		}
		
		iChar=readChar(  getInputStream() );
		if (iChar != '>')  {
			return false;
		}

		return true;	
	}
Exemple #11
0
bool XmlReader::readColor(const char* t, Color* val)
      {
      if (isTag(name(), t)) {
            while (readAttribute()) {
                  if (tag() == "r")
                        val->setRed(intValue());
                  else if (tag() == "g")
                        val->setGreen(intValue());
                  else if (tag() == "b")
                        val->setBlue(intValue());
                  }
            read();
            return true;
            }
      return false;
      }
 //--------------------------------------------------------------------------
 void
 WalkmeshFileXMLSerializer::readObject( TiXmlNode &node
                                       ,WalkmeshFileXMLSerializer::Triangle &pDest )
 {
     readAttribute( node, "a", pDest.a );
     readAttribute( node, "b", pDest.b );
     readAttribute( node, "c", pDest.c );
     readAttribute( node, "a_b", pDest.access_side[0] );
     readAttribute( node, "b_c", pDest.access_side[1] );
     readAttribute( node, "c_a", pDest.access_side[2] );
 }
Exemple #13
0
bool Loader::readItem(Node* parent) {
    char* name;
    uint8_t type;
    int nameLength;

    if ((m_file->read(&type, 1) != 1) ||
        (m_file->read(&nameLength, 4) != 4)) {
        return false;
    }

    name = new char[nameLength + 1];

    if (m_file->read(name, nameLength) != nameLength) {
        return false;
    }

    name[nameLength] = 0;

    switch (type) {
        case TYPE_NODE : {
            Node* child;

            if (!readNode(child)) {
                return false;
            }

            parent->addChild(name, child);

            break;
        }

        case TYPE_ATTRIBUTE : {
            Attribute* attribute;

            if (!readAttribute(attribute)) {
                return false;
            }

            parent->addAttribute(name, attribute);

            break;
        }
    }

    return true;
}
static int checkAttribute(int _iDatasetId, char *_pstAttribute, char *_pstValue)
{
    int iRet = 0;
    char *pstScilabClass = NULL;

    //status = H5Giterate (_iFile, "/", NULL, op_func, &iDatasetId);
    pstScilabClass = readAttribute(_iDatasetId, _pstAttribute);
    if (pstScilabClass != NULL && strcmp(pstScilabClass, _pstValue) == 0)
    {
        iRet = 1;
    }
    if (pstScilabClass)
    {
        FREE(pstScilabClass);
    }
    return iRet;
}
Exemple #15
0
int main(int argc, char*argv[])
{

	int iField;
	string market;
	market = "JPY";

	contractStruct myContract;
	myContract.market = market;

	readAttributes readAttribute("//mnt//nas//shared//progQuantCompFinance//lecture10//exampleReadAttributes//contractAttributes2.csv");
	int nFields = readAttribute.getNFields();
	//int nAttributes = readAttribute.getNAttributes();

	string *marketFields = new string[nFields];
	readAttribute.getMarketAllFields(market, marketFields);

	cout << " Attributes: ";
	for (iField = 0; iField < readAttribute.getNFields(); iField++){
		cout << marketFields[iField] << " ";
	}
	cout << endl;
	cout << " " << endl;

	cout << "calling setAttributes ..." << endl;
	cout << " " << endl;


	setAttributes(myContract, readAttribute);

	cout << "transaction cost: " << myContract.transactionCost << endl;
	cout << "currency value: " << myContract.currencyValue << endl;
	cout << "margin requirement: " << myContract.marginRequirement << endl;
	//cout << "currency name: " << myContract.currencyName << endl;
	cout << "one point value: " << myContract.onePointValue << endl;
	cout << "spread: " << myContract.spread << endl;
	cout << "tick size: " << myContract.ticksize << endl;
	cout << "precision size: " << myContract.precisionSize << endl;

	cout << "Done -- retrieved and set attributes for " << market  << endl;
	delete [] marketFields;

	return 0;

} // END
	bool UtlXMLStream::readHashtableEntry(std::string& sKey, double& dValue) {
		int iChar;
		skipBlanks( getInputStream() );
		if (!readKeyOfHashTable(sKey))
			return false;

		iChar=readChar(  getInputStream() );
		if (iChar != '>')  {
			return false;
		}

		std::string sValueTag;
		if (!readAttribute(  sValueTag , dValue))
			return false;

		if (!readEndOfHashTable())
			return false;

		return true;
	}
Exemple #17
0
bool readAttribute(ISAXAttributes *attributes, const std::wstring &name, std::string &value) {
	std::wstring wide;
	if (!readAttribute(attributes, name, wide)) {
		return false;
	}

	if (wide.length() == 0) {
		value.assign("");
		return true;
	}

	const int len = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), wide.length(), 0, 0, 0, 0);
	if (len == 0) {
		return false;
	}
	char *buffer = new char[len];
	if (WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), wide.length(), buffer, len, 0, 0) != len) {
		return false;
	}
	value.assign(buffer, len);
	delete[] buffer;
	return true;
}
	size_t HTTPFetchHeadParser::readAttributes(size_t startLinePos) {
		size_t pos = startLinePos;
		while((pos = readAttribute(pos)) != std::string::npos);
		return pos;
	}
int readCommonPolyMatrix(int _iDatasetId, char *_pstVarname, int _iComplex, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
{
    int i = 0;
    hid_t obj = 0;
    char *pstVarName = 0;
    hsize_t* piDims = NULL;
    hobj_ref_t *pData = NULL;
    herr_t status;
    int iSize = 1;

    for (i = 0 ; i < _iDims ; i++)
    {
        iSize *= _piDims[i];
    }

    pData = (hobj_ref_t *) MALLOC(iSize * sizeof(hobj_ref_t));

    /*
     * Read the data.
     */
    status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
    if (status < 0)
    {
        FREE(pData);
        return -1;
    }

    for (i = 0; i < iSize; i++)
    {
        /*
         * Open the referenced object, get its name and type.
         */
        obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pData[i]);
        if (_iComplex)
        {
            status = readComplexPoly(obj, &_piNbCoef[i], &_pdblReal[i], &_pdblImg[i]);
        }
        else
        {
            status = readPoly(obj, &_piNbCoef[i], &_pdblReal[i]);
        }

        if (status < 0)
        {
            FREE(pData);
            return -1;
        }
    }

    pstVarName = readAttribute(_iDatasetId, g_SCILAB_CLASS_VARNAME);
    strcpy(_pstVarname, pstVarName);
    FREE(pstVarName);
    status = H5Dclose(_iDatasetId);
    if (status < 0)
    {
        FREE(pData);
        return -1;
    }

    FREE(pData);

    return 0;
}
void ATOMCommonAttributes::readAttributes(const std::map<std::string, std::string> &attributes) {
	readAttribute(XML_BASE, attributes);
	readAttribute(XML_LANG, attributes);
}
Exemple #21
0
void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
{
  QString elementName( QString::fromUtf8( el ) );
  ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );
  QStringList splitName =  elementName.split( NS_SEPARATOR );
  QString localName = splitName.last();
  QString ns = splitName.size() > 1 ? splitName.first() : "";

  if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "coordinates" )
  {
    mParseModeStack.push( QgsGml::coordinate );
    mCoorMode = QgsGml::coordinate;
    mStringCash.clear();
    mCoordinateSeparator = readAttribute( "cs", attr );
    if ( mCoordinateSeparator.isEmpty() )
    {
      mCoordinateSeparator = ",";
    }
    mTupleSeparator = readAttribute( "ts", attr );
    if ( mTupleSeparator.isEmpty() )
    {
      mTupleSeparator = " ";
    }
  }
  if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "pos"
       || elementName == GML_NAMESPACE + NS_SEPARATOR + "posList" )
  {
    mParseModeStack.push( QgsGml::posList );
    mCoorMode = QgsGml::posList;
    mStringCash.clear();
    QString dimension = readAttribute( "srsDimension", attr );
    bool ok;
    mDimension = dimension.toInt( &ok );
    if ( dimension.isEmpty() || !ok )
    {
      mDimension = 2;
    }
  }
  else if ( localName == mGeometryAttribute )
  {
    mParseModeStack.push( QgsGml::geometry );
  }
  //else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
  {
    mParseModeStack.push( QgsGml::boundingBox );
  }
  else if ( theParseMode == none && localName == mTypeName )
  {
    Q_ASSERT( !mCurrentFeature );
    mCurrentFeature = new QgsFeature( mFeatureCount );
    QgsAttributes attributes( mThematicAttributes.size() ); //add empty attributes
    mCurrentFeature->setAttributes( attributes );
    mParseModeStack.push( QgsGml::feature );
    mCurrentFeatureId = readAttribute( "fid", attr );
  }

  else if ( theParseMode == boundingBox && elementName == GML_NAMESPACE + NS_SEPARATOR + "Box" )
  {
    //read attribute srsName="EPSG:26910"
    int epsgNr;
    if ( readEpsgFromAttribute( epsgNr, attr ) != 0 )
    {
      QgsDebugMsg( "error, could not get epsg id" );
    }
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
  {
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
  {
    mParseModeStack.push( QgsGml::multiPoint );
    //we need one nested list for intermediate WKB
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
  {
    mParseModeStack.push( QgsGml::multiLine );
    //we need one nested list for intermediate WKB
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
  {
    mParseModeStack.push( QgsGml::multiPolygon );
  }
  else if ( theParseMode == feature && mThematicAttributes.contains( localName ) )
  {
    mParseModeStack.push( QgsGml::attribute );
    mAttributeName = localName;
    mStringCash.clear();
  }
  // QGIS server (2.2) is using:
  // <Attribute value="My description" name="desc"/>
  else if ( theParseMode == feature
            && localName.compare( "attribute", Qt::CaseInsensitive ) == 0 )
  {
    QString name = readAttribute( "name", attr );
    if ( mThematicAttributes.contains( name ) )
    {
      QString value = readAttribute( "value", attr );
      setAttribute( name, value );
    }
  }

  if ( mEpsg == 0 && ( localName == "Point" || localName == "MultiPoint" ||
                       localName == "LineString" || localName == "MultiLineString" ||
                       localName == "Polygon" || localName == "MultiPolygon" ) )
  {
    if ( readEpsgFromAttribute( mEpsg, attr ) != 0 )
    {
      QgsDebugMsg( "error, could not get epsg id" );
    }
    else
    {
      QgsDebugMsg( QString( "mEpsg = %1" ).arg( mEpsg ) );
    }
  }
}
Exemple #22
0
void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
{
  QString elementName( QString::fromUtf8( el ) );
  ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );
  QStringList splitName =  elementName.split( NS_SEPARATOR );
  QString localName = splitName.last();
  QString ns = splitName.size() > 1 ? splitName.first() : "";

  if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "coordinates" )
  {
    mParseModeStack.push( QgsGml::coordinate );
    mStringCash.clear();
    mCoordinateSeparator = readAttribute( "cs", attr );
    if ( mCoordinateSeparator.isEmpty() )
    {
      mCoordinateSeparator = ",";
    }
    mTupleSeparator = readAttribute( "ts", attr );
    if ( mTupleSeparator.isEmpty() )
    {
      mTupleSeparator = " ";
    }
  }
  else if ( localName == mGeometryAttribute )
  {
    mParseModeStack.push( QgsGml::geometry );
  }
  //else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
  {
    mParseModeStack.push( QgsGml::boundingBox );
  }
  else if ( theParseMode == none && localName == mTypeName )
  {
    Q_ASSERT( !mCurrentFeature );
    mCurrentFeature = new QgsFeature( mFeatureCount );
    QgsAttributes attributes( mThematicAttributes.size() ); //add empty attributes
    mCurrentFeature->setAttributes( attributes );
    mParseModeStack.push( QgsGml::feature );
    mCurrentFeatureId = readAttribute( "fid", attr );
  }

  else if ( theParseMode == boundingBox && elementName == GML_NAMESPACE + NS_SEPARATOR + "Box" )
  {
    //read attribute srsName="EPSG:26910"
    int epsgNr;
    if ( readEpsgFromAttribute( epsgNr, attr ) != 0 )
    {
      QgsDebugMsg( "error, could not get epsg id" );
    }
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
  {
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
  {
    mParseModeStack.push( QgsGml::multiPoint );
    //we need one nested list for intermediate WKB
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
  {
    mParseModeStack.push( QgsGml::multiLine );
    //we need one nested list for intermediate WKB
    mCurrentWKBFragments.push_back( QList<unsigned char*>() );
    mCurrentWKBFragmentSizes.push_back( QList<int>() );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
  {
    mParseModeStack.push( QgsGml::multiPolygon );
  }
  else if ( theParseMode == feature && mThematicAttributes.contains( localName ) )
  {
    mParseModeStack.push( QgsGml::attribute );
    mAttributeName = localName;
    mStringCash.clear();
  }
}
Exemple #23
0
void QgsWFSData::startElement( const XML_Char* el, const XML_Char** attr )
{
  QString elementName( el );
  QString localName = elementName.section( NS_SEPARATOR, 1, 1 );
  if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "coordinates" )
  {
    mParseModeStack.push( QgsWFSData::coordinate );
    mStringCash.clear();
    mCoordinateSeparator = readAttribute( "cs", attr );
    if ( mCoordinateSeparator.isEmpty() )
    {
      mCoordinateSeparator = ",";
    }
    mTupleSeparator = readAttribute( "ts", attr );
    if ( mTupleSeparator.isEmpty() )
    {
      mTupleSeparator = " ";
    }
  }
  else if ( localName == mGeometryAttribute )
  {
    mParseModeStack.push( QgsWFSData::geometry );
  }
  else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
  {
    mParseModeStack.push( QgsWFSData::boundingBox );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "featureMember" )
  {
    mCurrentFeature = new QgsFeature( mFeatureCount );
    mParseModeStack.push( QgsWFSData::featureMember );
  }
  else if ( localName == mTypeName )
  {
    mCurrentFeatureId = readAttribute( "fid", attr );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Box" && mParseModeStack.top() == QgsWFSData::boundingBox )
  {
    //read attribute srsName="EPSG:26910"
    int epsgNr;
    if ( readEpsgFromAttribute( epsgNr, attr ) != 0 )
    {
      QgsDebugMsg( "error, could not get epsg id" );
    }
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
  {
    std::list<unsigned char*> wkbList;
    std::list<int> wkbSizeList;
    mCurrentWKBFragments.push_back( wkbList );
    mCurrentWKBFragmentSizes.push_back( wkbSizeList );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
  {
    mParseModeStack.push( QgsWFSData::multiPoint );
    //we need one nested list for intermediate WKB
    std::list<unsigned char*> wkbList;
    std::list<int> wkbSizeList;
    mCurrentWKBFragments.push_back( wkbList );
    mCurrentWKBFragmentSizes.push_back( wkbSizeList );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
  {
    mParseModeStack.push( QgsWFSData::multiLine );
    //we need one nested list for intermediate WKB
    std::list<unsigned char*> wkbList;
    std::list<int> wkbSizeList;
    mCurrentWKBFragments.push_back( wkbList );
    mCurrentWKBFragmentSizes.push_back( wkbSizeList );
  }
  else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
  {
    mParseModeStack.push( QgsWFSData::multiPolygon );
  }

  else if ( mParseModeStack.size() == 1 && mParseModeStack.top() == QgsWFSData::featureMember && mThematicAttributes.find( localName ) != mThematicAttributes.end() )
  {
    mParseModeStack.push( QgsWFSData::attribute );
    mAttributeName = localName;
    mStringCash.clear();
  }
}
//Scilab 6
char* getScilabTypeFromDataSet6(int dataset)
{
    return readAttribute(dataset, g_SCILAB_CLASS);
}
/*
** WARNING : this function returns an allocated value that must be freed.
*/
char* getScilabVersionAttribute(int _iFile)
{
    return readAttribute(_iFile, g_SCILAB_CLASS_SCI_VERSION);
}
Exemple #26
0
/*
  \overload
*/
QVariant DomTool::readAttribute(const QDomElement& e, const QString& name, const QVariant& defValue)
{
    QString comment;
    return readAttribute(e, name, defValue, comment);
}
Exemple #27
0
/*
 * Run the Device/Target Group Layout dialog
 */
void devTgtGrpLayoutDialog(CDKSCREEN *main_cdk_screen) {
    CDKSWINDOW *alua_info = 0;
    char *swindow_info[MAX_ALUA_LAYOUT_LINES] = {NULL};
    int i = 0, line_pos = 0;
    char dir_name[MAX_SYSFS_PATH_SIZE] = {0},
            tmp_buff[MAX_SYSFS_ATTR_SIZE] = {0};
    DIR *dev_grp_dir_stream = NULL, *tgt_grp_dir_stream = NULL,
            *tgt_dir_stream = NULL, *dev_dir_stream = NULL;
    struct dirent *dev_grp_dir_entry = NULL, *tgt_grp_dir_entry = NULL,
            *tgt_dir_entry = NULL, *dev_dir_entry = NULL;

    /* Setup scrolling window widget */
    alua_info = newCDKSwindow(main_cdk_screen, CENTER, CENTER,
            (ALUA_LAYOUT_ROWS + 2), (ALUA_LAYOUT_COLS + 2),
            "<C></31/B>SCST ALUA Device/Target Group Layout\n",
            MAX_ALUA_LAYOUT_LINES, TRUE, FALSE);
    if (!alua_info) {
        errorDialog(main_cdk_screen, SWINDOW_ERR_MSG, NULL);
        return;
    }
    setCDKSwindowBackgroundAttrib(alua_info, COLOR_DIALOG_TEXT);
    setCDKSwindowBoxAttribute(alua_info, COLOR_DIALOG_BOX);

    line_pos = 0;
    while (1) {
        /* We'll start with the SCST device groups */
        snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                "%s/device_groups", SYSFS_SCST_TGT);
        if ((dev_grp_dir_stream = opendir(dir_name)) == NULL) {
            if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s",
                        strerror(errno));
                line_pos++;
            }
            break;
        }
        while ((dev_grp_dir_entry = readdir(dev_grp_dir_stream)) != NULL) {
            /* The device group names are directories; skip '.' and '..' */
            if ((dev_grp_dir_entry->d_type == DT_DIR) &&
                    (strcmp(dev_grp_dir_entry->d_name, ".") != 0) &&
                    (strcmp(dev_grp_dir_entry->d_name, "..") != 0)) {
                if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                    SAFE_ASPRINTF(&swindow_info[line_pos],
                            "</B>Device Group:<!B> %s",
                            dev_grp_dir_entry->d_name);
                    line_pos++;
                }

                /* Now get all of the device names for this device group */
                snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                        "%s/device_groups/%s/devices",
                        SYSFS_SCST_TGT, dev_grp_dir_entry->d_name);
                if ((dev_dir_stream = opendir(dir_name)) == NULL) {
                    if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                        SAFE_ASPRINTF(&swindow_info[line_pos],
                                "opendir(): %s", strerror(errno));
                        line_pos++;
                    }
                    break;
                }
                while ((dev_dir_entry = readdir(dev_dir_stream)) != NULL) {
                    /* The device names are links */
                    if (dev_dir_entry->d_type == DT_LNK) {
                        if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                            SAFE_ASPRINTF(&swindow_info[line_pos],
                                    "\t</B>Device:<!B> %s",
                                    dev_dir_entry->d_name);
                            line_pos++;
                        }
                    }
                }
                closedir(dev_dir_stream);

                /* Now get all of the target groups for this device group */
                snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                        "%s/device_groups/%s/target_groups", SYSFS_SCST_TGT,
                        dev_grp_dir_entry->d_name);
                if ((tgt_grp_dir_stream = opendir(dir_name)) == NULL) {
                    if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                        SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s",
                                strerror(errno));
                        line_pos++;
                    }
                    break;
                }
                while ((tgt_grp_dir_entry = readdir(tgt_grp_dir_stream)) !=
                        NULL) {
                    /* The target group names are directories;
                     * skip '.' and '..' */
                    if ((tgt_grp_dir_entry->d_type == DT_DIR) &&
                            (strcmp(tgt_grp_dir_entry->d_name, ".") != 0) &&
                            (strcmp(tgt_grp_dir_entry->d_name, "..") != 0)) {
                        if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                            snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                            "%s/device_groups/%s/target_groups/%s/group_id",
                            SYSFS_SCST_TGT, dev_grp_dir_entry->d_name,
                                    tgt_grp_dir_entry->d_name);
                            readAttribute(dir_name, tmp_buff);
                            SAFE_ASPRINTF(&swindow_info[line_pos],
                                    "\t</B>Target Group:<!B> %s (Group ID: %s)",
                                    tgt_grp_dir_entry->d_name, tmp_buff);
                            line_pos++;
                        }

                        /* Loop over each target name for the
                         * current target group */
                        snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                                "%s/device_groups/%s/target_groups/%s",
                                SYSFS_SCST_TGT, dev_grp_dir_entry->d_name,
                                tgt_grp_dir_entry->d_name);
                        if ((tgt_dir_stream = opendir(dir_name)) == NULL) {
                            if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                                SAFE_ASPRINTF(&swindow_info[line_pos],
                                        "opendir(): %s", strerror(errno));
                                line_pos++;
                            }
                            break;
                        }
                        while ((tgt_dir_entry = readdir(tgt_dir_stream)) !=
                                NULL) {
                            /* The target names are links (if local),
                             * or directories (if remote); skip '.' and '..' */
                            if (((tgt_dir_entry->d_type == DT_DIR) &&
                                    (strcmp(tgt_dir_entry->d_name,
                                    ".") != 0) &&
                                    (strcmp(tgt_dir_entry->d_name,
                                    "..") != 0)) ||
                                    (tgt_dir_entry->d_type == DT_LNK)) {
                                if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                                    snprintf(dir_name, MAX_SYSFS_PATH_SIZE,
                                            "%s/device_groups/%s/"
                                            "target_groups/%s/%s/rel_tgt_id",
                                            SYSFS_SCST_TGT,
                                            dev_grp_dir_entry->d_name,
                                            tgt_grp_dir_entry->d_name,
                                            tgt_dir_entry->d_name);
                                    readAttribute(dir_name, tmp_buff);
                                    SAFE_ASPRINTF(&swindow_info[line_pos],
                                            "\t\t</B>Target:<!B> %s "
                                            "(Rel Tgt ID: %s)",
                                            tgt_dir_entry->d_name, tmp_buff);
                                    line_pos++;
                                }
                            }
                        }
                        closedir(tgt_dir_stream);
                    }
                }
                closedir(tgt_grp_dir_stream);

                /* Print a blank line to separate targets */
                if (line_pos < MAX_ALUA_LAYOUT_LINES) {
                    SAFE_ASPRINTF(&swindow_info[line_pos], " ");
                    line_pos++;
                }
            }
        }
        closedir(dev_grp_dir_stream);
        break;
    }

    /* Add a message to the bottom explaining how to close the dialog */
    if (line_pos < MAX_ALUA_LAYOUT_LINES) {
        SAFE_ASPRINTF(&swindow_info[line_pos], " ");
        line_pos++;
    }
    if (line_pos < MAX_ALUA_LAYOUT_LINES) {
        SAFE_ASPRINTF(&swindow_info[line_pos], CONTINUE_MSG);
        line_pos++;
    }

    /* Set the scrolling window content */
    setCDKSwindowContents(alua_info, swindow_info, line_pos);

    /* The 'g' makes the swindow widget scroll to the top, then activate */
    injectCDKSwindow(alua_info, 'g');
    activateCDKSwindow(alua_info, 0);

    /* We fell through -- the user exited the widget, but we don't care how */
    destroyCDKSwindow(alua_info);

    /* Done */
    for (i = 0; i < MAX_ALUA_LAYOUT_LINES; i++)
        FREE_NULL(swindow_info[i]);
    return;
}
Exemple #28
0
AttributeInfo readAttribute(FILE* fp, u2_t cpCount, CpInfo* cp) {
	AttributeInfo attr;
	READ2(fp, attr.nameIndex);
	READ4(fp, attr.length);

	if (cpCount >= attr.nameIndex && cp[attr.nameIndex].tag != 1) { // CONSTANT_Utf8
		printf("WRONG ATTRIBUTE INDEX\n");
		exit(EXIT_FAILURE);
	}

	// TODO info should go
	void* info = malloc(attr.length);
	Code* code;
	SourceFile* sourceFile;

	switch (attributeNameToKind( *((Utf8*) cp[attr.nameIndex].info) )) {
		case CONSTANTVALUE:
			READBYTES(fp, info, attr.length);
			break;
		case CODE:
			attr.kind = CODE;
			code = malloc(sizeof(Code));
			attr.info = code;
			READ2(fp, code->maxStack);
			READ2(fp, code->maxLocals);
			READ4(fp, code->codeLength);
			// TODO incomplete
			READBYTES(fp, info, code->codeLength);
			READ2(fp, code->exceptionTableLength);
			code->exceptionTable = (code->exceptionTableLength == 0) ? NULL : malloc(code->exceptionTableLength * sizeof(ExceptionTableEntry));
			for (u2_t i = 0 ; i < code->exceptionTableLength ; i++) {
				READ2(fp, code->exceptionTable[i].startPC);
				READ2(fp, code->exceptionTable[i].endPC);
				READ2(fp, code->exceptionTable[i].handlerPC);
				READ2(fp, code->exceptionTable[i].catchType);
				printf("%d %d %d %d\n", code->exceptionTable[i].startPC, code->exceptionTable[i].endPC, code->exceptionTable[i].handlerPC, code->exceptionTable[i].catchType);
			}
			READ2(fp, code->attributesCount);
			code->attributes = (code->attributesCount == 0) ? NULL : malloc(code->attributesCount * sizeof(AttributeInfo));
			for (u2_t i = 0 ; i < code->attributesCount ; i++) {
				code->attributes[i] = readAttribute(fp, cpCount, cp);
			}
			break;
		case STACKMAPTABLE:
			READBYTES(fp, info, attr.length);
			break;
		case EXCEPTIONS:
			READBYTES(fp, info, attr.length);
			break;
		case INNERCLASSES:
			READBYTES(fp, info, attr.length);
			break;
		case ENCLOSINGMETHOD:
			READBYTES(fp, info, attr.length);
			break;
		case SYNTHETIC:
			READBYTES(fp, info, attr.length);
			break;
		case SIGNATURE:
			READBYTES(fp, info, attr.length);
			break;
		case SOURCEFILE:
			attr.kind = SOURCEFILE;
			sourceFile = malloc(sizeof(SourceFile));
			attr.info = sourceFile;
			READ2(fp, sourceFile->sourceFileIndex);
			break;
		case SOURCEDEBUGEXTENSION:
			READBYTES(fp, info, attr.length);
			break;
		case LINENUMBERTABLE:
			READBYTES(fp, info, attr.length);
			break;
		case LOCALVARIABLETABLE:
			READBYTES(fp, info, attr.length);
			break;
		case LOCALVARIABLETYPETABLE:
			READBYTES(fp, info, attr.length);
			break;
		case DEPRECATED:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEVISIBLEANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEINVISIBLEANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEVISIBLEPARAMETERANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEINVISIBLEPARAMETERANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEVISIBLETYPEANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case RUNTIMEINVISIBLETYPEANNOTATIONS:
			READBYTES(fp, info, attr.length);
			break;
		case ANNOTATIONDEFAULT:
			READBYTES(fp, info, attr.length);
			break;
		case BOOTSTRAPMETHODS:
			READBYTES(fp, info, attr.length);
			break;
		case METHODPARAMETERS:
			READBYTES(fp, info, attr.length);
			break;
		default:
			printf("UNKNOWN ATTRIBUTE\n");
			exit(EXIT_FAILURE);
	}
	return attr;
}
int getScilabTypeFromDataSet(int _iDatasetId)
{
    int iVarType = 0;
    char *pstScilabClass = readAttribute(_iDatasetId, g_SCILAB_CLASS);

    if (pstScilabClass == NULL)
    {
        return unknow_type;
    }
    /* HDF5 Float type + SCILAB_Class = double <=> double */
    if (strcmp(pstScilabClass, g_SCILAB_CLASS_DOUBLE) == 0)
    {
        iVarType = sci_matrix;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_STRING) == 0)
    {
        iVarType = sci_strings;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_BOOLEAN) == 0)
    {
        iVarType = sci_boolean;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_POLY) == 0)
    {
        iVarType = sci_poly;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_INT) == 0)
    {
        iVarType = sci_ints;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_SPARSE) == 0)
    {
        iVarType = sci_sparse;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_BSPARSE) == 0)
    {
        iVarType = sci_boolean_sparse;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_LIST) == 0)
    {
        iVarType = sci_list;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_TLIST) == 0)
    {
        iVarType = sci_tlist;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_MLIST) == 0)
    {
        iVarType = sci_mlist;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_VOID) == 0)
    {
        iVarType = sci_void;
    }
    else if (strcmp(pstScilabClass, g_SCILAB_CLASS_UNDEFINED) == 0)
    {
        iVarType = sci_undefined;
    }

    FREE(pstScilabClass);
    return iVarType;
}