wrapper

wrapping template function and <unresolved overloaded function type

白昼怎懂夜的黑 提交于 2019-12-06 01:51:54
I have problem with my wrapping function. template <typename Iter, typename SomeFunction> void wrap(Iter first, Iter last, SomeFunction someFunction) { someFunction(first, last); } I would like to use it like this: template <typename Iter> void fill5(Iter first, Iter last) { fill(first, last, 5); } int main() { vector<int> v(100, -1); wrap(v.begin(), v.end(), fill5); } But I get test.cpp: In function ‘int main()’: test.cpp:16:40: error: no matching function for call to ‘wrap(std::vector<int>::iterator, std::vector<int>::iterator, <unresolved overloaded function type>)’ test.cpp:16:40: note:

how do you write a c wrapper for a c++ class with inheritance

对着背影说爱祢 提交于 2019-12-06 01:32:53
问题 I was just wondering if there was a way to create a c wrapper API for a c++ class that has inheritance. Consider the following: class sampleClass1 : public sampleClass{ public: int get() { return this.data *2; }; void set(int data); } class sampleClass : public sample{ public: int get() { return this.data; } void set(int data) {this.data = data; } } class sample { public: virtual int get(); virtual void set(int data); private: int data; } How would I wrap the sampleClass1 to make it work in a

Wrapping an Unmanaged C++ Class Library with C++/CLI - Question 2 - Collections

主宰稳场 提交于 2019-12-06 00:40:46
问题 Note: This post represents Question #2 of my inquiry. The introduction block (all text until the numbers are reached) is repeated in both questions as it is background information that may be needed to answer the question. Introduction to Question I have an unmanaged C++ library that contains classes and functions that are common to and shared among several "higher level" libraries. I now have need to provide access to the common library to C#/.Net applications. To do this, I will have to

Custom wrapper for indexing python list starting at 1

风流意气都作罢 提交于 2019-12-05 22:52:20
I'd like to write a simple wrapper for the python list type that forces it to start indexing at 1 instead of 0 . I've got a a fairly complex program based on some discrete probability distributions of duration data, with integer-length buckets, but I don't have any durations of less than 1. Anyway, it would greatly simplify a some significant portions of my code to be able to seamlessly index starting at 1. I was using a dict at first but I found several properties of them to be too cumbersome. I've never written a wrapper for a Python class before, much less a built-in type, but I feel like

python parent class 'wrapping' child-class methods

Deadly 提交于 2019-12-05 22:45:28
问题 I have the following situation in my python code: class Parent(object): def run(self): print "preparing for run" self.runImpl() print "run done" class Child(Parent): def runImpl(self): print "child running" However, I have several such 'decorators', doing different setup/teardown steps before and after 'runImpl', and I don't like having to define run() , runImpl() , runImplSingleProcess() etc. I am looking for a solution of the following form: class Parent(object): @wrapping_child_call def

void* to Object^ in C++/CLI

故事扮演 提交于 2019-12-05 19:35:48
I am working on wrapping a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#. Some of the native C++ functions have a return type of void*. I am not sure how to handle this when I pass back the value to my calling code. For instance: if a C# app calls my dll wrapper, what do I return from the native call: void* start(ThreadFunc,void *, unsigned *); I am currently attempting to box the return in a generic System::Object^ with no luck. This is the call in the wrapper: m_NativeThread->start(cb, GCHandle::ToIntPtr(GCHandle::Alloc(o))

Wrapping an API to support dependency injection

那年仲夏 提交于 2019-12-05 18:49:49
I am interacting with an API that just has static functions, and cannot be opened up and changed. public class WindowsNativeGraphAPI { public static IEnumerable<IGraphData> GetGraphData(); public static bool DeleteGraphData(IGraphData data); } I would like to be able to pass the API into a function or constructor and comply with dependency injection (just in case we were to swap out the API later). public void GatherGraphData(IGraphAPI api) {...} To allow this API to be passed in as a parameter, I'd need to at least abstract to use an interface to pass into the function. public interface

Return a structure to Python from C++ using BOOST.python

混江龙づ霸主 提交于 2019-12-05 17:57:32
I have written a C++ method from which I need to return a structure to Python. I'm already able to send an OpenCV mat from Python to C++ using BOOST following the method described in this link . Now I need to go the other way; return from C++ to Python, and then access that structure in Python. Can it be done? Any samples or reference links would be good. I have tried googling before posting this question and I couldn't get any samples or explanation links. You can use another function from modules/python/src2/cv2.cpp: PyObject* pyopencv_from(const cv::Mat& m) { if( !m.data ) Py_RETURN_NONE;

SQLite “database disk image is malformed”

天涯浪子 提交于 2019-12-05 17:45:16
问题 I am having trouble with an app where the SQLite database is getting corrupted. There was the odd case of this previously, but it seems to have become a lot more common after the release of iOS 7.1. I'm using the SQLite wrapper by Matteo Bertozzi that you can find here: https://github.com/ConnorD/simple-sqlite The database gets corrupted and spits out the error database disk image is malformed , some queries can be run but the existing data gets messed up. I have searched high and low and can

Pass a C++/CLI wrapper of a native type to another C++/CLI assembly

空扰寡人 提交于 2019-12-05 17:11:46
Suppose I have the following simple wrapper of a NativeClassInstance. public ref class Wrapper { private: NativeClass *_wrapped; public: Renderer() { _wrapped = new NativeClass(); } ~Renderer() { delete _wrapped; } operator NativeClass*() { return _wrapped; } } Now, I want to create an instance of Wrapper from C# with Wrapper wrapper = new Wrapper() and use it in another native functionalities wrapper that resides in another assembly with Helper.Foo(wrapper) (nothing strange having other functionalities not directly related to the wrapped classes in another assembly, IMO): // Utilities is in