void StyleReader::startElementHandler(const char *tag, const char **attributes) {
	static const std::string BASE = "base";
	static const std::string STYLE = "style";

	if (BASE == tag) {
		myCollection.myBaseStyle = new BaseTextStyle(attributeValue(attributes, "family"), intValue(attributes, "fontSize"));
	} else if (STYLE == tag) {
		const char *idString = attributeValue(attributes, "id");
		const char *name = attributeValue(attributes, "name");
		if ((idString != 0) && (name != 0)) {
			TextKind id = (TextKind)atoi(idString);
			TextStyleDecoration *decoration;

			int fontSizeDelta = intValue(attributes, "fontSizeDelta");
			Boolean3 bold = b3Value(attributes, "bold");
			Boolean3 italic = b3Value(attributes, "italic");
			int verticalShift = intValue(attributes, "vShift");
			Boolean3 allowHyphenations = b3Value(attributes, "allowHyphenations");
			bool isHyperlink = booleanValue(attributes, "isHyperlink");

			if (booleanValue(attributes, "partial")) {
				decoration = new TextStyleDecoration(name, fontSizeDelta, bold, italic, verticalShift, allowHyphenations);
			} else {
				int spaceBefore = intValue(attributes, "spaceBefore");
				int spaceAfter = intValue(attributes, "spaceAfter");
				int leftIndent = intValue(attributes, "leftIndent");
				int rightIndent = intValue(attributes, "rightIndent");
				int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta");

				AlignmentType alignment = ALIGN_UNDEFINED;
				const char *alignmentString = attributeValue(attributes, "alignment");
				if (alignmentString != 0) {
					if (strcmp(alignmentString, "left") == 0) {
						alignment = ALIGN_LEFT;
					} else if (strcmp(alignmentString, "rigth") == 0) {
						alignment = ALIGN_RIGHT;
					} else if (strcmp(alignmentString, "center") == 0) {
						alignment = ALIGN_CENTER;
					} else if (strcmp(alignmentString, "justify") == 0) {
						alignment = ALIGN_JUSTIFY;
					}
				}
				double lineSpace = doubleValue(attributes, "lineSpace");

				decoration = new FullTextStyleDecoration(name, fontSizeDelta, bold, italic, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, verticalShift, alignment, lineSpace, allowHyphenations);
			}
			if (isHyperlink) {
				decoration->setHyperlinkStyle();
			}
			myCollection.myDecorationMap.insert(std::pair<TextKind,TextStyleDecoration*>(id, decoration));
		}
	}
}
Esempio n. 2
0
IntegerType Number::ReadInteger(Input &input)
{
	IntegerType intValue(0);
	// Process part before decimal separator
	while(input.Current() >= '0' && input.Current() <= '9')
	{
		intValue = intValue * 10 + (input.Current() - '0');
		input.Next();
	}
	return intValue;
}
Esempio n. 3
0
void fun_itoa()
{
    char buffer[100];
    sprintf(buffer, "%d", intValue(top()));

    {
        VAR_ str = *stringConstructor_cP(buffer);
        assign(top(), &str);
        stringDestructor(&str);
    }
}
Esempio n. 4
0
//***********************************************************
//* Import a shared notebook
//***********************************************************
void ImportData::processSharedNotebookNode() {
    QLOG_DEBUG() << "Processing Shared Notebook Node";


    SharedNotebook sharedNotebook;
    //bool sharedNotebookIsDirty = false;

    QLOG_ERROR() << "Shared notebook database support not implemented yet";

    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "id") {
                sharedNotebook.id = intValue();
            }
            if (name == "userid") {
                sharedNotebook.userId = intValue();
            }
            if (name == "email") {
                sharedNotebook.email = textValue();
            }
            if (name == "notebookguid") {
                sharedNotebook.notebookGuid = textValue();
            }
            if (name == "sharekey") {
                sharedNotebook.shareKey = textValue();
            }
            if (name == "username") {
                sharedNotebook.username = textValue();
            }
            if (name == "servicecreated") {
                sharedNotebook.serviceCreated = longValue();
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "sharednotebook" && reader->isEndElement())
            atEnd = true;		}
    return;
}
Esempio n. 5
0
int getInteger(const XML_Node& parent, const std::string& name)
{
    if (!parent.hasChild(name)) {
        throw CanteraError("getInteger (called from XML Node \"" +
                           parent.name() + "\"): ",
                           "no child XML element named " + name);
    }
    const XML_Node& node = parent.child(name);
    int x = node.int_value();
    const string& vmin = node["min"];
    const string& vmax = node["max"];
    if (vmin != "" && x < intValue(vmin)) {
        writelog("\nWarning: value "+node.value()+" is below lower limit of "
                 +vmin+".\n");
    }
    if (node["max"] != "" && x > intValue(vmax)) {
        writelog("\nWarning: value "+node.value()+" is above upper limit of "
                 +vmax+".\n");
    }
    return x;
}
Esempio n. 6
0
int QLCDNumber::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 9)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 9;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = smallDecimalPoint(); break;
        case 1: *reinterpret_cast< int*>(_v) = numDigits(); break;
        case 2: *reinterpret_cast< int*>(_v) = digitCount(); break;
        case 3: *reinterpret_cast< Mode*>(_v) = mode(); break;
        case 4: *reinterpret_cast< SegmentStyle*>(_v) = segmentStyle(); break;
        case 5: *reinterpret_cast< double*>(_v) = value(); break;
        case 6: *reinterpret_cast< int*>(_v) = intValue(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSmallDecimalPoint(*reinterpret_cast< bool*>(_v)); break;
        case 1: setNumDigits(*reinterpret_cast< int*>(_v)); break;
        case 2: setDigitCount(*reinterpret_cast< int*>(_v)); break;
        case 3: setMode(*reinterpret_cast< Mode*>(_v)); break;
        case 4: setSegmentStyle(*reinterpret_cast< SegmentStyle*>(_v)); break;
        case 5: display(*reinterpret_cast< double*>(_v)); break;
        case 6: display(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 7
0
//***********************************************************
//* Process a shared notebook
//***********************************************************
void ImportData::processLinkedNotebookNode() {
    LinkedNotebook  linkedNotebook;
    bool linkedNotebookIsDirty=false;

    QLOG_ERROR() << "Linked notebook database support not implemented yet";

    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid") {
                linkedNotebook.guid = textValue().toStdString();
                linkedNotebook.__isset.guid = true;
            }
            if (name == "shardid") {
                linkedNotebook.shardId = textValue().toStdString();
                linkedNotebook.__isset.shardId = true;
            }
            if (name == "updatesequencenumber") {
                linkedNotebook.updateSequenceNum = intValue();
                linkedNotebook.__isset.updateSequenceNum = true;
            }
            if (name == "sharekey") {
                linkedNotebook.shareKey = textValue().toStdString();
                linkedNotebook.__isset.shareKey = true;
            }
            if (name == "sharename") {
                linkedNotebook.shareName = textValue().toStdString();
                linkedNotebook.__isset.shareName = true;
            }
            if (name == "uri") {
                linkedNotebook.uri = textValue().toStdString();
                linkedNotebook.__isset.uri = true;
            }
            if (name == "username") {
                linkedNotebook.username = textValue().toStdString();
                linkedNotebook.__isset.username = true;
            }
            if (name == "dirty") {
                if (booleanValue())
                    linkedNotebookIsDirty = true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "linkednotebook" && reader->isEndElement())
            atEnd = true;		}
    return;
}
QVariant VcsBaseClientSettings::value(const QString &key) const
{
    switch (valueType(key)) {
    case QVariant::Int:
        return intValue(key);
    case QVariant::Bool:
        return boolValue(key);
    case QVariant::String:
        return stringValue(key);
    case QVariant::Invalid:
        return QVariant();
    default:
        return QVariant();
    }
}
void TCmdSetProperty::ExecuteL()
	{
	// ---------- Setup --------------------------------------------------------

    // Getting Uids and value
    TInt uidValue = ExtractIntegerL( KParamPropertyUid, 0, EFalse );
    TInt key = ExtractIntegerL( KParamPropertyKey, 0, ETrue );

    TInt propertyAttr = RProperty::EText;
    TInt intValue( 0 );
    TPtrC8 descrValue = ExtractTextL( KParamPropertyTextValue, EFalse );
    if ( descrValue == KNullDesC8 )
    	{
    	// As text parameter was not specified, integer parameter is now
		// mandatory, except for KMceTesterNatPluginResourceReservationStatus
		// which does not require a value.
		TBool isMandatory = ( key != KMceTesterNatPluginResourceReservationStatus );
		intValue = ExtractIntegerL( KParamPropertyValue, 0, isMandatory );

    	propertyAttr = RProperty::EInt;
    	}

    TUid uidkey = KUidMceTesterPSKeys;
    if ( uidValue != 0 )
        {
        uidkey = TUid::Uid( uidValue );
        }

    // ---------- Execution ----------------------------------------------------

    _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
    User::LeaveIfError( RProperty::Define( uidkey, key, propertyAttr,
    									   KAllowAllPolicy, KAllowAllPolicy ) );
    if ( propertyAttr == RProperty::EInt )
    	{
    	User::LeaveIfError( RProperty::Set( uidkey, key, intValue ) );
    	}
    else
    	{
    	User::LeaveIfError( RProperty::Set( uidkey, key, descrValue ) );
    	}
    
    // ---------- Response creation --------------------------------------------

    }
