易截截图软件、单文件、免安装、纯绿色、仅160KB

c++于python混合系统的一个难题

这是一个普通的混合使用方式, 但这种方式不能达到脚本真正的灵活性, c++每个属性必须绑定一个唯一的set和get接口提供给python内部访问这个属性
C/C++ code:

class sample
{

public:
int m_obj;
int GetValue(){
return m_obj;
}

void SetValue(int v){
m_obj= v;
}
};


class_<sample>("sample")
.add_property("m_obj", &sample::GetValue, &sample::SetValue )





我看过一个公司做的一个系统使用自己开发的python插件模块实现了非常灵活的c++与python交互
这个系统有一个配置文件, 其中定义着一些属性和接口, 在系统启动时会去分析这些配置然后把它们
建立在python中, 用户在python中对这些配置定义的属性赋值都会被c++所截获

下面是按照我的设想去做, 当然下面代码不能运行 因为不支持这样的方式。
用户在配置文件定义了3个属性
int obj1, float obj2, string obj3

把它们绑定到一个通用的接口上
.add_property("obj1", &bind(&sample::GetValue, 1), &bind(&sample::SetValue, 1 ) )
.add_property("obj2", &bind(&sample::GetValue, 2), &bind(&sample::SetValue, 2 ) )
.add_property("obj3", &bind(&sample::GetValue, 3), &bind(&sample::SetValue, 3 ) )

class sample
{
   
public:
    Py


相关问答:

用C或C++如何编写求解3D魔方程序 - C/C++ / C++ 语言

请问用C或C++如何编写求解3D魔方的程序,该从何开始?
谢谢各位,帮忙提点建议吧。

http://www.mofang.net/code/176/182/6581.html

我只能突破60秒!唉。

我刚过40秒

google的android中有个OpenGL ES + ......

[提问]Python 如何忽略 whitespace 读入

像 C 的 scanf() 那样
比如读入 1 2 3 a b c
每次读入一个
下面这个应该是你想要的吧:
Python code:

>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......

C 程序问题 (三) - C/C++ / C语言

问题一:
在对齐为4的情况下
struct BBB
{
long num;
char *name;
short int data;
char ha;
short ba[5];
}*p;
p=0x1000000;
p+0x200=____;
(Ulong)p+0x200=____;
(char*)p+0x200=____;
假设在32位C ......

请教一题C,我看不明白! - C/C++ / C语言

#include "stdio.h"
void main()
{
  int *p;
  int a[10]={0,1,2,3,4,5,6,7,8,9};
  int k=0;
  p=a;
  for(int i=0;i<10;i++,p ......

C/C++里屏shift+f10键要怎么写! - C/C++ / C++ 语言

SHIFT加F10与那个键右ctrl边上的那个键功能一样,想屏这个
但不知要怎么写那个组合键!
有没哪个大侠放一段这个的代码或写一段
http://topic.csdn.net/u/20090609/15/7dc9fb70-243f-4070-9cfd-34e48b66e6c6.html ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号