当前位置: 首页>>代码示例>>C++>>正文


C++ ObjRef::URI方法代码示例

本文整理汇总了C++中ObjRef::URI方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjRef::URI方法的具体用法?C++ ObjRef::URI怎么用?C++ ObjRef::URI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjRef的用法示例。


在下文中一共展示了ObjRef::URI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mId

CellmlFileRdfTripleElement::CellmlFileRdfTripleElement(iface::rdf_api::Node *pRdfNode) :
    mId(QString()),
    mUriReference(QString()),
    mLexicalForm(QString()),
    mLanguage(QString()),
    mDataTypeUri(QString())
{
    // Check which interface is supported by the node and initialise it in case
    // it supports the rdf_api::URIReference, rdf_api::PlainLiteral or
    // rdf_api::TypedLiteral interface

    ObjRef<iface::rdf_api::URIReference> uriReference = QueryInterface(pRdfNode);

    if (uriReference) {
        // The rdf_api::URIReference interface is supported, so initialise the
        // triple element using that interface

        mType = UriReference;

        mUriReference = QString::fromStdWString(uriReference->URI()).trimmed();
    } else {
        ObjRef<iface::rdf_api::PlainLiteral> plainLiteral = QueryInterface(pRdfNode);

        if (plainLiteral) {
            // The rdf_api::PlainLiteral interface is supported, so initialise
            // the triple element using that interface

            mType = PlainLiteral;

            mLexicalForm = QString::fromStdWString(plainLiteral->lexicalForm()).trimmed();
            mLanguage    = QString::fromStdWString(plainLiteral->language()).trimmed();
        } else {
            ObjRef<iface::rdf_api::TypedLiteral> typedLiteral = QueryInterface(pRdfNode);

            if (typedLiteral) {
                // The rdf_api::TypedLiteral interface is supported, so
                // initialise the triple element using that interface

                mType = TypedLiteral;

                mLexicalForm = QString::fromStdWString(typedLiteral->lexicalForm()).trimmed();
                mDataTypeUri = QString::fromStdWString(typedLiteral->datatypeURI()).trimmed();
            } else {
                // The node doesn't support any interface, so initialise the
                // triple element using its id
                // Note: the id returned by the CellML API will look something
                //       like
                //
                //          7EQ?;?Y?A?w???A
                //
                //       This is clearly not user-friendly, so we generate and
                //       use our own id instead...

                static QMap<QString, QString> ids;
                static int counter = 0;

                QString id = QString::fromStdString(pRdfNode->objid()).trimmed();

                mType = Id;

                mId = ids.value(id);

                if (mId == QString()) {
                    // There is no id value for the current id, so generate one
                    // and keep track of it

                    mId = QString("id_%1").arg(++counter, 9, 10, QChar('0'));

                    ids.insert(id, mId);
                }
            }
        }
    }

    // Keep track of the RDF triple element's value as a string, which is based
    // on its type

    switch (mType) {
    case UriReference:
        mAsString = mUriReference;

        break;
    case PlainLiteral:
        mAsString = mLexicalForm+" ["+mLanguage+"]";

        break;
    case TypedLiteral:
        mAsString = mLexicalForm+" ["+mDataTypeUri+"]";

        break;
    default:
        // Id

        mAsString = mId;
    }
}
开发者ID:hsorby,项目名称:opencor,代码行数:96,代码来源:cellmlfilerdftripleelement.cpp


注:本文中的ObjRef::URI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。