在C++程序中怎么使用python函数所返回的字典

在C++程序中如何使用python函数所返回的字典
我在python中定义了一个函数,函数返回一个字典,看起来大体是这个样子的:

def get_a_dic():
  dic = {}
  #在这里对字典进行操作
  ……
  return dic

然后再C++中调用这个函数
得到一个PyObject* pDic
我该怎么使用这个pDic?
我想获得里面的所有Key和对应的value,把这个字典中的所有item导入到一个map中,应该怎么做?

我是用的是python3.0,eclipse3.5 挂接mingw编译环境,没有使用boost库。

请高手指教!

------解决方案--------------------
看看http://docs.python.org/c-api/dict.html
------解决方案--------------------
同学一下
------解决方案--------------------
学习学习
------解决方案--------------------
写了个,试试, 用cpython 2.5

1. my_utils.py
def get_a_dict():
d = {'A':1, 'B':2, 'C':3}
return d


if __name__ == '__main__' :
print get_a_dict()


----------output--------
$ ./a.out 
{'A': 1, 'C': 3, 'B': 2}
pos, key value = 1 A 1
pos, key value = 3 C 3
pos, key value = 4 B 2
key value = A 1
key value = B 2
key value = C 3

*/

#include <iostream>
#include <string>
#include <map>
#include <Python.h>
 
using namespace std;
 
int main() {
typedef map<string, long> mapType;
mapType data;

Py_Initialize();
PyObject * pFunc = NULL;
PyObject * pArg = NULL;

PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append('./')");

PyObject* mod= PyImport_ImportModule("my_utils");

if(mod == 0) {
puts("didn't load" );
}

pFunc = PyObject_GetAttrString(mod, "get_a_dict");
PyObject *dict1 = PyEval_CallObject(pFunc, pArg); //pArg = NULL => no argument 

printf( "%s\n", PyString_AsString( PyObject_Repr(dict1) ) );

PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next(dict1, &pos, &key, &value)) {
printf("pos, key value = %ld %s %ld\n", pos, PyString_AsString(key), PyLong_AsLong(value));
data[PyString_AsString(key)] = PyLong_AsLong(value);
}

Py_DECREF( dict1 );

Py_Finalize();

for(mapType::const_iterator it = data.begin(); it != data.end(); ++it) {
printf("key value = %s %ld\n", (it->first).c_str(), it->second);
}
return 0;
}