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


C++ Listing类代码示例

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


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

示例1: Listing

void YAMLReaderImpl::onListingStart(yaml_event_t& event)
{
    if(debugTrace){
        cout << "YAMLReaderImpl::onListingStart()" << endl;
    }

    NodeInfo info;
    Listing* listing;

    const yaml_mark_t& mark = event.start_mark;

    if(!isRegularMultiListingExpected){
        listing = new Listing(mark.line, mark.column);
    } else {
        size_t level = nodeStack.size();
        if(expectedListingSizes.size() <= level){
            expectedListingSizes.resize(level + 1, 0);
        }
        const int prevSize = expectedListingSizes[level];
        listing = new Listing(mark.line, mark.column, prevSize);
    }

    listing->setFlowStyle(event.data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE);
    info.node = listing;
    nodeStack.push(info);

    if(event.data.sequence_start.anchor){
        setAnchor(listing, event.data.sequence_start.anchor, mark);
    }
}
开发者ID:s-nakaoka,项目名称:choreonoid,代码行数:30,代码来源:YAMLReader.cpp

示例2: onListingEnd

void YAMLReaderImpl::onListingEnd(yaml_event_t& event)
{
    if(debugTrace){
        cout << "YAMLReaderImpl::onListingEnd()" << endl;
    }

    if(isRegularMultiListingExpected){
        Listing* listing = static_cast<Listing*>(nodeStack.top().node.get());
        const int level = nodeStack.size() - 1;
        expectedListingSizes[level] = listing->size();
    }
    
    popNode(event);
}
开发者ID:s-nakaoka,项目名称:choreonoid,代码行数:14,代码来源:YAMLReader.cpp

示例3: if

