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


C++ List::size方法代码示例

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


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

示例1: operator

 /*!
  * @brief Format a WSGI application response as an HTTP response.
  * @param status HTTP status line (without the HTTP version)
  * @param headers a list of pairs of strings with HTTP headers
  * @param body the response body
  */
 void operator() ( const py::Bytes& status,
     const py::List& headers, const py::Bytes& body )
 {
       // Send status line.
     myStream
         << "HTTP/1.1 " << status << "\r\n";
     bool contentlength = false;
       // Send headers.
     for ( py::ssize_t i = 0; (i < headers.size()); ++i )
     {
         const py::Tuple header(headers[i]);
         const py::Bytes field(header[0]);
         const py::Bytes value(header[1]);
         if ( field == "Content-Length" ) {
             contentlength = true;
         }
         myStream
             << field << ": " << value << "\r\n";
     }
       // More headers (if desired).
     if ( !contentlength ) {
         myStream
             << "Content-Length" << ": " << body.size() << "\r\n";
     }
       // Send body.
     myStream
         << "\r\n" << body;
 }
开发者ID:AndreLouisCaron,项目名称:cxxpy,代码行数:34,代码来源:wsgi.cpp

示例2: getModeInfo

PyObject* AttachEnginePy::getModeInfo(PyObject* args)
{
    char* modeName;
    if (!PyArg_ParseTuple(args, "s", &modeName))
        return 0;

    try {
        AttachEngine &attacher = *(this->getAttachEnginePtr());
        eMapMode mmode = attacher.getModeByName(modeName);
        Py::List pyListOfCombinations;
        Py::List pyCombination;
        refTypeStringList &listOfCombinations = attacher.modeRefTypes.at(mmode);
        for(const refTypeString &combination: listOfCombinations){
            pyCombination = Py::List(combination.size());
            for(int iref = 0   ;   iref < combination.size()   ;   iref++){
                pyCombination[iref] = Py::String(AttachEngine::getRefTypeName(combination[iref]));
            }
            pyListOfCombinations.append(pyCombination);
        }
        Py::Dict ret;
        ret["ReferenceCombinations"] = pyListOfCombinations;
        ret["ModeIndex"] = Py::Int(mmode);

        try {
            Py::Module module(PyImport_ImportModule("PartGui"),true);
            if (!module.hasAttr("AttachEngineResources")) {
                // in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods)
                throw Py::RuntimeError("Gui is not up");//DeepSOIC: wanted to throw ImportError here, but it's not defined, so I don't know...
            }
            Py::Object submod(module.getAttr("AttachEngineResources"));
            Py::Callable method(submod.getAttr("getModeStrings"));
            Py::Tuple arg(2);
            arg.setItem(0, Py::String(this->getAttachEnginePtr()->getTypeId().getName()));
            arg.setItem(1, Py::Int(mmode));
            Py::List strs = method.apply(arg);
            assert(strs.size() == 2);
            ret["UserFriendlyName"] = strs[0];
            ret["BriefDocu"] = strs[1];
        } catch (Py::Exception& e) {
            if (PyErr_ExceptionMatches(PyExc_ImportError)) {
                // the GUI is not up.
                Base::Console().Warning("AttachEngine: Gui not up, so no gui-related entries in getModeInfo.\n");
                e.clear();
            } else {
                Base::Console().Warning("AttachEngine.getModeInfo: error obtaining GUI strings\n");
                e.clear();
            }
        } catch (Base::Exception &e){
            Base::Console().Warning("AttachEngine.getModeInfo: error obtaining GUI strings:");
            Base::Console().Warning(e.what());
            Base::Console().Warning("\n");
        }

        return Py::new_reference_to(ret);
    } ATTACHERPY_STDCATCH_METH;
}
开发者ID:Freemydog,项目名称:FreeCAD,代码行数:56,代码来源:AttachEnginePyImp.cpp


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