背景:我想在一个项目中使用mysql.c的Delphi翻译,但原始维护者Matthias Fichtner(http://www.fichtner.net/delphi/mysql/)似乎已经将其删除了.
问题:有没有人知道libmySQL.dll的类似包装(或Matthias Fichtner的包装器的更新版本)在轻量级方面类似?
是否有任何方法可以使Java程序(在Windows中)充当PE(.exe)的包装器,将所有stdin输入传递给程序并写出stdout PE写出的所有内容.
我需要这个,因为程序的接口只允许Java类,但我希望它运行一些我在C++中放在一起的代码.
提前致谢.
编辑:可移植性是0%重要.这只需要在Windows中工作,永远不需要在其他任何地方工作.
所以我知道 WinForms 稍微触及了 Windows API,但坦率地说它很糟糕。特别是分层窗口和闪烁。所以我想知道是否有人为 Windows API 编写了部分或完整的包装器。我对分层窗口方面特别感兴趣,但实际上 API 的任何部分都是一个很好的起点。
更新:我在这里找到了 Windows API 代码包:http : //code.msdn.microsoft.com/WindowsAPICodePack但它似乎没有包装分层 Windows?我的假设正确吗?
我听说过一些关于 Native API 的事情,但我不太确定它是做什么用的?它提供什么功能?研究一下是个好主意吗?
非常感谢对其中任何一个的回答:)谢谢
我目前正在使用C++/CLI包装一个C++类,用于.NET互操作性,遵循在托管类中保存本机指针的标准过程.在一个实例中,我有一个本机类,其功能如下:
std::shared_ptr<BaseChannel> channelData(const int RunNumber);
Run Code Online (Sandbox Code Playgroud)
我已经开始为它创建一个包装类BaseChannel.但是,如果我将原始指针传递给托管类的构造函数,则无法保证托管类指向的对象的生命周期.即shared_ptr可能超出范围,对象将被删除,托管类将保留一个悬空指针.
这种情况的常见解决方案是什么?
UPDATE
@Ben:所以我在上面这个问题中包含了保存方法的类(假设它是在一个被调用的本机类中Node,它被包装在一个名为NodeRef的托管类中:
ChannelUser^ NodeRef::ChannelData(int runNumber)
{
// mpNode is native class pointer of type Node held in managed class
// wrapper called NodeRef
std::shared_ptr<BaseChannel> spBaseChannel = mpNode->channelData(runNumber);
// ChannelUser is using clr_scoped_ptr to hold the shared_ptr
ChannelUser^ channelUser = gcnew ChannelUser(spBaseChannel);
return channelUser;
}
Run Code Online (Sandbox Code Playgroud)
因为shared_ptr没有增加引用计数,因为它通过引用传递给托管类,这是否意味着
只要此shared_ptr在范围内,它指向的对象仍然存在,因为它的引用计数至少为1
我想替换Android默认sqlite构建为一个新的启用rtree功能.看起来我必须使用java包装器才能实现这一点,而我发现android兼容的唯一一个是sqlite4java.我更喜欢坚持标准.不幸的是我发现dalvikvm(Androids VM)不支持jdbc,而本机android.database.sqlite与srtite的rtree禁用版本一起使用.
目前我有一个新的.so sqlite rtree启用库为Android编译,但想要替换orroids本机,而不必使用像sqlite4java这样的第三方包装器.有任何想法吗?我正在考虑从android sdk下载android.database.sqlite包并构建一个jar来替换我的应用程序上下文中的.so加载.这是最好的方法吗?
说我们有:
public method(Integer s) {
....
}
Run Code Online (Sandbox Code Playgroud)
Java承认该方法的调用:
method(7);
Run Code Online (Sandbox Code Playgroud)
要么
int i = 7;
method(i);
Run Code Online (Sandbox Code Playgroud)
这样做时,JVM是否会创建一个新的Integer?如果我使用相同的int多次调用该方法,我是否创建了几个整数,或者使用了包装对象的"缓存"版本?
谢谢.
我的包装功能有问题.
template <typename Iter, typename SomeFunction>
void wrap(Iter first, Iter last, SomeFunction someFunction)
{
someFunction(first, last);
}
Run Code Online (Sandbox Code Playgroud)
我想像这样使用它:
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);
}
Run Code Online (Sandbox Code Playgroud)
但我明白了
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: candidate is:
wrap.h:6:6: note: template<class Iter, class SomeFunction> void wrap(Iter, Iter, someFunction)
Run Code Online (Sandbox Code Playgroud)
我知道如果我会这样称呼这个功能
wrap(v.begin(), v.end(), fill5< vector<int>::iterator> …Run Code Online (Sandbox Code Playgroud) 我想编写一个通用的构建器类,它包含任何 java 类并提供特定样式的 setter 函数。我不确定这是否可以称为“动态生成的函数”。
当我有一个豆豆 Pojo 类时,即
class Pojo {
public void setValue(int value) {...}
public void setName(String name) {...}
}
Run Code Online (Sandbox Code Playgroud)
我的Maker班级应该可以这样使用:
Pojo p = Builder<Pojo>.create(new Pojo())
.setName("Funny")
.setValue(123)
.build();
Run Code Online (Sandbox Code Playgroud)
如您所见,它所做的工作应该类似于
class PojoBuilder {
private Pojo pojo;
PojoBuilder(Pojo pojo) { this.pojo = pojo; }
public static PojoMaker create(Pojo p) { return new PojoBuilder(p); }
public PojoBuilder setName(String name) { pojo.setName(name); return this; }
public PojoBuilder setValue(int val) { pojo.setValue(val); return this; }
public Pojo make() …Run Code Online (Sandbox Code Playgroud) 我有许多不同内容的函数,但参数和try catch内部几乎相似.无论如何都要将函数包起来以减少冗余代码.
ResponseStatus GetPotatoList(GetPotatosRequest requestParam, out GetPotatosResponse response, out ResponseErrorType errorType)
{
ResponseStatus status = ResponseStatus.Fail;
response = new GetPotatosResponse();
//To Do
try
{
//To Do
status = ResponseStatus.Success;
}
catch(CustomException ex)
{
errorType = ResponseErrorType.CustomError;
}
catch(TimeoutException ex)
{
errorType = ResponseErrorType.Timeout;
}
catch(Exception ex)
{
errorType = ResponseErrorType.GeneralFailure;
}
return status;
}
Run Code Online (Sandbox Code Playgroud)