这篇教程C++ throw_error_already_set函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中throw_error_already_set函数的典型用法代码示例。如果您正苦于以下问题:C++ throw_error_already_set函数的具体用法?C++ throw_error_already_set怎么用?C++ throw_error_already_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了throw_error_already_set函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rvalue_from_python_stage2BOOST_PYTHON_DECL void* rvalue_from_python_stage2( PyObject* source, rvalue_from_python_stage1_data& data, registration const& converters){ if (!data.convertible) { handle<> msg(#if PY_VERSION_HEX >= 0x03000000 ::PyUnicode_FromFormat#else ::PyString_FromFormat#endif ( "No registered converter was able to produce a C++ rvalue of type %s from this Python object of type %s" , converters.target_type.name() , source->ob_type->tp_name )); PyErr_SetObject(PyExc_TypeError, msg.get()); throw_error_already_set(); } // If a construct function was registered (i.e. we found an // rvalue conversion), call it now. if (data.construct != 0) data.construct(source, &data); // Return the address of the resulting C++ object return data.convertible;}
开发者ID:AsherBond,项目名称:PDAL,代码行数:29,
示例2: PyInt_AsLongbool str_base::startswith(object_cref prefix, object_cref start) const{ bool result = PyInt_AsLong(this->attr("startswith")(prefix,start).ptr()); if (PyErr_Occurred()) throw_error_already_set(); return result;}
开发者ID:Karlan88,项目名称:xray,代码行数:7,
示例3: attributes static list attributes(AttributeCachePtr cache, const AttributeCache::ObjectHandle &obj, object regex) { list attributes; AttributeHandleVector a; if ( regex != object() ) { extract< std::string >elem( regex ); if ( elem.check() ) { cache->attributes(obj, elem(), a); } else { PyErr_SetString(PyExc_TypeError, "Regex parameter must be a string or None."); throw_error_already_set(); } } else { cache->attributes(obj, a); } for (AttributeHandleVector::const_iterator it = a.begin(); it != a.end(); ++it) { attributes.append<std::string>(*it); } return attributes; }
开发者ID:AtomicFiction,项目名称:cortex,代码行数:29,
示例4: base_append static void base_append(Container& container, object v) { extract<data_type&> elem(v); // try if elem is an exact Data if (elem.check()) { DerivedPolicies::append(container, elem()); } else { // try to convert elem to data_type extract<data_type> elem(v); if (elem.check()) { DerivedPolicies::append(container, elem()); } else { PyErr_SetString(PyExc_TypeError, "Attempting to append an invalid type"); throw_error_already_set(); } } }
开发者ID:C-D-D,项目名称:Geant4.9.6,代码行数:25,
示例5: _BOOST_PYTHON_ASLONGbool str_base::startswith(object_cref prefix, object_cref start, object_cref end) const{ bool result = _BOOST_PYTHON_ASLONG(this->attr("startswith")(prefix,start,end).ptr()); if (PyErr_Occurred()) throw_error_already_set(); return result;}
开发者ID:AsherBond,项目名称:PDAL,代码行数:7,
示例6: exec_file// Execute python source code from file filename.// global and local are the global and local scopes respectively,// used during execution.object BOOST_PYTHON_DECL exec_file(str filename, object global, object local){ // Set suitable default values for global and local dicts. if (global.is_none()) { if (PyObject *g = PyEval_GetGlobals()) global = object(detail::borrowed_reference(g)); else global = dict(); } if (local.is_none()) local = global; // should be 'char const *' but older python versions don't use 'const' yet. char *f = python::extract<char *>(filename);#if PY_VERSION_HEX >= 0x03000000 // TODO(bhy) temporary workaround for Python 3. // should figure out a way to avoid binary incompatibilities as the Python 2 // version did. FILE *fs = fopen(f, "r");#else // Let python open the file to avoid potential binary incompatibilities. PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r")); if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file"); python::handle<> file(pyfile); FILE *fs = PyFile_AsFile(file.get());#endif PyObject* result = PyRun_File(fs, f, Py_file_input, global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result));}
开发者ID:jaimeyu,项目名称:ycmd,代码行数:35,
示例7: extract static T extract(PyObject* intermediate) { long x = PyInt_AsLong(intermediate); if (PyErr_Occurred()) throw_error_already_set(); return numeric_cast<T>(x); }
开发者ID:RossBille,项目名称:vim-config,代码行数:7,
示例8: exec_file// Execute python source code from file filename.// global and local are the global and local scopes respectively,// used during execution.object BOOST_PYTHON_DECL exec_file(str filename, object global, object local){ // Set suitable default values for global and local dicts. object none; if (global.ptr() == none.ptr()) { if (PyObject *g = PyEval_GetGlobals()) global = object(detail::borrowed_reference(g)); else global = dict(); } if (local.ptr() == none.ptr()) local = global; // should be 'char const *' but older python versions don't use 'const' yet. char *f = python::extract<char *>(filename); // Let python open the file to avoid potential binary incompatibilities. PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r")); if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file"); python::handle<> file(pyfile); PyObject* result = PyRun_File(PyFile_AsFile(file.get()), f, Py_file_input, global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result));}
开发者ID:coxlab,项目名称:boost_patched_for_objcplusplus,代码行数:28,
示例9: msgBOOST_PYTHON_DECL PyObject* registration::to_python(void const volatile* source) const{ if (this->m_to_python == 0) { handle<> msg(#if PY_VERSION_HEX >= 0x3000000 ::PyUnicode_FromFormat#else ::PyString_FromFormat#endif ( "No to_python (by-value) converter found for C++ type: %s" , this->target_type.name() ) ); PyErr_SetObject(PyExc_TypeError, msg.get()); throw_error_already_set(); } return source == 0 ? incref(Py_None) : this->m_to_python(const_cast<void*>(source));}
开发者ID:bk5115545,项目名称:omegalib,代码行数:25,
示例10: extend_container void extend_container(Container& container, object l) { typedef typename Container::value_type data_type; // l must be iterable BOOST_FOREACH(object elem, std::make_pair( boost::python::stl_input_iterator<object>(l), boost::python::stl_input_iterator<object>() )) { extract<data_type const&> x(elem); // try if elem is an exact data_type type if (x.check()) { container.push_back(x()); } else { // try to convert elem to data_type type extract<data_type> x(elem); if (x.check()) { container.push_back(x()); } else { PyErr_SetString(PyExc_TypeError, "Incompatible Data Type"); throw_error_already_set(); } } }
开发者ID:ARK1988,项目名称:nupic.core,代码行数:33,
示例11: PyObject_IsTrueinline boolobject_operators<U>::operator!() const{ object_cref2 x = *static_cast<U const*>(this); int is_true = PyObject_IsTrue(x.ptr()); if (is_true < 0) throw_error_already_set(); return !is_true;}
开发者ID:DD-L,项目名称:lproxy,代码行数:8,
示例12: execobject BOOST_PYTHON_DECL exec(str string, object global, object local){ // should be 'char const *' but older python versions don't use 'const' yet. char *s = python::extract<char *>(string); PyObject* result = PyRun_String(s, Py_file_input, global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result));}
开发者ID:Axitonium,项目名称:sourcesdkpython,代码行数:8,
示例13: bool_typeinlineobject_operators<U>::operator bool_type() const{ object_cref2 x = *static_cast<U const*>(this); int is_true = PyObject_IsTrue(x.ptr()); if (is_true < 0) throw_error_already_set(); return is_true ? &object::ptr : 0;}
开发者ID:DD-L,项目名称:lproxy,代码行数:8,
示例14: setattrBOOST_PYTHON_DECL void setattr(object const& target, char const* key, object const& value){ if (PyObject_SetAttrString( target.ptr(), const_cast<char*>(key), value.ptr()) == -1 ) { throw_error_already_set(); }}
开发者ID:RossBille,项目名称:vim-config,代码行数:9,
示例15: delsliceBOOST_PYTHON_DECL void delslice(object const& target, handle<> const& begin, handle<> const& end){ if (assign_slice( target.ptr(), begin.get(), end.get(), 0) == -1 ) { throw_error_already_set(); }}
开发者ID:RossBille,项目名称:vim-config,代码行数:9,
示例16: delattrBOOST_PYTHON_DECL void delattr(object const& target, char const* key){ if (PyObject_DelAttrString( target.ptr(), const_cast<char*>(key)) == -1 ) { throw_error_already_set(); }}
开发者ID:RossBille,项目名称:vim-config,代码行数:9,
示例17: convert_index static index_type convert_index(Container& container, PyObject* i_) { extract<long> i(i_); if (i.check()) { long index = i(); if (index < 0) index += DerivedPolicies::size(container); if (index >= long(container.size()) || index < 0) { PyErr_SetString(PyExc_IndexError, "Index out of range"); throw_error_already_set(); } return index; } PyErr_SetString(PyExc_TypeError, "Invalid index type"); throw_error_already_set(); return index_type(); }
开发者ID:claudiok,项目名称:icetray-icetray,代码行数:18,
示例18: GetNucleon //[] access is by reference, so nucleon_collection[0].x += 5 works Nucleon& GetNucleon(NucleonCollection& nucleon_collection, int index) { if(index >= int(nucleon_collection.NucleonCount())) { PyErr_SetString(PyExc_StopIteration, "No more data."); throw_error_already_set(); } if(index < 0) { index = index % nucleon_collection.NucleonCount(); } return nucleon_collection[index]; }
开发者ID:sangaline,项目名称:gespin,代码行数:11,
示例19: checkGreaterThanZerodouble checkGreaterThanZero(double value){ if (value <= 0) { PyErr_SetString(PyExc_ValueError, "Expected resolution > 0"); throw_error_already_set(); } return value;}
开发者ID:matajoh,项目名称:pcl,代码行数:11,
示例20: get_item static data_type& get_item(Container& container, index_type i_) { typename Container::iterator i = container.find(i_); if (i == container.end()) { PyErr_SetString(PyExc_KeyError, "Invalid key"); throw_error_already_set(); } return i->second; }
开发者ID:4eek,项目名称:xtractorfan,代码行数:11,
示例21: MakeFile object MakeFile() { FILE* fp = pcap_dump_file( mFileHandle ); if( fp == NULL ) { PyErr_SetString( PyExc_Exception, "Can't make file." ); throw_error_already_set(); } PyObject* o = PyFile_FromFile( fp, "savefile", "wb", fclose ); return object(borrowed(o)); }
开发者ID:bahamut8348,项目名称:xkcode,代码行数:11,
注:本文中的throw_error_already_set函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ throw_exception函数代码示例 C++ throw_error函数代码示例 |