bool LinkGroup::load(const Body& body, const Listing& linkGroupList)
{
    for(int i=0; i < linkGroupList.size(); ++i) {

        const ValueNode& node = linkGroupList[i];

        if(node.isScalar()) {
            Link* link = body.link(node.toString());
            if(!link) {
                return false;
            }
            elements.push_back(link->index());

        } else if(node.isMapping()) {
            const Mapping& group = *node.toMapping();
            LinkGroupPtr linkGroup = boost::make_shared<LinkGroup>(private_tag());
            linkGroup->setName(group["name"]);
            if(linkGroup->load(body, *group["links"].toListing())) {
                elements.push_back(linkGroup);
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    return true;
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:29,代码来源:LinkGroup.cpp

示例4: replaceDirectoryVariable

void replaceDirectoryVariable(ArchiveSharedData* shared, QString& io_pathString, const QString& varname, int pos, int len)
{
    Listing* paths = shared->directoryVariableMap->findListing(varname.toStdString());
    if(paths){
        for(int i=0; i < paths->size(); ++i){
            string vpath;
            QString replaced(io_pathString);
            replaced.replace(pos, len, paths->at(i)->toString().c_str());
            filesystem::file_status fstatus = filesystem::status(filesystem::path(replaced.toStdString()));
            if(filesystem::is_directory(fstatus) || filesystem::exists(fstatus)) {
                io_pathString = replaced;
                return;
            }
        }
    }
    MessageView::mainInstance()->putln(
        MessageView::WARNING,
        QString(_("${%1} of \"%2\" cannot be expanded !")).arg(varname).arg(io_pathString));
}
开发者ID:hattorishizuko,项目名称:choreonoid,代码行数:19,代码来源:Archive.cpp

示例5: if

void YAMLReaderImpl::addNode(ValueNode* node, yaml_event_t& event)
{
    NodeInfo& info = nodeStack.top();
    ValueNode* parent = info.node;

    if(parent->isListing()){
        Listing* listing = static_cast<Listing*>(parent);
        listing->append(node);

    } else if(parent->isMapping()){

        Mapping* mapping = static_cast<Mapping*>(parent);

        if(info.key == "<<"){
            if(node->isMapping()){
                mapping->insert(static_cast<Mapping*>(node));
            } else if(node->isListing()){
                Listing* listing = static_cast<Listing*>(node);
                for(auto& element : *listing){
                    if(element->isMapping()){
                        mapping->insert(static_cast<Mapping*>(element.get()));
                    } else {
                        ValueNode::SyntaxException ex;
                        ex.setMessage(_("An element to merge by the \"<<\" key must be a mapping"));
                        const yaml_mark_t& start_mark = event.start_mark;
                        ex.setPosition(start_mark.line, start_mark.column);
                        throw ex;
                    }
                }
            } else {
                ValueNode::SyntaxException ex;
                ex.setMessage(_("A value to merge by the \"<<\" key must be mapping or listing"));
                const yaml_mark_t& start_mark = event.start_mark;
                ex.setPosition(start_mark.line, start_mark.column);
                throw ex;
            }
        }
        
        mapping->insert(info.key, node);
        info.key.clear();
    }
}
开发者ID:s-nakaoka,项目名称:choreonoid,代码行数:42,代码来源:YAMLReader.cpp

示例6: storeSplitterState

MappingPtr ViewAreaImpl::storeSplitterState(QSplitter* splitter, Archive* archive)
{
    MappingPtr state = new Mapping;

    ListingPtr children = new Listing;

    for(int i=0; i < splitter->count(); ++i){
        QSplitter* childSplitter = dynamic_cast<QSplitter*>(splitter->widget(i));
        if(childSplitter){
            MappingPtr childState = storeSplitterState(childSplitter, archive);
            if(childState){
                children->append(childState);
            }
        } else {
            ViewPane* pane = dynamic_cast<ViewPane*>(splitter->widget(i));
            if(pane && pane->count() > 0){
                MappingPtr childState = storePaneState(pane, archive);
                if(childState){
                    children->append(childState);
                }
            }
        }
    }

    const int numChildren = children->size();
    if(numChildren == 0){
        state.reset();
    } else if(numChildren == 1){
        state = children->at(0)->toMapping();
    } else if(numChildren == 2){
        state->write("type", "splitter");
        state->write("orientation", (splitter->orientation() == Qt::Vertical) ? "vertical" : "horizontal");
        Listing* sizeSeq = state->createFlowStyleListing("sizes");
        QList<int> sizes = splitter->sizes();
        for(int i=0; i < sizes.size(); ++i){
            sizeSeq->append(sizes[i]);
        }
        state->insert("children", children);
    }

    return state;
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:42,代码来源:ViewArea.cpp

示例7: replaced

bool ParametricPathProcessorImpl::replaceDirectoryVariable
(QString& io_pathString, const string& varname, int pos, int len)
{
    Listing* paths = variables->findListing(varname);
    if(paths) {
        for(int i=0; i < paths->size(); ++i) {
            string vpath;
            QString replaced(io_pathString);
            replaced.replace(pos, len, paths->at(i)->toString().c_str());
            filesystem::file_status fstatus = filesystem::status(filesystem::path(replaced.toStdString()));
            if(filesystem::is_directory(fstatus) || filesystem::exists(fstatus)) {
                io_pathString = replaced;
                return true;
            }
        }
    }

    errorMessage = str(format(_("%1% of \"%2%\" cannot be expanded !")) % varname % io_pathString.toStdString());
    return false;
}
开发者ID:hattorishizuko,项目名称:choreonoid,代码行数:20,代码来源:ParametricPathProcessor.cpp

示例8: write

bool BodyItemImpl::store(Archive& archive)
{
    archive.setDoubleFormat("% .6f");

    archive.writeRelocatablePath("modelFile", self->filePath());
    archive.write("currentBaseLink", (currentBaseLink ? currentBaseLink->name() : ""), DOUBLE_QUOTED);

    /// \todo Improve the following for current / initial position representations
    write(archive, "rootPosition", body->rootLink()->p());
    write(archive, "rootAttitude", Matrix3(body->rootLink()->R()));
    Listing* qs = archive.createFlowStyleListing("jointPositions");
    int n = body->numJoints();
    for(int i=0; i < n; ++i){
        qs->append(body->joint(i)->q(), 10, n);
    }

    //! \todo replace the following code with the ValueTree serialization function of BodyState
    SE3 initialRootPosition;
    if(initialState.getRootLinkPosition(initialRootPosition)){
        write(archive, "initialRootPosition", initialRootPosition.translation());
        write(archive, "initialRootAttitude", Matrix3(initialRootPosition.rotation()));
    }
    BodyState::Data& initialJointPositions = initialState.data(BodyState::JOINT_POSITIONS);
    if(!initialJointPositions.empty()){
        qs = archive.createFlowStyleListing("initialJointPositions");
        for(int i=0; i < initialJointPositions.size(); ++i){
            qs->append(initialJointPositions[i], 10, n);
        }
    }

    write(archive, "zmp", zmp);

    if(isOriginalModelStatic != body->isStaticModel()){
        archive.write("staticModel", body->isStaticModel());
    }

    archive.write("selfCollisionDetection", isSelfCollisionDetectionEnabled);
    archive.write("isEditable", isEditable);

    return true;
}
开发者ID:orikuma,项目名称:choreonoid,代码行数:41,代码来源:BodyItem.cpp

示例9: dirPath

/**
   \todo Introduce a tree structure to improve the efficiency of searching matched directories
*/
bool ParametricPathProcessorImpl::findSubDirectoryOfDirectoryVariable
(const filesystem::path& path, std::string& out_varName, filesystem::path& out_relativePath)
{
    out_relativePath.clear();
    int maxMatchSize = 0;
    filesystem::path relativePath;
    Mapping::const_iterator p;
    for(p = variables->begin(); p != variables->end(); ++p) {
        Listing* paths = p->second->toListing();
        if(paths) {
            for(int i=0; i < paths->size(); ++i) {
                filesystem::path dirPath(paths->at(i)->toString());
                int n = findSubDirectory(dirPath, path, relativePath);
                if(n > maxMatchSize) {
                    maxMatchSize = n;
                    out_relativePath = relativePath;
                    out_varName = fromUTF8(p->first);
                }
            }
        }
    }
    return (maxMatchSize > 0);
}
开发者ID:hattorishizuko,项目名称:choreonoid,代码行数:26,代码来源:ParametricPathProcessor.cpp

示例10: Mapping

MappingPtr ViewAreaImpl::storePaneState(ViewPane* pane, Archive* archive)
{
    MappingPtr state = new Mapping();
    
    state->write("type", "pane");
    
    Listing* views = state->createFlowStyleListing("views");
    const int n = pane->count();
    for(int i=0; i < n; ++i){
        View* view = pane->view(i);
        int id = archive->getViewId(view);
        if(id >= 0){
            views->append(id);
            if(i == pane->currentIndex()){
                state->write("current", id);
            }
        }
    }
    if(views->empty()){
        state.reset();
    }
    return state;
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:23,代码来源:ViewArea.cpp

示例11: err

Error Console::printSource(int n) {

	Error* error = nullptr;
	Listing *listing = CONTROLLER->getListing(error);
	Error err(*error);
	delete error;

	if (err.getErrorLevel() == SUCCESS || err.getErrorLevel() == WARNING) {
		Common::Array<ListingLine> lines = listing->getLines(CONTROLLER->getLastLine(), n/2, n/2);
		for (uint i = 0; i < lines.size(); i++) {
			if (lines[i].number == CONTROLLER->getLastLine()) {
				debugPrintf(" -> ");
			} else {
				debugPrintf("    ");
			}
			debugPrintf("%d", lines[i].number);
			debugPrintf("%s", lines[i].text.c_str());
			debugPrintf("\n");
		}
	}

	delete listing;
	return err;
}
开发者ID:86400,项目名称:scummvm,代码行数:24,代码来源:debugger.cpp

示例12: readAffine3

static void readAffine3(const Listing& node, Affine3& out_value)
{
    if(node.size() == 6){

        Affine3::TranslationPart t = out_value.translation();
        t[0] = node[0].toDouble();
        t[1] = node[1].toDouble();
        t[2] = node[2].toDouble();

        const double r = node[3].toDouble();
        const double p = node[4].toDouble();
        const double y = node[5].toDouble();
        
        out_value.linear() = rotFromRpy(r, p, y);
    }
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:16,代码来源:MultiAffine3Seq.cpp

示例13: list_combined

static void
list_combined(const SqlDatabase::TransactionPtr &tx, int func_id, bool show_assembly)
{
    CloneDetection::FilesTable files(tx);

    Events events;
    gather_events(tx, func_id);
    load_events(tx, func_id, events/*out*/);
    gather_instructions(tx, func_id, events);

    Listing listing;
    gather_source_code(tx);
    load_source_code(tx, listing/*out*/);

    // Get lines of assembly code and insert them into the correct place in the Listing.
    if (show_assembly) {
        SqlDatabase::StatementPtr stmt = tx->statement("select"
                                                       // 0                1              2              3
                                                       " insn.src_file_id, insn.src_line, insn.position, insn.address,"
                                                       // 4             5        6
                                                       " insn.assembly, func.id, func.name"
                                                       " from tmp_insns as insn"
                                                       " join semantic_functions as func on insn.func_id = func.id"
                                                       " order by position");
        for (SqlDatabase::Statement::iterator row=stmt->begin(); row!=stmt->end(); ++row) {
            int src_file_id = row.get<int>(0);
            int src_line_num = row.get<int>(1);
            SourcePosition srcpos(src_file_id, src_line_num);
            int pos = row.get<int>(2);
            rose_addr_t addr = row.get<rose_addr_t>(3);
            std::string assembly = row.get<std::string>(4);
            int func_id = row.get<int>(5);
            std::string func_name = row.get<std::string>(6);
            listing[srcpos].assembly_code.insert(std::make_pair(addr, AssemblyCode(pos, addr, assembly, func_id, func_name)));
        }

        // Listing header
        std::cout <<"WARNING: This listing should be read cautiously. It is ordered according to the\n"
                  <<"         source code with assembly lines following the source code line from which\n"
                  <<"         they came.  However, the compiler does not always generate machine\n"
                  <<"         instructions in the same order as source code.  When a discontinuity\n"
                  <<"         occurs in the assembly instruction listing, it will be marked by a \"#\"\n"
                  <<"         character.  The assembly instructions are also numbered according to\n"
                  <<"         their relative positions in the binary function.\n"
                  <<"\n"
                  <<"         The prefix area contains either source location information or test trace\n"
                  <<"         information.  Note that trace information might be incomplete because\n"
                  <<"         tracing was disabled or only partially enabled, or the trace includes\n"
                  <<"         instructions that are not present in this function listing (e.g., when\n"
                  <<"         execution follows a CALL instruction). The following notes are possible:\n"
                  <<"           * \"Nx\" where N is an integer indicates that this instruction\n"
                  <<"             was reached N times during testing.  These notes are typically\n"
                  <<"             only attached to the first instruction of a basic block and only\n"
                  <<"             if the trace contains EV_REACHED events.  Lack of an Nx notation\n"
                  <<"             doesn't necessarily mean that the basic block was not reached, it\n"
                  <<"             only means that there is no EV_REACHED event for that block.\n"
                  <<"           * \"N<\" where N is an integer indicates that the instruction\n"
                  <<"             on the previous line consumed N inputs. Information about the\n"
                  <<"             inputs is listed on the right side of this line.\n"
                  <<"           * \"N>\" where N is an integer indicates that the instruction\n"
                  <<"             on the previous line produced N memory outputs. Information about the\n"
                  <<"             outputs is listed on the right side of this line. Only the final\n"
                  <<"             write to a memory address is considered a true output, and such\n"
                  <<"             writes will be marked with the string \"final\".\n"
                  <<"           * \"BR\" indicates that the instruction on the previous line is a\n"
                  <<"             control flow branch point. The right side of the line shows more\n"
                  <<"             detailed information about how many times the branch was taken.\n"
                  <<"           * \"FAULT\" indicates that the test was terminated at the previous\n"
                  <<"             instruction. The right side of the line shows the distribution of\n"
                  <<"             faults that occurred here.\n"
                  <<"\n"
                  <<"                /------------- Prefix area\n"
                  <<" /-------------/-------------- Source file ID or assembly function ID\n"
                  <<" |     /------/--------------- Source line number or assembly instruction index\n"
                  <<" |     |   /-/---------------- Instruction out-of-order indicator\n"
                  <<" |     |   |/     /----------- Instruction virtual address\n"
                  <<" |     |   |      |\n"
                  <<"vvvv vvvvv/|      |\n"
                  <<"vvvvvvvvvv v vvvvvvvvvv\n";
    }

    // Show the listing
    int prev_func_id = -1, prev_position = -1;
    std::set<int> seen_files;
    for (Listing::iterator li=listing.begin(); li!=listing.end(); ++li) {
        int file_id = li->first.file_id;
        if (seen_files.insert(file_id).second) {
            if (file_id>=0) {
                std::cout <<"\n" <<std::setw(4) <<std::right <<file_id <<".file  |"
                          <<(opt.colorize?"\033[33;4m":"") <<files.name(file_id) <<(opt.colorize?"\033[m":"") <<"\n";
            } else {
                std::cout <<"\n" <<std::string(11, ' ') <<"|"
                          <<(opt.colorize?"\033[33;4m":"") <<"instructions not associated with a source file"
                          <<(opt.colorize?"\033[m":"") <<"\n";
            }
        }
        if (file_id>=0) {
            std::cout <<std::setw(4) <<std::right <<file_id <<"." <<std::setw(6) <<std::left <<li->first.line_num
                      <<"|"
                      <<(opt.colorize?"\033[34m":"")
//.........这里部分代码省略.........
开发者ID:matzke1,项目名称:rose-develop,代码行数:101,代码来源:90-list-function.C

示例14: internalConfig

int AsmMain::Run(int argc, char *argv[])
{
    int rv = 0;
    Utils::banner(argv[0]);
    CmdSwitchFile internalConfig(SwitchParser);
    std::string configName = Utils::QualifiedFile(argv[0], ".cfg");
    std::fstream configTest(configName.c_str(), std::ios::in);
    if (configTest != NULL)
    {
        configTest.close();
        if (!internalConfig.Parse(configName.c_str()))
            Utils::fatal("Corrupt configuration file");
    }
    if (!SwitchParser.Parse(&argc, argv) || (argc == 1 && File.GetCount() <= 1))
    {
        Utils::usage(argv[0], usageText);
    }
    CmdFiles files(argv+1);
    if (File.GetValue())
        files.Add(File.GetValue() + 1);
    if (files.GetSize() > 1 && OutputFile.GetValue().size())
        Utils::fatal("Cannot specify output file for multiple input files");
    std::string sysSrchPth;
    std::string srchPth;
    if (includePath.GetValue().size())
    {
        size_t n = includePath.GetValue().find_first_of(';');
        if (n == std::string::npos)
        {
            sysSrchPth = includePath.GetValue();
        }
        else
        {
            sysSrchPth = includePath.GetValue().substr(0, n);
            srchPth = includePath.GetValue().substr(n+1);
        }
    }
    for (CmdFiles::FileNameIterator it = files.FileNameBegin(); it != files.FileNameEnd(); ++it)
    {
        std::string inName = (*it)->c_str();
        int npos = inName.find_last_of(".");
        if (npos == std::string::npos || npos && inName[npos-1] == '.' || (npos != inName.size()-1 && inName[npos+1] == CmdFiles::DIR_SEP[0]))
        {
            inName = Utils::QualifiedFile( (*it)->c_str(), ".asm");
        }
        PreProcessor pp(inName, srchPth, sysSrchPth,
                 false, false, '%', false, false, true);
        int n = Defines.GetCount();
        for (int i=0; i < n; i++)
        {
            CmdSwitchDefine::define *v = Defines.GetValue(i);
            pp.Define(v->name, v->value, false);
        }
        std::string outName;
        if (OutputFile.GetValue().size() != 0)
            outName = OutputFile.GetValue();
        else
            outName = Utils::QualifiedFile( (*it)->c_str(), ".o");
        if (PreprocessOnly.GetValue())
        {
            std::string working = Utils::QualifiedFile((*it)->c_str(), ".i");
            std::fstream out(working.c_str(), std::ios::out);
            if (out == NULL)
            {
                Utils::fatal(std::string(std::string("Could not open ") + working.c_str() + " for write.").c_str());
            }
            else
            {
                while (pp.GetLine(working))
                {
                    CheckAssign(working, pp);
                    out << working << std::endl;
                }
            }
            out.close();
        }
        else
        {
            Listing listing;
            AsmFile asmFile(pp, CaseInsensitive.GetValue(), listing);
            if (asmFile.Read())
            {
                if (!asmFile.Write(outName, inName) || Errors::ErrorCount())
                {
                    rv = 1;
                }
                else if (CreateListFile.GetValue())
                {
                    std::string listingName = Utils::QualifiedFile( (*it)->c_str(), ".lst");
                    if (!listing.Write(listingName, inName, CreateListFile.GetValue('m')))
                    {
                        rv = 1;
                    }
                }
            }
            else
            {
                rv = 1;
            }
        if (rv)
//.........这里部分代码省略.........
开发者ID:doniexun,项目名称:OrangeC,代码行数:101,代码来源:AsmMain.cpp

示例15: load

bool BodyItemImpl::restore(const Archive& archive)
{
    bool restored = false;
    
    string modelFile;
    /*
      if(archive.readRelocatablePath("modelFile", modelFile)){
      restored = modelFile.empty() || load(modelFile);
      }
    */
    if(archive.readRelocatablePath("modelFile", modelFile)){
        restored = self->load(modelFile);
    }

    if(restored){

        Vector3 p;
        if(read(archive, "rootPosition", p)){
            body->rootLink()->p() = p;
        }
        Matrix3 R;
        if(read(archive, "rootAttitude", R)){
            body->rootLink()->R() = R;
        }
        Listing* qs = archive.findListing("jointPositions");
        if(qs->isValid()){
            for(int i=0; i < qs->size(); ++i){
                body->joint(i)->q() = (*qs)[i].toDouble();
            }
        }

        //! \todo replace the following code with the ValueTree serialization function of BodyState
        initialState.clear();

        if(read(archive, "initialRootPosition", p) && read(archive, "initialRootAttitude", R)){
            initialState.setRootLinkPosition(SE3(p, R));
        }
        qs = archive.findListing("initialJointPositions");
        if(qs->isValid()){
            BodyState::Data& q = initialState.data(BodyState::JOINT_POSITIONS);
            q.resize(qs->size());
            for(int i=0; i < qs->size(); ++i){
                q[i] = (*qs)[i].toDouble();
            }
        }

        read(archive, "zmp", zmp);
        
        body->calcForwardKinematics();
        setCurrentBaseLink(body->link(archive.get("currentBaseLink", "")));

        bool staticModel;
        if(archive.read("staticModel", staticModel)){
            onStaticModelPropertyChanged(staticModel);
        }

        archive.read("selfCollisionDetection", isSelfCollisionDetectionEnabled);
        archive.read("isEditable", isEditable);

        self->notifyKinematicStateChange();
    }

    return restored;
}
开发者ID:orikuma,项目名称:choreonoid,代码行数:64,代码来源:BodyItem.cpp


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