Esempio n. 10
0
//***********************************************************
//* Process a <synchronization> node
//***********************************************************
void ImportData::processSynchronizationNode() {
    bool atEnd = false;
    UserTable userTable;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "updatesequencenumber") {
                userTable.updateLastSyncNumber(intValue());
            }
            if (name == "lastsequencedate")
                userTable.updateLastSyncDate(longValue());
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "synchronization" && reader->isEndElement())
            atEnd = true;
    }

}
Esempio n. 11
0
WaylandInterface readInterface(QXmlStreamReader &xml)
{
    WaylandInterface interface;
    interface.name = byteArrayValue(xml, "name");
    interface.version = intValue(xml, "version", 1);

    while (xml.readNextStartElement()) {
        if (xml.name() == "event")
            interface.events << readEvent(xml, false);
        else if (xml.name() == "request")
            interface.requests << readEvent(xml, true);
        else if (xml.name() == "enum")
            interface.enums << readEnum(xml);
        else
            xml.skipCurrentElement();
    }

    return interface;
}
Esempio n. 12
0
int FrInteger::compare(const FrObject *obj) const
{
   if (!obj)
      return 1 ;     // anything is greater than NIL / empty-list
   if (!obj->numberp())
      return -1 ;    // sort all non-numbers after numbers
   else if (objType() < obj->objType())
      return -((FrNumber*)obj)->compare(this) ;
   else
      {
      long diff = intValue() - ((FrNumber*)obj)->intValue() ;
      if (diff < 0)
	 return -1 ;
      else if (diff > 0)
	 return +1 ;
      else
	 return 0 ;
      }
}
Esempio n. 13
0
//***********************************************************
//* Process a <savedsearch> node.
//***********************************************************
void ImportData::processSavedSearchNode() {
    SavedSearch search;
    bool searchIsDirty = false;
    SearchTable searchTable;

    bool atEnd = false;

    // Keep going until we hit </savedsearch>
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid")  {
                search.guid = textValue().toStdString();
                search.__isset.guid = true;
            }
            if (name == "name") {
                search.name = textValue().toStdString();
                search.__isset.name = true;
            }
            if (name == "updatesequencenumber") {
                search.updateSequenceNum = intValue();
                search.__isset.updateSequenceNum = true;
            }
            if (name == "query") {
                search.query = textValue().toStdString();
                search.__isset.query = true;
            }
            if (name == "dirty") {
                if (booleanValue())
                    searchIsDirty = true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "savedsearch" && reader->isEndElement())
            atEnd = true;
    }

    // Add this search to the table
    searchTable.add(0,search, searchIsDirty);
    return;
}
Esempio n. 14
0
void Sim1D::restore(const std::string& fname, const std::string& id,
                    int loglevel)
{
    ifstream s(fname.c_str());
    if (!s)
        throw CanteraError("Sim1D::restore",
                           "could not open input file "+fname);

    XML_Node root;
    root.build(s);
    s.close();

    XML_Node* f = root.findID(id);
    if (!f) {
        throw CanteraError("Sim1D::restore","No solution with id = "+id);
    }

    vector<XML_Node*> xd;
    f->getChildren("domain", xd);
    if (xd.size() != m_nd) {
        throw CanteraError("Sim1D::restore", "Solution does not contain the "
                           " correct number of domains. Found " +
                           int2str(xd.size()) + "expected " +
                           int2str(m_nd) + ".\n");
    }
    size_t sz = 0;
    for (size_t m = 0; m < m_nd; m++) {
        if (loglevel > 0 && xd[m]->attrib("id") != domain(m).id()) {
            writelog("Warning: domain names do not match: '" +
                     (*xd[m])["id"] + + "' and '" + domain(m).id() + "'\n");
        }
        sz += domain(m).nComponents() * intValue((*xd[m])["points"]);
    }
    m_x.resize(sz);
    m_xnew.resize(sz);
    for (size_t m = 0; m < m_nd; m++) {
        domain(m).restore(*xd[m], DATA_PTR(m_x) + domain(m).loc(), loglevel);
    }
    resize();
    finalize();
}
Esempio n. 15
0
int64_t FrNumber::int64value() const
{
   return intValue() ;
}
Esempio n. 16
0
bool importPhase(XML_Node& phase, ThermoPhase* th,
                 SpeciesThermoFactory* spfactory)
{
    // Check the the supplied XML node in fact represents a phase.
    if (phase.name() != "phase") {
        throw CanteraError("importPhase",
                           "Current const XML_Node named, " + phase.name() +
                           ", is not a phase element.");
    }

    /*
     * In this section of code, we get the reference to the
     * phase xml tree within the ThermoPhase object. Then,
     * we clear it and fill it with the current information that
     * we are about to use to construct the object. We will then
     * be able to resurrect the information later by calling xml().
     */
    th->setXMLdata(phase);

    // set the id attribute of the phase to the 'id' attribute in the XML tree.
    th->setID(phase.id());
    th->setName(phase.id());

    // Number of spatial dimensions. Defaults to 3 (bulk phase)
    if (phase.hasAttrib("dim")) {
        int idim = intValue(phase["dim"]);
        if (idim < 1 || idim > 3)
            throw CanteraError("importPhase",
                               "phase, " + th->id() +
                               ", has unphysical number of dimensions: " + phase["dim"]);
        th->setNDim(idim);
    } else {
        th->setNDim(3);     // default
    }

    // Set equation of state parameters. The parameters are
    // specific to each subclass of ThermoPhase, so this is done
    // by method setParametersFromXML in each subclass.
    const XML_Node& eos = phase.child("thermo");
    if (phase.hasChild("thermo")) {
        th->setParametersFromXML(eos);
    } else {
        throw CanteraError("importPhase",
                           " phase, " + th->id() +
                           ", XML_Node does not have a \"thermo\" XML_Node");
    }

    VPStandardStateTP* vpss_ptr = 0;
    int ssConvention = th->standardStateConvention();
    if (ssConvention == cSS_CONVENTION_VPSS) {
        vpss_ptr = dynamic_cast <VPStandardStateTP*>(th);
        if (vpss_ptr == 0) {
            throw CanteraError("importPhase",
                               "phase, " + th->id() + ", was VPSS, but dynamic cast failed");
        }
    }

    // if no species thermo factory was supplied, use the default one.
    if (!spfactory) {
        spfactory = SpeciesThermoFactory::factory();
    }

    /***************************************************************
     * Add the elements.
     ***************************************************************/
    if (ssConvention != cSS_CONVENTION_SLAVE) {
        installElements(*th, phase);
    }

    /***************************************************************
     * Add the species.
     *
     * Species definitions may be imported from multiple
     * sources. For each one, a speciesArray element must be
     * present.
     ***************************************************************/
    vector<XML_Node*> sparrays;
    phase.getChildren("speciesArray", sparrays);
    if (ssConvention != cSS_CONVENTION_SLAVE) {
        if (sparrays.empty()) {
            throw CanteraError("importPhase",
                               "phase, " + th->id() + ", has zero \"speciesArray\" XML nodes.\n"
                               + " There must be at least one speciesArray nodes "
                               "with one or more species");
        }
    }
    vector<XML_Node*> dbases;
    vector_int sprule(sparrays.size(),0);

    // loop over the speciesArray elements
    for (size_t jsp = 0; jsp < sparrays.size(); jsp++) {

        const XML_Node& speciesArray = *sparrays[jsp];

        // If the speciesArray element has a child element
        //
        //   <skip element="undeclared">
        //
        // then set sprule[jsp] to 1, so that any species with an undeclared
        // element will be quietly skipped when importing species. Additionally,
        // if the skip node has the following attribute:
        //
        // <skip species="duplicate">
        //
        // then duplicate species names will not cause Cantera to throw an
        // exception. Instead, the duplicate entry will be discarded.
        if (speciesArray.hasChild("skip")) {
            const XML_Node& sk = speciesArray.child("skip");
            string eskip = sk["element"];
            if (eskip == "undeclared") {
                sprule[jsp] = 1;
            }
            string dskip = sk["species"];
            if (dskip == "duplicate") {
                sprule[jsp] += 10;
            }
        }

        // Get a pointer to the node containing the species
        // definitions for the species declared in this
        // speciesArray element. This may be in the local file
        // containing the phase element, or may be in another
        // file.
        XML_Node* db = get_XML_Node(speciesArray["datasrc"], &phase.root());
        if (db == 0) {
            throw CanteraError("importPhase()",
                               " Can not find XML node for species database: "
                               + speciesArray["datasrc"]);
        }

        // add this node to the list of species database nodes.
        dbases.push_back(db);
    }

    // Now, collect all the species names and all the XML_Node * pointers
    // for those species in a single vector. This is where we decide what
    // species are to be included in the phase.
    // The logic is complicated enough that we put it in a separate routine.
    std::vector<XML_Node*>  spDataNodeList;
    std::vector<std::string> spNamesList;
    std::vector<int> spRuleList;
    formSpeciesXMLNodeList(spDataNodeList, spNamesList, spRuleList,
                           sparrays, dbases, sprule);

    // Decide whether the the phase has a variable pressure ss or not
    SpeciesThermo* spth = 0;
    VPSSMgr* vp_spth = 0;
    if (ssConvention == cSS_CONVENTION_TEMPERATURE) {
        // Create a new species thermo manager.  Function
        // 'newSpeciesThermoMgr' looks at the species in the database
        // to see what thermodynamic property parameterizations are
        // used, and selects a class that can handle the
        // parameterizations found.
        spth = newSpeciesThermoMgr(spDataNodeList);

        // install it in the phase object
        th->setSpeciesThermo(spth);
    } else if (ssConvention == cSS_CONVENTION_SLAVE) {
        /*
         * No species thermo manager for this type
         */
    } else if (ssConvention == cSS_CONVENTION_VPSS) {
        vp_spth = newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
        vpss_ptr->setVPSSMgr(vp_spth);
        spth = vp_spth->SpeciesThermoMgr();
        th->setSpeciesThermo(spth);
    } else {
        throw CanteraError("importPhase()", "unknown convention");
    }


    size_t k = 0;

    size_t nsp = spDataNodeList.size();
    if (ssConvention == cSS_CONVENTION_SLAVE) {
        if (nsp > 0) {
            throw CanteraError("importPhase()", "For Slave standard states, number of species must be zero: "
                               + int2str(nsp));
        }
    }
    for (size_t i = 0; i < nsp; i++) {
        XML_Node* s = spDataNodeList[i];
        AssertTrace(s != 0);
        bool ok = installSpecies(k, *s, *th, spth, spRuleList[i],
                                 &phase, vp_spth, spfactory);
        if (ok) {
            th->saveSpeciesData(k, s);
            ++k;
        }
    }

    if (ssConvention == cSS_CONVENTION_SLAVE) {
        th->installSlavePhases(&phase);
    }

    // Done adding species. Perform any required subclass-specific
    // initialization.
    th->initThermo();

    // Perform any required subclass-specific initialization
    // that requires the XML phase object
    std::string id = "";
    th->initThermoXML(phase, id);

    return true;
}
Esempio n. 17
0
//***********************************************************
//* Process a <notebook> node
//***********************************************************
void ImportData::processNotebookNode() {
    QLOG_DEBUG() << "Processing Notebook Node";


    Notebook notebook;
    bool notebookIsDirty = false;
    bool notebookIsLocal = false;
    Publishing publishing;
//    bool notebookIsReadOnly = false;

//    notebookIcon = null;
    bool atEnd = false;

    // Loop through until we hit </notebook>
    while(!atEnd) {
        if (backup || importNotebooks) {
            if (reader->isStartElement()) {
                QString name = reader->name().toString().toLower();
                if (name == "guid") {
                    notebook.guid = textValue();
                }
                if (name == "name") {
                    notebook.name = textValue();
                }
                if (name == "updatesequencenumber") {
                    notebook.updateSequenceNum = intValue();
                }
                if (name == "servicecreated") {
                    notebook.serviceCreated = longValue();
                }
                if (name == "serviceupdated") {
                    notebook.serviceUpdated = longValue();
                }
                if (name == "defaultnotebook") {
                    notebook.defaultNotebook = booleanValue();
                }
                if (name == "dirty") {
                    if (booleanValue())
                        notebookIsDirty = true;
                }
                if (name == "localnotebook") {
                    if (booleanValue())
                        notebookIsLocal = true;
                }
                if (name == "publishingpublicdescription") {
                    publishing.publicDescription = textValue();
                }
                if (name == "publishinguri") {
                    publishing.uri = textValue();
                }
                if (name == "publishingorder") {
                    //notebook->publishing.order =
                      //      NoteSortOrder.;
                    QLOG_DEBUG() << "!!!!!!!!!!!! PublishingOrder not completed in import";
                }
                if (name == "PublishingAscending") {
                    if (booleanValue())
                        publishing.ascending = true;
                    else
                        publishing.ascending = false;
                }
                if (name == "icon") {
                    //byte[] b = textValue().getBytes();   // data binary
                    //QByteArray hexData = new QByteArray(b);
                    //QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
                    //notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));
                }
                if (name == "stack") {
                    notebook.stack = textValue();
                }
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "notebook" && reader->isEndElement())
            atEnd = true;
    }
    notebook.publishing = publishing;

    // We are at the end.  We should have a valid notebook now
    NotebookTable notebookTable(global.db);

    // Check if there is a notebook by this name already.
    // If one exists, we treat this as an update
    qint32 lid = notebookTable.findByName(notebook.name);
    if (lid <= 0) {
        lid = notebookTable.getLid(notebook.guid);
    }
    if (lid <= 0) {
        notebookTable.add(lid,notebook,notebookIsDirty, notebookIsLocal);
    } else {
        qint32 oldLid = notebookTable.getLid(notebook.guid);
        if (oldLid != lid)
            notebookTable.merge(oldLid, lid);
        notebookTable.sync(lid, notebook);
//        notebookTable.updateGuid(lid, notebook.guid);
        notebookTable.setDirty(lid, notebookIsDirty);
    }
    return;
}
Esempio n. 18
0
//***********************************************************
//* Process a <note> tag
//***********************************************************
void ImportData::processNoteNode() {
    QLOG_DEBUG() << "Processing Note Node";
    Note note;
    QUuid uuid;
    QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
    note.guid = newGuid;
    NoteMetaData meta;
    bool noteIsDirty = false;

    bool atEnd = false;
    while(!atEnd) {
        QString name = reader->name().toString().toLower();
        if (name == "guid" && !reader->isEndElement() && backup) {
            note.guid = textValue();
            noteList.append(note.guid);
        }
        if (name == "updatesequencenumber" && !reader->isEndElement()) {
            note.updateSequenceNum = textValue().toLong();
        }
        if (name == "title" && !reader->isEndElement()) {
            note.title = textValue();
        }
        if (name == "created" && !reader->isEndElement()) {
            note.created = longLongValue();
        }
        if (name == "updated" && !reader->isEndElement()) {
            note.updated = longLongValue();
        }
        if (name == "deleted" && !reader->isEndElement()) {
            note.deleted = longLongValue();
        }
        if (name == "active" && !reader->isEndElement()) {
            note.active = booleanValue();
        }
        if (name == "notebookguid" && !reader->isEndElement()) {
            note.notebookGuid = textValue();
        }
        if (name == "dirty" && !reader->isEndElement()) {
            noteIsDirty = booleanValue();
        }
        if (name == "content" && !reader->isEndElement()) {
            note.content = textValue();
        }
        if (name == "titlecolor" && !reader->isEndElement()) {
            meta.setColor(intValue());
        }
        if (name == "notetags" && (createTags || backup) && !reader->isEndElement()) {
            QStringList names, guids;
            processNoteTagList(guids, names);
            QList<QString> tagGuids;
            QList<QString> tagNames;
            for (qint32 i=0; i<guids.size(); i++) {
                tagGuids.append(guids[i]);
                tagNames.append(names[i]);
            }
            note.tagNames = tagNames;
            note.tagGuids = tagGuids;
        }
        if (name == "noteattributes" && !reader->isEndElement()) {
            processNoteAttributes(note.attributes);
        }
        if (name == "noteresource" && !reader->isEndElement()) {
            Resource newRes;
            processResource(newRes);
            newRes.noteGuid = note.guid;
            if (!backup)
                newRes.updateSequenceNum = 0;
            QList<Resource> resources;
            if (note.resources.isSet())
                resources = note.resources;
            resources.append(newRes);
            note.resources = resources;
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "note" && reader->isEndElement())
            atEnd = true;
    }

    // Loop through the resources & make sure they all have the
    // proper guid for this note
    QList<Resource> resources;
    if (note.resources.isSet())
        resources = note.resources;
    for (int i=0; i<resources.size(); i++) {
        resources[i].noteGuid = note.guid;
    }
    note.resources = resources;
    NoteTable noteTable(global.db);
    if (backup)
        noteTable.add(0,note, noteIsDirty);
    else {
        note.updateSequenceNum = 0;
        if (notebookGuid != NULL)
            note.notebookGuid = notebookGuid;
        noteTable.add(0,note, true);
        if (metaData.contains(note.guid)) {
            QLOG_ERROR() << "ERROR IN IMPORTING DATA:  Metadata not yet supported";
        }
    }
    return;
}
Esempio n. 19
0
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportData::processResource(Resource &resource) {
    QLOG_DEBUG() << "Processing Resource Node";

    bool atEnd = false;
    //bool isDirty = false;

    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid") {
                resource.guid = textValue();
            }
            if (!backup) {
                QUuid uuid;
                QString g =  uuid.createUuid().toString().replace("{","").replace("}","");
                resource.guid = g;
            }
            if (name == "noteguid") {
                QString tx = textValue();
                resource.noteGuid = tx;
            }
            if (name == "updatesequencenumber") {
                resource.updateSequenceNum = intValue();
            }
            if (name == "active") {
                resource.active =  booleanValue();
            }
            if (name == "mime") {
                resource.mime = textValue();
            }
            if (name == "duration") {
                resource.duration = shortValue();
            }
            if (name == "height") {
                resource.height = shortValue();
            }
            if (name == "width") {
                resource.width = shortValue();
            }
//            if (name == "dirty")
//                isDirty = booleanValue();
            if (name == "data") {
                Data data;
                resource.data = data;
                processData("Data", resource.data);
            }
            if (name == "alternatedata") {
                processData("AlternateData", resource.data);
            }
            if (name == "recognitiondata") {
                processData("RecognitionData", resource.recognition);
            }
            if (name == "noteresourceattributes") {
                processResourceAttributes(resource.attributes);
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "noteresource" && reader->isEndElement())
            atEnd = true;
    }
}
Esempio n. 20
0
void fun_inc ()
{
    register VAR_ *dest = getdest();

    intSetValue(dest, intValue(dest) + 1);
}
bool AccessibilityUIElement::isChecked() const
{
    return intValue();
}
Esempio n. 22
0
void XmlTools::saveIntValue(int int_value, std::string section, std::string variable)
{
    coConfigInt intValue(config, QString(variable.c_str()), QString(section.c_str()));
    intValue = int_value;
    saveToXml();
}
Esempio n. 23
0
void JsonPrinter::intProperty(Print& printer, char* name, int value) {
    property(printer, name);
    intValue(printer, value);
}
Esempio n. 24
0
unsigned int HTString::uintValue() const
{
    return (unsigned int) intValue();
}
Esempio n. 25
0
static void
parse_file(FILE *f, configuration *conf)
{
    do {
        // read a line
        char *b = fgets(buffer, sizeof(buffer), f);

        if (!b) {
            break;
        }
        else if (b[0] == '#') {
            // comment - skip line
        }
        else if (b[0] == '\n') {
            // empty line
        }
        else if (matchKeyword(b, "GL_VENDOR")) {
            conf->vendor = stringValue(f, b + 10);
        }
        else if (matchKeyword(b, "GL_VERSION")) {
            conf->version = stringValue(f, b + 11);
        }
        else if (matchKeyword(b, "GL_EXTENSIONS")) {
            conf->extensions = stringValue(f, b + 14);
        }
        else if (matchKeyword(b, "GL_RENDERER")) {
            conf->renderer = stringValue(f, b + 12);
        }
        else if (matchKeyword(b, "GL_SHADING_LANGUAGE_VERSION")) {
            conf->glslVersion = stringValue(f, b + 28);
        }
        else if (matchKeyword(b, "GL_MAX_TEXTURE_SIZE")) {
            conf->maxTextureSize = intValue(f, b + 20);
        }
        else if (matchKeyword(b, "GL_MAJOR_VERSION")) {
            conf->versionMajor = intValue(f, b + 17);
        }
        else if (matchKeyword(b, "GL_MINOR_VERSION")) {
            conf->versionMinor = intValue(f, b + 17);
        }
        else if (matchKeyword(b, "GL_CONTEXT_PROFILE_MASK")) {
            char *maskStr = stringValue(f, b + 24);
            conf->profileMask = 0x0;
            if (strstr(maskStr, "GL_CONTEXT_CORE_PROFILE_BIT"))
                conf->profileMask |= GL_CONTEXT_CORE_PROFILE_BIT;
            if (strstr(maskStr, "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT"))
                conf->profileMask |= GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
            free(maskStr);
        }
        else {
            std::cerr << "Unexpected config variable: " << b << ".\n";
            break;
        }
    } while (!feof(f));

    if (conf->version) {
        // String version was specified, compute integer major/minor versions
        conf->versionMajor = conf->version[0] - '0';
        conf->versionMinor = conf->version[2] - '0';
        assert(conf->versionMajor >= 1 && conf->versionMajor <= 4);
        assert(conf->versionMinor >= 0 && conf->versionMinor <= 9);
    }
    else if (conf->versionMajor) {
        // Numeric version was specified, update the string
        if (conf->version) {
            // if version string was specified too, override it
            conf->version[0] = '0' + conf->versionMajor;
            conf->version[2] = '0' + conf->versionMinor;
        }
        else {
            // allocate new version string
            conf->version = (char *) malloc(4);
            assert(conf->version);
            conf->version[0] = '0' + conf->versionMajor;
            conf->version[1] = '.';
            conf->version[2] = '0' + conf->versionMinor;
            conf->version[3] = 0;
        }
    }

    if (conf->extensions) {
        create_extensions_list(conf);
    }
}
Esempio n. 26
0
void installElements(Phase& th, const XML_Node& phaseNode)
{
    // get the declared element names
    if (!phaseNode.hasChild("elementArray")) {
        throw CanteraError("installElements",
                           "phase xml node doesn't have \"elementArray\" XML Node");
    }
    XML_Node& elements = phaseNode.child("elementArray");
    vector<string> enames;
    getStringArray(elements, enames);

    // // element database defaults to elements.xml
    string element_database = "elements.xml";
    if (elements.hasAttrib("datasrc")) {
        element_database = elements["datasrc"];
    }

    XML_Node* doc = get_XML_File(element_database);
    XML_Node* dbe = &doc->child("ctml/elementData");

    XML_Node& root = phaseNode.root();
    XML_Node* local_db = 0;
    if (root.hasChild("ctml")) {
        if (root.child("ctml").hasChild("elementData")) {
            local_db = &root.child("ctml/elementData");
        }
    }

    for (size_t i = 0; i < enames.size(); i++) {
        // Find the element data
        XML_Node* e = 0;
        if (local_db) {
            e = local_db->findByAttr("name",enames[i]);
        }
        if (!e) {
            e = dbe->findByAttr("name",enames[i]);
        }
        if (!e) {
            throw CanteraError("addElementsFromXML","no data for element "
                               +enames[i]);
        }

        // Add the element
        doublereal weight = 0.0;
        if (e->hasAttrib("atomicWt")) {
            weight = fpValue(e->attrib("atomicWt"));
        }
        int anum = 0;
        if (e->hasAttrib("atomicNumber")) {
            anum = intValue(e->attrib("atomicNumber"));
        }
        string symbol = e->attrib("name");
        doublereal entropy298 = ENTROPY298_UNKNOWN;
        if (e->hasChild("entropy298")) {
            XML_Node& e298Node = e->child("entropy298");
            if (e298Node.hasAttrib("value")) {
                entropy298 = fpValueCheck(e298Node["value"]);
            }
        }
        if (weight != 0.0) {
            th.addElement(symbol, weight, anum, entropy298);
        } else {
            th.addElement(symbol);
        }
    }
}
Esempio n. 27
0
/* SAction::parse
 * Loads a parsed SAction definition
 *******************************************************************/
