本文整理汇总了C++中py::List类的典型用法代码示例。如果您正苦于以下问题:C++ List类的具体用法?C++ List怎么用?C++ List使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPropertiesList
Py::List PropertyContainerPy::getPropertiesList(void) const
{
Py::List ret;
std::map<std::string,Property*> Map;
getPropertyContainerPtr()->getPropertyMap(Map);
for (std::map<std::string,Property*>::const_iterator It=Map.begin();It!=Map.end();++It)
ret.append(Py::String(It->first));
return ret;
}
示例2: supportedTypes
PyObject* DocumentPy::supportedTypes(PyObject *args)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
std::vector<Base::Type> ary;
Base::Type::getAllDerivedFrom(App::DocumentObject::getClassTypeId(), ary);
Py::List res;
for (std::vector<Base::Type>::iterator it = ary.begin(); it != ary.end(); ++it)
res.append(Py::String(it->getName()));
return Py::new_reference_to(res);
}
示例3: setA
void MatrixPy::setA(Py::List arg)
{
double mat[16];
this->getMatrixPtr()->getMatrix(mat);
int index=0;
for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
mat[index++] = (double)Py::Float(*it);
}
this->getMatrixPtr()->setMatrix(mat);
}
示例4: setCommands
void PathPy::setCommands(Py::List list)
{
getToolpathPtr()->clear();
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Path::CommandPy::Type))) {
Path::Command &cmd = *static_cast<Path::CommandPy*>((*it).ptr())->getCommandPtr();
getToolpathPtr()->addCommand(cmd);
} else {
throw Py::Exception("The list can only contain Path Commands");
}
}
}
示例5: getImplementedModes
Py::List AttachEnginePy::getImplementedModes(void) const
{
try {
Py::List ret;
AttachEngine &attacher = *(this->getAttachEnginePtr());
for(int imode = 0 ; imode < mmDummy_NumberOfModes ; imode++){
if(attacher.modeRefTypes[imode].size() > 0){
ret.append(Py::String(attacher.getModeName(eMapMode(imode))));
}
}
return ret;
} ATTACHERPY_STDCATCH_ATTR;
}
示例6: getPointSelection
PyObject* MeshPy::getPointSelection(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
Py::List ary;
std::vector<unsigned long> points;
getMeshObjectPtr()->getPointsFromSelection(points);
for (std::vector<unsigned long>::const_iterator it = points.begin(); it != points.end(); ++it) {
ary.append(Py::Int((int)*it));
}
return Py::new_reference_to(ary);
}
示例7: sGetVersion
PyObject* Application::sGetVersion(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
Py::List list;
const std::map<std::string, std::string>& cfg = Application::Config();
std::map<std::string, std::string>::const_iterator it;
it = cfg.find("BuildVersionMajor");
list.append(Py::String(it != cfg.end() ? it->second : ""));
it = cfg.find("BuildVersionMinor");
list.append(Py::String(it != cfg.end() ? it->second : ""));
it = cfg.find("BuildRevision");
list.append(Py::String(it != cfg.end() ? it->second : ""));
it = cfg.find("BuildRepositoryURL");
list.append(Py::String(it != cfg.end() ? it->second : ""));
it = cfg.find("BuildRevisionDate");
list.append(Py::String(it != cfg.end() ? it->second : ""));
it = cfg.find("BuildRevisionBranch");
if (it != cfg.end())
list.append(Py::String(it->second));
it = cfg.find("BuildRevisionHash");
if (it != cfg.end())
list.append(Py::String(it->second));
return Py::new_reference_to(list);
}
示例8: getSeparateComponents
PyObject* MeshPy::getSeparateComponents(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
Py::List meshesList;
std::vector<std::vector<unsigned long> > segs;
segs = getMeshObjectPtr()->getComponents();
for (unsigned int i=0; i<segs.size(); i++) {
MeshObject* mesh = getMeshObjectPtr()->meshFromSegment(segs[i]);
meshesList.append(Py::Object(new MeshPy(mesh),true));
}
return Py::new_reference_to(meshesList);
}
示例9: getInListRecursive
Py::List DocumentObjectPy::getInListRecursive(void) const
{
Py::List ret;
try {
std::vector<DocumentObject*> list = getDocumentObjectPtr()->getInListRecursive();
for (std::vector<DocumentObject*>::iterator It = list.begin(); It != list.end(); ++It)
ret.append(Py::Object((*It)->getPyObject(), true));
}
catch (const Base::Exception& e) {
throw Py::IndexError(e.what());
}
return ret;
}
示例10: getVKnotSequence
Py::List BSplineSurfacePy::getVKnotSequence(void) const
{
Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
(getGeometryPtr()->handle());
Standard_Integer m = 0;
for (int i=1; i<= surf->NbVKnots(); i++)
m += surf->VMultiplicity(i);
TColStd_Array1OfReal k(1,m);
surf->VKnotSequence(k);
Py::List list;
for (Standard_Integer i=k.Lower(); i<=k.Upper(); i++) {
list.append(Py::Float(k(i)));
}
return list;
}
示例11: generated
PyObject* BRepOffsetAPI_MakePipeShellPy::generated(PyObject *args)
{
PyObject *shape;
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->_Shape;
const TopTools_ListOfShape& list = this->getBRepOffsetAPI_MakePipeShellPtr()->Generated(s);
Py::List shapes;
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(list); it.More(); it.Next()) {
const TopoDS_Shape& s = it.Value();
shapes.append(Py::asObject(new TopoShapePy(new TopoShape(s))));
}
return Py::new_reference_to(shapes);
}
示例12: toListOfStrings
Py::List toListOfStrings( Py::Object obj )
{
Py::List list;
if( obj.isList() )
list = obj;
else
list.append( obj );
// check all members of the list are strings
for( Py::List::size_type i=0; i<list.length(); i++ )
{
Py::String path_str( list[i] );
}
return list;
}
示例13: 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;
}
示例14: getObjectsByLabel
PyObject* DocumentPy::getObjectsByLabel(PyObject *args)
{
char *sName;
if (!PyArg_ParseTuple(args, "s",&sName)) // convert args: Python->C
return NULL; // NULL triggers exception
Py::List list;
std::string name = sName;
std::vector<DocumentObject*> objs = getDocumentPtr()->getObjects();
for (std::vector<DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
if (name == (*it)->Label.getValue())
list.append(Py::asObject((*it)->getPyObject()));
}
return Py::new_reference_to(list);
}
示例15: getEditorMode
PyObject* PropertyContainerPy::getEditorMode(PyObject *args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name)) // convert args: Python->C
return NULL; // NULL triggers exception
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
Py::List ret;
if (prop) {
short Type = prop->getType();
if ((prop->testStatus(Property::ReadOnly)) || (Type & Prop_ReadOnly))
ret.append(Py::String("ReadOnly"));
if ((prop->testStatus(Property::Hidden)) || (Type & Prop_Hidden))
ret.append(Py::String("Hidden"));
}
return Py::new_reference_to(ret);
}