Parse and print CellML syntax

Parse from a CellML format file

The following code will read a file called sine_comparison.cellml and deserialise its contents into a Model instance.

Note that both the Parser class and its opposite number, the Printer class, deal with strings rather than files. You’ll need to read the file into a string, and then use the string as input to the Parser item.

Parse a model from a CellML file

    // Parse a CellML file into a model.

    // Read the file containing the CellML model into a string.
    std::string inFileName = "simulationExample.cellml";
    std::ifstream inFile(inFileName);
    std::stringstream inFileContents;
    inFileContents << inFile.rdbuf();

    std::cout << "Opening the CellML file" << std::endl;

    // Create a libCellML Parser, and use it to parse the fileContents
    // string and convert it into a CellML Model structure.
    auto parser = libcellml::Parser::create();
    auto model = parser->parseModel(inFileContents.str());
    printIssues(parser);

Full context: example_simulationToolDev.cpp