Beispiel #1
0
void BinaryVtkFile::writeFile(const std::string & baseFileName)
{
    const std::string nl("\n");
    const boost::regex pattern("\n");
    const std::string replaceFormat = nl + std::string(indent_l3);
    std::string pointData = concatenateFields();
    char buffer[50];
    sprintf(buffer, "%s_node%05d.vtr", baseFileName.c_str(), Ippl::myNode());
    std::string headerFileName = baseFileName + std::string(".pvtr");
    std::ofstream out(buffer);

    out << indent_l0 << _header
        << indent_l1 << "<RectilinearGrid WholeExtent=" << _localGridExtent << ">" << "\n"
        << indent_l2 << "<Piece Extent=" << _localGridExtent << ">\n"
        << indent_l3 << boost::regex_replace(pointData, pattern, replaceFormat) << "\n"
        << indent_l3 << boost::regex_replace(_coordinates, pattern, replaceFormat) << "\n"
        << indent_l2 << "</Piece>\n"
        << indent_l1 << "</RectilinearGrid>\n"
        << indent_l1 << "<AppendedData encoding=\"raw\">\n"
        << indent_l2 << "_";
    out.write(&(_data[0]), _data.size());
    out << nl
        << indent_l1 << "</AppendedData>\n"
        << indent_l0 << "</VTKFile>" << std::endl;
    out.close();

    writeHeaderFile(baseFileName);
}
Beispiel #2
0
void MetaInfoGenerator::generate()
{
    buildSkipList();
    writeCppFile();
    writeHeaderFile();
    writeLibraryInitializers();
}
Beispiel #3
0
void TclWriter::writeClass(UMLClassifier * c)
{
    if (!c) {
        uDebug() << "Cannot write class of NULL concept!";
        return;
    }
    QFile fileh, filetcl;

    // find an appropriate name for our file
    fileName_ = findFileName(c, ".tcl");
    if (fileName_.isEmpty()) {
        emit codeGenerated(c, false);
        return;
    }

    if (!openFile(fileh, fileName_)) {
        emit codeGenerated(c, false);
        return;
    }
    // preparations
    className_ = cleanName(c->name());
    if (!c->package().isEmpty()) {
        mNamespace = "::" + cleanName(c->package());
        mClassGlobal = mNamespace + "::" + className_;
    } else {
        mNamespace = "::";
        mClassGlobal = "::" + className_;
    }

    // write Header file
    writeHeaderFile(c, fileh);
    fileh.close();

    // Determine whether the implementation file is required.
    // (It is not required if the class is an enumeration.)
    bool need_impl = true;
    if (!c->isInterface()) {
        if (c->baseType() == UMLObject::ot_Enum)
            need_impl = false;
    }
    if (need_impl) {
        if (!openFile(filetcl, fileName_ + "body")) {
            emit codeGenerated(c, false);
            return;
        }
        // write Source file
        writeSourceFile(c, filetcl);
        filetcl.close();
    }
    // emit done code
    emit codeGenerated(c, true);
}
Beispiel #4
0
/**
 * Call this method to generate cpp code for a UMLClassifier.
 * @param c   the class to generate code for
 */
void CppWriter::writeClass(UMLClassifier *c)
{
    if (!c) {
        uDebug() << "Cannot write class of NULL concept!";
        return;
    }

    QFile fileh, filecpp;

    // find an appropriate name for our file
    fileName_ = findFileName(c, ".h");
    if (fileName_.isEmpty()) {
        emit codeGenerated(c, false);
        return;
    }

    className_ = cleanName(c->name());

    if (c->visibility() != Uml::Visibility::Implementation) {
        if( !openFile(fileh, fileName_)) {
            emit codeGenerated(c, false);
            return;
        }
        // write Header file
        writeHeaderFile(c, fileh);
        fileh.close();
    }

    // Determine whether the implementation file is required.
    // (It is not required if the class is an enumeration.)
    bool need_impl = true;
    if (c->baseType() == Uml::ot_Enum) {
        need_impl = false;
    }
    if (need_impl) {
        fileName_.replace( QRegExp(".h$"), ".cpp");
        if( !openFile(filecpp, fileName_)) {
            emit codeGenerated(c, false);
            return;
        }
        // write Source file
        writeSourceFile(c, filecpp);
        filecpp.close();
    }

    emit codeGenerated(c, true);
}