本文整理汇总了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;
}
示例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;
}