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


C++ Constant::Value方法代码示例

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


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

示例1: ReadXML

int VectorField::ReadXML(string xmlfilename)
    {
    FILE *xmlfile;
    mxml_node_t *tree;
    mxml_node_t *node;
    bool bad_attr;

    xmlfile = fopen(xmlfilename.c_str(),"r");
    if (xmlfile == NULL)
       {
       // Failed to open the file.
       cerr << "Error: Unable to open " << xmlfilename << "\n";
       exit(-1);
       }
    tree = mxmlLoadFile(NULL,xmlfile,MXML_NO_CALLBACK);
    fclose(xmlfile);
    if (tree == NULL)
        {
        cerr << "Error: Unable to load the vector field from the file " << xmlfilename << ".\n";
        cerr << "There may be an error in the XML definition of the vector field.\n";
        mxmlDelete(tree);
        exit(-1);
        }

    node = mxmlFindElement(tree,tree,"VectorField",NULL,NULL,MXML_DESCEND);
    if (node == NULL)
        {
        cerr << "Error: No VectorField element found in XML defintion.\n";
        mxmlDelete(tree);
        exit(-1);
        }
    else
        {
        bad_attr = false;
        for (int i = 0; i < node->value.element.num_attrs; ++i)
            {
            string attr = node->value.element.attrs[i].name;
            if (attr != "Name" && attr != "IndependentVariable" && attr != "Description")
                {
                cerr << "Error: The VectorField element has an unknown attribute: " << attr << endl;
                bad_attr = true;
                }
            }
        if (bad_attr)
            exit(-1);
        const char *attr;
        attr = mxmlElementGetAttr(node,"Name");
        if (attr == NULL)
            {
            cerr << "Error: The VectorField element has no Name attribute.\n";
            mxmlDelete(tree);
            exit(-1);
            }
        else
            {
            if (!isValidName(attr))
                {
                cerr << "Error: The VectorField Name \"" << attr << "\" is not valid.\n";
                mxmlDelete(tree);
                exit(-1);
                }
            string s(attr);
            Name(s);
            }
        attr = mxmlElementGetAttr(node,"Description");
        if (attr != NULL)
            {
            string s(attr);
            Description(s);
            }
        attr = mxmlElementGetAttr(node,"IndependentVariable");
        if (attr == NULL)
            IndependentVariable = "t";
        else
            {
            if (!isValidName(attr))
                {
                cerr << "Error: The VectorField IndependentVariable \"" << attr << "\" is not valid.\n";
                mxmlDelete(tree);
                exit(-1);
                }
            string s(attr);
            IndependentVariable = s;
            }
        }

    //
    // Get the constants
    //
    for (node = mxmlFindElement(tree,tree,"Constant",NULL,NULL,MXML_DESCEND);
         node != NULL;
         node = mxmlFindElement(node,tree,"Constant",NULL,NULL,MXML_DESCEND))
        {
        bad_attr = false;
        for (int i = 0; i < node->value.element.num_attrs; ++i)
            {
            string attr = node->value.element.attrs[i].name;
            if (attr != "Name" && attr != "Value" && attr != "Description" && attr != "Latex")
                {
                cerr << "Error: A Constant element has an unknown attribute: " << attr << endl;
//.........这里部分代码省略.........
开发者ID:BioinformaticsArchive,项目名称:mcmc_clib,代码行数:101,代码来源:vf_xml.cpp


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