bool SAction::parse(ParseTreeNode* node)
{
	string linked_cvar;
	int custom_wxid = -1;

	for (unsigned a = 0; a < node->nChildren(); a++)
	{
		auto prop = node->getChildPTN(a);
		string prop_name = prop->getName();
		
		// Text
		if (S_CMPNOCASE(prop_name, "text"))
			text = prop->stringValue();

		// Icon
		else if (S_CMPNOCASE(prop_name, "icon"))
			icon = prop->stringValue();

		// Help Text
		else if (S_CMPNOCASE(prop_name, "help_text"))
			helptext = prop->stringValue();

		// Shortcut
		else if (S_CMPNOCASE(prop_name, "shortcut"))
			shortcut = prop->stringValue();

		// Keybind (shortcut)
		else if (S_CMPNOCASE(prop_name, "keybind"))
			shortcut = S_FMT("kb:%s", prop->stringValue());

		// Type
		else if (S_CMPNOCASE(prop_name, "type"))
		{
			string lc_type = prop->stringValue().Lower();
			if (lc_type == "check")
				type = Type::Check;
			else if (lc_type == "radio")
				type = Type::Radio;
		}

		// Linked CVar
		else if (S_CMPNOCASE(prop_name, "linked_cvar"))
			linked_cvar = prop->stringValue();

		// Custom wx id
		else if (S_CMPNOCASE(prop_name, "custom_wx_id"))
			custom_wxid = prop->intValue();

		// Reserve ids
		else if (S_CMPNOCASE(prop_name, "reserve_ids"))
			reserved_ids = prop->intValue();
	}

	// Setup wxWidgets id stuff
	if (custom_wxid == -1)
	{
		wx_id = cur_id;
		cur_id += reserved_ids;
	}
	else
		wx_id = custom_wxid;

	// Setup linked cvar
	if (type == Type::Check && !linked_cvar.IsEmpty())
	{
		auto cvar = get_cvar(linked_cvar);
		if (cvar && cvar->type == CVAR_BOOLEAN)
		{
			this->linked_cvar = (CBoolCVar*)cvar;
			checked = cvar->GetValue().Bool;
		}
	}
	
	return true;
}
Esempio n. 28
0
void importPhase(XML_Node& phase, ThermoPhase* th)
{
    // Check the the supplied XML node in fact represents a phase.
    if (phase.name() != "phase") {
        throw CanteraError("importPhase",
                           "Current const XML_Node named, " + phase.name() +
                           ", is not a phase element.");
    }

    // In this section of code, we get the reference to the phase XML tree
    // within the ThermoPhase object. Then, we clear it and fill it with the
    // current information that we are about to use to construct the object. We
    // will then be able to resurrect the information later by calling xml().
    th->setXMLdata(phase);

    // set the id attribute of the phase to the 'id' attribute in the XML tree.
    th->setID(phase.id());
    th->setName(phase.id());

    // Number of spatial dimensions. Defaults to 3 (bulk phase)
    if (phase.hasAttrib("dim")) {
        int idim = intValue(phase["dim"]);
        if (idim < 1 || idim > 3) {
            throw CanteraError("importPhase",
                               "phase, " + th->id() +
                               ", has unphysical number of dimensions: " + phase["dim"]);
        }
        th->setNDim(idim);
    } else {
        th->setNDim(3); // default
    }

    // Set equation of state parameters. The parameters are specific to each
    // subclass of ThermoPhase, so this is done by method setParametersFromXML
    // in each subclass.
    const XML_Node& eos = phase.child("thermo");
    if (phase.hasChild("thermo")) {
        th->setParametersFromXML(eos);
    } else {
        throw CanteraError("importPhase",
                           " phase, " + th->id() +
                           ", XML_Node does not have a \"thermo\" XML_Node");
    }

    VPStandardStateTP* vpss_ptr = 0;
    int ssConvention = th->standardStateConvention();
    if (ssConvention == cSS_CONVENTION_VPSS) {
        vpss_ptr = dynamic_cast <VPStandardStateTP*>(th);
        if (vpss_ptr == 0) {
            throw CanteraError("importPhase",
                               "phase, " + th->id() + ", was VPSS, but dynamic cast failed");
        }
    }

    // Add the elements.
    if (ssConvention != cSS_CONVENTION_SLAVE) {
        installElements(*th, phase);
    }

    // Add the species.
    //
    // Species definitions may be imported from multiple sources. For each one,
    // a speciesArray element must be present.
    vector<XML_Node*> sparrays = phase.getChildren("speciesArray");
    if (ssConvention != cSS_CONVENTION_SLAVE && sparrays.empty()) {
        throw CanteraError("importPhase",
                           "phase, " + th->id() + ", has zero \"speciesArray\" XML nodes.\n"
                           + " There must be at least one speciesArray nodes "
                           "with one or more species");
    }
    vector<XML_Node*> dbases;
    vector_int sprule(sparrays.size(),0);

    // Default behavior when importing from CTI/XML is for undefined elements to
    // be treated as an error
    th->throwUndefinedElements();

    // loop over the speciesArray elements
    for (size_t jsp = 0; jsp < sparrays.size(); jsp++) {
        const XML_Node& speciesArray = *sparrays[jsp];

        // If the speciesArray element has a child element
        //
        //   <skip element="undeclared">
        //
        // then set sprule[jsp] to 1, so that any species with an undeclared
        // element will be quietly skipped when importing species. Additionally,
        // if the skip node has the following attribute:
        //
        // <skip species="duplicate">
        //
        // then duplicate species names will not cause Cantera to throw an
        // exception. Instead, the duplicate entry will be discarded.
        if (speciesArray.hasChild("skip")) {
            const XML_Node& sk = speciesArray.child("skip");
            string eskip = sk["element"];
            if (eskip == "undeclared") {
                sprule[jsp] = 1;
            }
            string dskip = sk["species"];
            if (dskip == "duplicate") {
                sprule[jsp] += 10;
            }
        }

        // Get a pointer to the node containing the species definitions for the
        // species declared in this speciesArray element. This may be in the
        // local file containing the phase element, or may be in another file.
        XML_Node* db = get_XML_Node(speciesArray["datasrc"], &phase.root());
        if (db == 0) {
            throw CanteraError("importPhase()",
                               " Can not find XML node for species database: "
                               + speciesArray["datasrc"]);
        }

        // add this node to the list of species database nodes.
        dbases.push_back(db);
    }

    // Now, collect all the species names and all the XML_Node * pointers for
    // those species in a single vector. This is where we decide what species
    // are to be included in the phase. The logic is complicated enough that we
    // put it in a separate routine.
    std::vector<XML_Node*> spDataNodeList;
    std::vector<std::string> spNamesList;
    vector_int spRuleList;
    formSpeciesXMLNodeList(spDataNodeList, spNamesList, spRuleList,
                           sparrays, dbases, sprule);

    size_t nsp = spDataNodeList.size();
    if (ssConvention == cSS_CONVENTION_SLAVE && nsp > 0) {
        throw CanteraError("importPhase()", "For Slave standard states, "
            "number of species must be zero: {}", nsp);
    }
    for (size_t k = 0; k < nsp; k++) {
        XML_Node* s = spDataNodeList[k];
        AssertTrace(s != 0);
        if (spRuleList[k]) {
           th->ignoreUndefinedElements();
        }
        th->addSpecies(newSpecies(*s));
        if (vpss_ptr) {
            const XML_Node* const ss = s->findByName("standardState");
            std::string ss_model = (ss) ? ss->attrib("model") : "ideal-gas";
            unique_ptr<PDSS> kPDSS(newPDSS(ss_model));
            kPDSS->setParametersFromXML(*s);
            vpss_ptr->installPDSS(k, std::move(kPDSS));
        }
        th->saveSpeciesData(k, s);
    }

    // Done adding species. Perform any required subclass-specific
    // initialization.
    th->initThermo();

    // Perform any required subclass-specific initialization that requires the
    // XML phase object
    std::string id = "";
    th->initThermoXML(phase, id);
}
Esempio n. 29
0
 virtual void Load(void)
 {
     PlayGroupDBStorage::Load();
     if (intValue() < 50 || intValue() > 200)
         setValue(45);
 }
Esempio n. 30
0
ostream &FrInteger::printValue(ostream &output) const
{
   return output << intValue() ;
}