本文整理汇总了C++中boost::python::list类的典型用法代码示例。如果您正苦于以下问题:C++ list类的具体用法?C++ list怎么用?C++ list使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了list类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ControllerData
ControllerData(const sixenseControllerData& data)
{
for(int i = 0; i < 3; ++i)
{
pos.append(data.pos[i]);
}
for(int y = 0; y < 3; ++y)
{
boost::python::list col;
for(int x = 0; x < 3; ++x)
{
col.append(data.rot_mat[y][x]);
}
rot_mat.append(col);
}
joystick_x = data.joystick_x;
joystick_y = data.joystick_y;
trigger = data.trigger;
buttons = data.buttons;
sequence_number = data.sequence_number;
for(int i = 0; i < 4; ++i)
{
rot_quat.append(data.rot_quat[i]);
}
firmware_revision = data.firmware_revision;
hardware_revision = data.hardware_revision;
packet_type = data.packet_type;
magnetic_frequency = data.magnetic_frequency;
enabled = data.enabled == 1;
controller_index = data.controller_index;
is_docked = data.is_docked == 1;
which_hand = data.which_hand;
}
开发者ID:mrwonko,项目名称:PySixense,代码行数:33,代码来源:dllmain.cpp
示例2: open
bool PythonSignal::open(boost::python::list macAddress) {
BOOST_VERIFY(mpSignal != 0);
uint8_t mac[6] = {0,0,0,0,0,0};
if(boost::python::extract<size_t>(macAddress.attr("__len__")()) >= 6) {
for (int i = 5; i >= 0; i--) {
mac[i] = boost::python::extract<uint8_t>(macAddress.pop());
}
}
return mpSignal->open(mac);
}
开发者ID:NeuralProsthesisLab,项目名称:unlock,代码行数:10,代码来源:PythonSignal.cpp
示例3: periodise_wrap
int periodise_wrap(boost::python::list args ) {
int iSize = extract<int> (args.attr("__len__")()),
iIb ;
char ** argv = new char*[iSize+1] ;
#define NOM "periodise"
argv[0] = new char[strlen(NOM)+1] ;
strcpy (argv[0], NOM);
for (iIb=0; iIb < iSize ; iIb ++) {
const char * pcArg ;
extract <const char*> earg(args[iIb]);
if (earg.check()) {
pcArg= earg() ;
argv[iIb+1] = new char[strlen(pcArg)+1] ;
strcpy (argv[iIb+1], pcArg);
}
}
int result = periodise (iSize+1, argv ) ;
for (iIb = 0 ; iIb < iSize ;iIb ++) {
delete [] argv[iIb] ;
}
delete [](argv) ;
return result ;
}
开发者ID:openalea-incubator,项目名称:caribu,代码行数:28,代码来源:periodise2py.cpp
示例4: insert
inline void json::insert(const json::key_type& k, const boost::python::list& li) {
unsigned n = boost::python::extract<unsigned>(li.attr("__len__")());
if(!n) return;
jsonvec jv;
for(unsigned i=0;i<n;++i) {
try {
qm_real v = boost::python::extract<qm_real>(li[i]);
jv.add(v);
}
catch(...) {
try {
qm_string s = boost::python::extract<qm_string>(li[i]);
jv.add(s);
}
catch(...) {
try {
json js(*boost::python::extract<json*>(li[i]));
jv.add(js);
}
catch(...) {
QM_FAIL("Could not add list");
}
}
}
}
this->insert(k,jv);
}
开发者ID:algotrust,项目名称:qmlib,代码行数:27,代码来源:json_wrap.cpp
示例5: grid2utf
void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order)
{
using keys_type = std::map< typename T::lookup_type, typename T::value_type>;
using keys_iterator = typename keys_type::iterator;
typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
typename T::feature_key_type::const_iterator feature_pos;
keys_type keys;
// start counting at utf8 codepoint 32, aka space character
std::uint16_t codepoint = 32;
std::size_t array_size = data.width();
for (std::size_t y = 0; y < data.height(); ++y)
{
std::uint16_t idx = 0;
const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
typename T::value_type const* row = data.get_row(y);
for (std::size_t x = 0; x < data.width(); ++x)
{
typename T::value_type feature_id = row[x];
feature_pos = feature_keys.find(feature_id);
if (feature_pos != feature_keys.end())
{
mapnik::grid::lookup_type val = feature_pos->second;
keys_iterator key_pos = keys.find(val);
if (key_pos == keys.end())
{
// Create a new entry for this key. Skip the codepoints that
// can't be encoded directly in JSON.
if (codepoint == 34) ++codepoint; // Skip "
else if (codepoint == 92) ++codepoint; // Skip backslash
if (feature_id == mapnik::grid::base_mask)
{
keys[""] = codepoint;
key_order.push_back("");
}
else
{
keys[val] = codepoint;
key_order.push_back(val);
}
line[idx++] = static_cast<Py_UNICODE>(codepoint);
++codepoint;
}
else
{
line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
}
}
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
开发者ID:davenquinn,项目名称:python-mapnik,代码行数:60,代码来源:python_grid_utils.cpp
示例6: grid2utf2
void grid2utf2(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
{
using keys_type = std::map< typename T::lookup_type, typename T::value_type>;
using keys_iterator = typename keys_type::const_iterator;
typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
typename T::feature_key_type::const_iterator feature_pos;
keys_type keys;
// start counting at utf8 codepoint 32, aka space character
uint16_t codepoint = 32;
mapnik::grid::data_type target(data.width()/resolution,data.height()/resolution);
mapnik::scale_grid(target,grid_type.data(),0.0,0.0);
unsigned array_size = target.width();
for (unsigned y = 0; y < target.height(); ++y)
{
uint16_t idx = 0;
const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
mapnik::grid::value_type * row = target.getRow(y);
unsigned x;
for (x = 0; x < target.width(); ++x)
{
feature_pos = feature_keys.find(row[x]);
if (feature_pos != feature_keys.end())
{
mapnik::grid::lookup_type val = feature_pos->second;
keys_iterator key_pos = keys.find(val);
if (key_pos == keys.end())
{
// Create a new entry for this key. Skip the codepoints that
// can't be encoded directly in JSON.
if (codepoint == 34) ++codepoint; // Skip "
else if (codepoint == 92) ++codepoint; // Skip backslash
keys[val] = codepoint;
key_order.push_back(val);
line[idx++] = static_cast<Py_UNICODE>(codepoint);
++codepoint;
}
else
{
line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
}
}
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
开发者ID:Jiangyangyang,项目名称:mapnik,代码行数:56,代码来源:python_grid_utils.cpp
示例7: ObjToVector
Array<double,1>* ObjToVector (const list& list)
{
int len = boost::python::extract<int>(list.attr("__len__")());/**< Get the list length */
Array<double,1>* vector = new Array<double,1>(len);
for (int i = 0; i < len; i++)
{
(*vector)(i) = (boost::python::extract<int>(list[i]));
}
return vector;
}
开发者ID:Guyome,项目名称:Lss,代码行数:10,代码来源:objConv.cpp
示例8: mpi_init
bool mpi_init(boost::python::list python_argv)
{
using boost::python::extract;
using boost::python::object;
// If already initialized, do nothing but note that initialization
// is done.
int flag = 0;
int result = MPI_Initialized(&flag);
assert(result == MPI_SUCCESS);
if (flag) return false;
// Convert Python argv into C-style argc/argv. Ewwwww!
int my_argc = extract<int>(python_argv.attr("__len__")());
char** my_argv = new char*[my_argc];
for (int arg = 0; arg < my_argc; ++arg)
my_argv[arg] = strdup(extract<const char*>(python_argv[arg]));
// Initialize MPI
int mpi_argc = my_argc;
char** mpi_argv = my_argv;
result = MPI_Init(&mpi_argc, &mpi_argv);
assert(result == MPI_SUCCESS);
// If anything changed, convert C-style argc/argv into Python argv
if (mpi_argv != my_argv) {
// Tear down Python argv
while (int(extract<int>(python_argv.attr("__len__")())) > 0)
python_argv.pop();
// Build up new Python argv
for (int arg = 0; arg < mpi_argc; ++arg)
python_argv.append(object(mpi_argv[arg]));
}
for (int arg = 0; arg < my_argc; ++arg)
free(my_argv[arg]);
delete [] my_argv;
return true;
}
开发者ID:erwinvaneijk,项目名称:bgl-python,代码行数:41,代码来源:mpi.cpp
示例9: setPlotTypes
void CyMapGenerator::setPlotTypes(boost::python::list& listPlotTypes)
{
if (!m_pMapGenerator)
{
return;
}
int* paiPlotTypes = NULL;
gDLL->getPythonIFace()->putSeqInArray(listPlotTypes.ptr() /*src*/, &paiPlotTypes /*dst*/);
m_pMapGenerator->setPlotTypes(paiPlotTypes);
delete [] paiPlotTypes;
}
开发者ID:Alrik2002,项目名称:Civ4-MMod,代码行数:12,代码来源:CyMapGenerator.cpp
示例10: grid2utf
static void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
{
//typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
typename T::key_type keys;
typename T::key_type::const_iterator key_pos;
typename T::feature_key_type::const_iterator feature_pos;
// start counting at utf8 codepoint 32, aka space character
boost::uint16_t codepoint = 32;
// TODO - use double?
unsigned array_size = static_cast<unsigned int>(grid_type.width()/resolution);
for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
{
boost::uint16_t idx = 0;
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
mapnik::grid::value_type const* row = grid_type.getRow(y);
for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
{
feature_pos = feature_keys.find(row[x]);
if (feature_pos != feature_keys.end())
{
mapnik::grid::lookup_type val = feature_pos->second;
key_pos = keys.find(val);
if (key_pos == keys.end())
{
// Create a new entry for this key. Skip the codepoints that
// can't be encoded directly in JSON.
if (codepoint == 34) ++codepoint; // Skip "
else if (codepoint == 92) ++codepoint; // Skip backslash
keys[val] = codepoint;
key_order.push_back(val);
line[idx++] = static_cast<Py_UNICODE>(codepoint);
++codepoint;
}
else
{
line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
}
}
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
开发者ID:novldp,项目名称:mapnik,代码行数:50,代码来源:python_grid_utils.hpp
示例11: ObjToArray
Array<double,2>* ObjToArray(const vector<vector<double> >& list)
{
int row = list.size();/**< Get the row length */
int col = list[1].size();/**< Get the column length, all columns have the same size */
Array<double,2>* tab = new Array<double,2>(row,col);
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j ++)
{
(*tab)(i,j) = list[i][j];
}
}
return tab;
}
开发者ID:Guyome,项目名称:Lss,代码行数:14,代码来源:objConv.cpp
示例12: lenExtract
ConvexHull2::ConvexHull2(boost::python::list points)
{
boost::python::object lenObj = points.attr( "__len__" )();
boost::python::extract<int> lenExtract( lenObj );
if ( lenExtract.check() )
{
int numPoints = lenExtract;
for (int pointI = 0; pointI < numPoints; pointI++)
{
boost::python::object pointObj = points[pointI];
boost::python::extract<Point2&> pointExtract( pointObj );
if ( pointExtract.check() )
{
addPoint( pointExtract );
}
}
}
}
开发者ID:Britefury,项目名称:gsculpt,代码行数:18,代码来源:ConvexHull2.cpp
示例13: clearCallback
void NotepadPlusWrapper::clearCallback(boost::python::object callback, boost::python::list events)
{
for(callbackT::iterator it = m_callbacks.begin(); it != m_callbacks.end(); )
{
if(it->second == callback && boost::python::extract<bool>(events.contains(it->first)))
{
it = m_callbacks.erase(it);
}
else
{
++it;
}
}
if (m_callbacks.empty())
{
m_notificationsEnabled = false;
}
}
开发者ID:bruderstein,项目名称:PythonScript,代码行数:18,代码来源:NotepadPlusWrapper.cpp
示例14: lenExtract
Polygon2::Polygon2(boost::python::list verts)
{
boost::python::object lenObj = verts.attr( "__len__" )();
boost::python::extract<int> lenExtract( lenObj );
if ( lenExtract.check() )
{
int numVerts = lenExtract;
vertices.reserve( numVerts );
for (int i = 0; i < numVerts; i++)
{
boost::python::object pointObj = verts[i];
boost::python::extract<Point2&> pointExtract( pointObj );
if ( pointExtract.check() )
{
vertices.push_back( pointExtract );
}
}
}
}
开发者ID:Britefury,项目名称:gsculpt,代码行数:19,代码来源:Polygon2.cpp
示例15: clearCallbackEvents
void ScintillaWrapper::clearCallbackEvents(boost::python::list events)
{
for(callbackT::iterator it = m_callbacks.begin(); it != m_callbacks.end(); )
{
if(boost::python::extract<bool>(events.contains(it->first)))
{
Py_DECREF(it->second);
it = m_callbacks.erase(it);
}
else
{
++it;
}
}
if (m_callbacks.empty())
{
m_notificationsEnabled = false;
}
}
开发者ID:juntalis,项目名称:PythonScript,代码行数:20,代码来源:ScintillaWrapper.cpp
示例16: operator
void operator ()(boost::python::list mylist, const T& value) const
{
mylist.append( value );
}
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:4,代码来源:shared_types_ext.cpp
注:本文中的boost::python::list类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论