How can I send a C++ map<> to Python using Boost Python object? -


i want pass map<string, string> c++ code python code while i'm using boost::python::object. want use input parameters.

i define dictionary in python this:

script_parameters = {} 

and pass map<string, string> in c++ this:

typedef map<string, string> commandparametersmap;  if ( !command_parameters.empty() ) {     commandparametersmap::iterator begin = command_parameters.begin();     commandparametersmap::iterator end = command_parameters.end();     boost::python::dict command_parameters_dict;     (commandparametersmap::iterator = begin; != end; it++)     {         command_parameters_dict[it->first] = it->second;     }     m_script_global["script_parameters"] = command_parameters_dict;  }    

and run python file:

object o_result = exec(m_filescript->c_str(), m_script_global, m_script_global); 

but here problem: script_parameters in python code empty. doing wrong in here?

i have mention other parts of code, such executing scripts, work fine. want know how can pass data c++ python boost::python::object.

i tried way still have same problem:

i made script_mode in python code this:

script_mode = "" 

then tried pass string variable in c++ python this:

m_script_global["script_mode"] = "get_script_version";  object o_result = exec(m_filescript->c_str(), m_script_global, m_script_global); 

when try back, has value assigned in python, "".

string mode = extract<std::string>(m_script_global["script_mode"]); 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -