草庐IT

swig-template

全部标签

c# - 将代码添加到 SWIG 中自动生成的类

我正在尝试找到一种方法来将代码添加到swig生成的函数中。我已经使用类型映射来扩展类,但在文档中找不到任何关于扩展特定功能的内容。给定以下swig接口(interface)文件:%moduleTest%{#include"example.h"%}%typemap(cscode)Example%{bool64bit=SizeOf(typeof(System.IntPtr))==8;staticstringPath=64bit?"/...Pathto64bitdll.../":"/...Pathto32bitdll.../";%}%include"example.h"我得到以下C#代码:p

c++ - SWIG:向生成的 .py 文件添加注释

使用SWIG生成C++应用程序的Python接口(interface),有没有什么办法让它在生成的.py文件中注释函数?我实际上是将整个.h文件拉入.i文件,但举个小例子:%moduleexamplebooldo_something_interesting(intnumber,stringtext);swig-pythonexample.i生成:...defdo_something_interesting(*args):return_example.do_something_interesting(*args)do_something_interesting=_example.do_s

python - 将字符串返回到 SWIG python 接口(interface)的最佳方法是什么?

将字符串从C++返回到SWIGpython接口(interface)的线程安全且无内存泄漏的方法是什么?SWIG会自动将char*返回值的内容复制到python字符串中。ThisSWIGguide举个例子:char*__str__(){staticchartemp[256];/*WRITESTUFFTOSTRING*/return&temp[0];}他们的示例使用静态字符串作为返回值,但如果我的C++程序有多个线程,它们可以很容易地覆盖彼此的字符串。返回新分配的字符串会造成内存泄漏,因为SWIG不知道要释放它。我唯一能想到的是注册并返回一个指向实际python字符串对象的指针(这样py

c++ - Swig -includeall 除了...

我有一个大型项目,其中使用Swig-includeall标志似乎很有意义。但是,有些文件我不想扩展,主要是STL库(例如vector和列表)。是否可以使用-includeall标志,但将某些文件列入黑名单以防止扩展(如vector和列表)? 最佳答案 来自DocsabouttheSWIGPreprocessor:SWIGfullysupportstheuseof#if,#ifdef,#ifndef,#else,#endiftoconditionallyincludepartsofaninterface.Thefollowingsym

WPF界面魔法:探秘Template奇妙世界,个性化定制你的UI

 概述:WPF中的Template机制为界面定制提供了强大工具,包括控件模板、ItemsPresenter、ItemsPanel、和ItemContainerStyle。通过这些功能,开发者能精确定义控件外观和布局,个性化每个项的样式,实现灵活而美观的用户界面。WPF中各种Template功能用途:Template(控件模板):用途: 控件模板用于定义整个控件的外观和布局。示例: 在ComboBox中,可以通过模板定义文本区域、下拉按钮区域以及Items的Popup区域。ItemsPresenter(项呈现器):用途: 在控件样式中标记一个区域,用于展示该控件的Items。示例: 在Combo

c++ - 标准 :forward inside a template class

templateclassBlockingQueue{std::queuecontainer_;templatevoidpush(U&&value){static_assert(std::is_same::type>::value,"Can'tcallpushwithoutthesameparameterastemplateparameter'sclass");container_.push(std::forward(value));}};我希望BlockingQueue::push方法能够处理T类型对象的右值和左值引用,以将其转发到std::queue::push正确的版本。是像上面

c++ - 错误 : ‘template<class> class std::auto_ptr’ is deprecated

我正在使用scons和ubuntu。当我使用'scons'制作一些程序时,会发生错误,例如,src/db/DBTextLoader.cc:296:3:error:‘templateclassstd::auto_ptr’isdeprecated[-Werror=deprecated-declarations]/usr/include/c++/5/bits/unique_ptr.h:49:28:note:declaredheretemplateclassauto_ptr;这是我的命令;$./configuer$sourcesomething.sh$scons其实我也不知道。我已经在搜索这个

c++ - 错误 : Expected template-name before '<' token

我正在尝试编译一个实现chain和chainNodes的程序并在以下行(第22行)出现错误:classchain:publiclinearList错误是:Error:expectedtemplate-namebefore'知道为什么会出现这种情况吗?我的代码如下://linkedimplementationofalinearlist//derivesfromabstractclasslinearListjusttomakesure//allmethodsoftheADTareimplemented#ifndefchain_#definechain_#include#include#in

C++11 : Is it possible to give fixed-template-parameted template to varidic-template-template-parameter?

(是的,由于我糟糕的英语,标题很奇怪;我希望有人能改进它。)接听thisquestion,我发现这段代码有效:templateclassA{};templateclassU>classB{};intmain(){Bit_works;}..虽然templateclass和templateclass不相等。我试图弄清楚为什么这是可能的,并观察了N3337standard的[temp.param],但我找不到任何东西。怎么可能? 最佳答案 是的,这是可能的。C++1114.3.3/3特别允许,并提供了一个例子。3Atemplate-arg

c++ - 奇怪的 "Could not deduce template argument for ' T'"错误

错误在this代码://myutil.htemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,predicatecondition);//myutil.cpptemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,Predcondition){Tinputcout>input;while(!condition(input)){cout>input;}returninput;}...//c_main.cppintrow;row=ConditionalI