Example #1
0
void print_ptree(std::ostream& os, const boost::property_tree::ptree& pt, int depth)
{
	typedef bp::ptree::const_iterator c_it;

	if(pt.empty())
		os << "'" << pt.data() << "'\n";
	else
	{
		std::string pad("");
		pad.assign(depth*4,' ');
		++depth;
		std::string pad2 = pad + "    ";

		if(is_list(pt))
		{
			os << "[\n";
			for(c_it it=pt.begin(); it!=pt.end(); ++it)
			{
				os << pad2;
				print_ptree(os, it->second, depth);
			}
			os << pad << "]\n";
		}
		else
		{
			os << "{\n";
			for(c_it it=pt.begin(); it!=pt.end(); ++it)
			{
				os << pad2 << "'" << it->first << "': ";
				print_ptree(os, it->second, depth);
			}
			os << pad << "}\n";
		}
	}
}
Example #2
0
int Split::loadConfig(const boost::property_tree::ptree& pt)
{
    BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ <<  " " << id();
    const boost::property_tree::ptree& split = pt.get_child("split");
    boost::optional<string> name = split.get_optional<string>("name");
    if (name.is_initialized()) {
	this->name(*name);
    }

    cout << "HAHA!!!" << id() << " " << pt.begin()->first << endl;
    updateConfig(pt.begin()->second );
    return 1;
}
Example #3
0
void property_tree::to_path_value( std::ostream& os, const boost::property_tree::ptree& ptree, path_mode mode, char equal_sign, char delimiter, const xpath& root )
{
    for( boost::property_tree::ptree::const_iterator i = ptree.begin(); i != ptree.end(); ++i )
    {
        // display_path is the modified key path showing array indices, if array exists within e.g abc[0]/xyz[0]
        // But the actual path to the value is many empty keys under abc and abc/xyz
        // Boost: "JSON arrays are mapped to nodes. Each element is a child node with an empty name.
        //         If a node has both named and unnamed child nodes, it cannot be mapped to a JSON representation."
        // http://www.boost.org/doc/libs/1_41_0/doc/html/boost_propertytree/parsers.html#boost_propertytree.parsers.json_parser
        xpath path;
        xpath display_path;
        impl::ptree_to_path_value_string_impl( os, i, i == ptree.begin(), path, display_path, mode, equal_sign, delimiter, root.to_string() ); // quick and dirty
    }
}
void XSDSchemaParser::parseStringTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeStringLimits> &pStringLimits)
{
    for (auto it = restrictTree.begin(); it != restrictTree.end(); ++it)
    {
        std::string restrictionType = it->first;

        if (restrictionType == "xs:minLength")
            pStringLimits->setMinLength(it->second.get<int>("<xmlattr>.value"));
        else if (restrictionType == "xs:maxLength")
            pStringLimits->setMaxLength(it->second.get<int>("<xmlattr>.value"));
        else if (restrictionType == "xs:length")
            pStringLimits->setLength(it->second.get<int>("<xmlattr>.value"));
        else if (restrictionType == "xs:pattern")
            pStringLimits->addPattern(it->second.get("<xmlattr>.value", "0"));
        else if (restrictionType == "xs:enumeration")
        {
            pStringLimits->addAllowedValue(it->second.get("<xmlattr>.value", "badbadbad"), it->second.get("<xmlattr>.hpcc:description", ""));
        }
        else if (restrictionType != "<xmlattr>")
        {
            std::string msg = "Invalid restriction(" + it->first + ") found while parsing type";
            throw(ParseException(msg));
        }
    }
}
// Reads in all the render objects from the scene file
void readObjects(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();

	// Iterate through the sub branches of the property file, reading in each
	// object
	for (; iter != pt.end(); ++iter)
	{
		// Create a render object
		render_object* object = new render_object();

		// Read in the name for the object
		std::string name = iter->first;

		// Read in the geometry
		std::string geom = iter->second.get_child("geometry").get_value<std::string>();
		object->geometry = scene->geometry[geom];

		// Read in the material
		std::string mat = iter->second.get_child("material").get_value<std::string>();
		object->material = scene->material[mat];

		// Read in the transform
		readTransform(object, iter->second.get_child("transform"));

		// Add the render object to the table of render objects
		scene->objects[name] = object;
	}
}
void NetworkManagerHandler::setSettings(const boost::property_tree::ptree &requestPt)
{
    if (requestPt.find("type") != requestPt.not_found())
    {
        NetworkInterfaces::InterfaceSettings settings;
        settings.interface = _interfaceName;
        settings.type = requestPt.get<std::string>("type");
        settings.autoConnect = requestPt.get<bool>("auto", true);

        for (boost::property_tree::ptree::const_iterator it = requestPt.begin(); it != requestPt.end(); ++it)
        {
            if (it->first != "type")
                settings.arguments[it->first] = it->second.get_value<std::string>();
        }

        NetworkInterfaces::writeInterfaceSettings(kNetworkInterfacesFile, settings);

        if (_interfaceName != qpcrApp.wirelessManager()->interfaceName())
        {
            NetworkInterfaces::ifdown(_interfaceName);
            NetworkInterfaces::ifup(_interfaceName);
        }
        else
            wifiConnect();
    }
    else
    {
        setStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
        setErrorString("type must be set");
    }
}
    /**
     * @brief  Construct a PropertyTreeValue from a tree object
     *
     * This function will determine whether the tree object represents an array
     * or an object by scanning the key names for any non-empty strings. In the
     * case of an empty tree object, it is not possible to determine whether it
     * is an array or an object, so it will be treated as an array by default.
     * Empty arrays are considered equal to empty objects when compared using
     * non-strict type comparison. Empty strings will also be stored as empty
     * arrays.
     *
     * @param  tree  Tree object to be wrapped
     */
    PropertyTreeValue(const boost::property_tree::ptree &tree)
    {
        if (tree.data().empty()) {    // No string content
            if (tree.size() == 0) {   // No children
                array = tree;         // Treat as empty array
            } else {
                bool isArray = true;
                boost::property_tree::ptree::const_iterator itr;
                for (itr = tree.begin(); itr != tree.end(); itr++) {
                    if (!itr->first.empty()) {
                        isArray = false;
                        break;
                    }
                }

                if (isArray) {
                    array = tree;
                } else {
                    object = tree;
                }
            }
        } else {
            value = tree.data();
        }
    }
Example #8
0
static boost::property_tree::ptree xml_to_ptree_( boost::property_tree::ptree& ptree)
{
    boost::property_tree::ptree out= boost::property_tree::ptree();
    boost::property_tree::ptree unnamed_array= boost::property_tree::ptree();
    for ( boost::property_tree::ptree::iterator i=ptree.begin(); i!=ptree.end(); i++ )
    {
        //look ahead for duplicate name
        boost::property_tree::ptree::iterator lah = i;
        if ( ++lah != ptree.end() && i->first == lah->first )
        {
            //add to unnamed array
            unnamed_array.push_back( std::make_pair( "", xml_to_ptree_( i->second ) ) );
        }
        else
        {
            if(unnamed_array.size()!=0)
            {
                //assert((i-1)->first==i->first);
                //the last of duplicated name
                unnamed_array.push_back( std::make_pair( "", xml_to_ptree_( i->second ) ) );
                out.add_child(i->first,unnamed_array);
                unnamed_array= boost::property_tree::ptree();
            }
            else
            {
                out.add_child(i->first, xml_to_ptree_(i->second) );
            }
        }
    }
    out.put_value( trim( ptree.get_value<std::string>() ) );
    return out;
}
// Read in material data from the scene file
void readMaterials(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	// Iterate through all the sub branches, and read in the relevant data
	for (; iter != pt.end(); ++iter)
	{
		material* mat = new material();
		std::string name = iter->first;
		mat->data.emissive = readVec4(iter->second.get_child("emmisive"));
		mat->data.ambient = readVec4(iter->second.get_child("ambient"));
		mat->data.diffuse = readVec4(iter->second.get_child("diffuse"));
		mat->data.specular = readVec4(iter->second.get_child("specular"));
		mat->data.shininess = iter->second.get_child("shininess").get_value<float>();
		std::string texture = iter->second.get_child("texture").get_value<std::string>();

		// Try and find texture, and set material accordingly.  If the not found, 
		// set to nullptr
		if (scene->textures.find(texture) != scene->textures.end())
			mat->texture = scene->textures[texture];
		else
			mat->texture = nullptr;

		// Create the material, and add to the table
		mat->create();
		scene->material[name] = mat;
	}
}
Example #10
0
int ParallelFilter::handleConfigItem(const std::string& confFile,
				     const boost::property_tree::ptree::const_iterator& it)
{
    BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":: "<< type() << " " << it->first ;

    cout << "PF::handle "  << it->first << endl;
    if (it->first == "parallelFilter") {
	// recurse
 	return loadConfig(confFile, it->second.begin(), it->second.end());
    } else if (it->first == "thread") {
	cout << "PF::THREAD FOUND!"<< endl;
	Filter* f;
	if ( it->second.size() > 1 
	     ) {
	    // instantiate a filterbank
	    FilterBank* fb = new FilterBank();

	    fb->bank(NULL);
	    fb->loadConfig( it->second );
	    
	    f=fb;
	} else if (it->second.begin()->first == "filterGroup") {
	    // instantiate a filterbank
	    FilterBank* fb = new FilterBank();
	    const boost::property_tree::ptree pt = it->second.begin()->second;

	    cout << "DD " << pt.data() << endl;
	    fb->bank(NULL);
	    fb->loadFileConfig(pt.data());

	    f=fb;
	} else {
	    const boost::property_tree::ptree pt = it->second;
	    f = instantiateFilter(pt.begin() );
	}

	FilterThread* ft = new FilterThread(f);
	lanes.push_back(ft);

	add(f); // book-keeping

    } else if (it->first == "barrier") {
	boost::property_tree::ptree::const_iterator child = it->second.begin();
	cout << "PF::BARRIER FOUND! "<< child->first << endl;

	Filter* f = instantiateFilter( child );
	
	f->loadConfig( it->second );

	this->mux = (Mux*) f;

	add(f); // book-keeping

    } else {
	//return FilterBank::handleConfigItem(confFile, it);
    }
    return 1;
}
Example #11
0
Options::Options(const boost::property_tree::ptree& tree)
{
    for (auto iter = tree.begin(); iter != tree.end(); ++iter)
    {
        assert(iter->first == "Option");
        Option opt(iter->second);
        add(opt);
    }
}
Example #12
0
File: xml.cpp Project: spolitov/lib
void convert(const boost::property_tree::ptree & in, boost::property_tree::wptree & out)
{
    out.data() = deutf8(in.data());
    for(boost::property_tree::ptree::const_iterator i = in.begin(), end = in.end(); i != end; ++i)
    {
        out.push_back(boost::property_tree::wptree::value_type(deutf8(i->first), boost::property_tree::wptree()));
        convert(i->second, out.back().second);
    }
}
 // For extracted ptree.
 stack_data(const ptree_ptr& p,
            const std::tr1::shared_ptr<pqrs::string::replacement>& r,
            const boost::property_tree::ptree& root_children) :
   it(root_children.begin()),
   end(root_children.end()),
   parent_replacement(*r),
   pt_ptr_(p),
   replacement_ptr_(r)
 {}
// Takes a branch of a property tree and reads in a vec3
glm::vec3 readVec3(const boost::property_tree::ptree& pt)
{
	glm::vec3 v;
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	v.x = (iter++)->second.get_value<float>();
	v.y = (iter++)->second.get_value<float>();
	v.z = (iter++)->second.get_value<float>();
	return v;
}
Example #15
0
void readGeometry(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		std::string name = iter->first;
		geometry* geom;
		if (name == "cube")
			geom = createBox();
		else if (name == "tetrahedron")
			geom = createTetrahedron();
		else if (name == "pyramid")
			geom = createPyramid();
		else if (name == "disk")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			geom = createDisk(slices);
		}
		else if (name == "cylinder")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createCylinder(stacks, slices);
		}
		else if (name == "sphere")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createSphere(stacks, slices);
		}
		else if (name == "torus")
		{
			float radius = iter->second.get_child("radius").get_value<float>();
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createTorus(radius, stacks, slices);
		}
		else if (name == "plane")
		{
			int width = iter->second.get_child("width").get_value<int>();
			int depth = iter->second.get_child("depth").get_value<int>();
			geom = createPlane(width, depth);
		}
		else if (name == "sierpinski")
		{
			int divisions = iter->second.get_child("divisions").get_value<int>();
			geom = createSierpinski(divisions);
		}
		else
		{
			std::cerr << "Error - Geometry type not recognised: " << name << std::endl;
			exit(EXIT_FAILURE);
		}
		scene->geometry[name] = geom;
	}
}
void traverse_recursive(const boost::property_tree::ptree::path_type &childPath, const boost::property_tree::ptree &child, T method)
{
    using boost::property_tree::ptree;

    method(childPath, child);
    for(ptree::const_iterator it=child.begin(); it!=child.end(); ++it) {
        ptree::path_type curPath = childPath / ptree::path_type(it->first);
        traverse_recursive(curPath, it->second, method);
    }
}
Example #17
0
void printPTree(const boost::property_tree::ptree &pt, const std::string prefix)
{
	std::cout << prefix << "data = \"" << pt.data() << '"' << std::endl;
	using boost::property_tree::ptree;
	for (ptree::const_iterator it = pt.begin(); it != pt.end(); ++it)
	{
		std::cout << prefix << "child = \""  << it->first << '"' << std::endl;
		printPTree(it->second, prefix + "\t");
	}
}
Example #18
0
bool is_list(const boost::property_tree::ptree& pt)
{
	if(!pt.data().empty())
		return false;

	for(bp::ptree::const_iterator it=pt.begin(); it!=pt.end(); ++it)
	{
		if(!it->first.empty())
			return false;
	}
	return true;
}
Example #19
0
core::vector3df getVectorFromJsonArray(const boost::property_tree::ptree& tree) {
	//if position array has correct size, fetch the three elements via incrementing iterator to first element two times
	if(tree.size() == 3) {
		auto begin = tree.begin();
		float x = (begin++)->second.get_value<float>();
		float y = (begin++)->second.get_value<float>();
		float z = begin->second.get_value<float>();
		return core::vector3df(x,y,z);
	} else {
		return core::vector3df();
	}
}
Example #20
0
void readTextures(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		std::string name = iter->first;
		std::string filename = iter->second.get_value<std::string>();
		GLuint image = ilutGLLoadImage((wchar_t*)filename.c_str());
		ILenum error = ilGetError();
		printf("%s\n", iluErrorString(error));
		scene->textures[name] = image;
	}
}
void XSDSchemaParser::parseXSD(const pt::ptree &keys)
{
    for (auto it = keys.begin(); it != keys.end(); ++it)
    {
        //
        // Element parent (a type in realilty) and the element name help figure out how to process the XSD schema element
        std::string elemType = it->first;
        if (elemType == "xs:include")
        {
            std::string schemaFile = getXSDAttributeValue(it->second, "<xmlattr>.schemaLocation");
            if (m_pSchemaItem->addUniqueName(schemaFile))
            {
                parseXSD(schemaFile);
            }
        }
        else if (elemType == "xs:simpleType")
        {
            parseSimpleType(it->second);
        }
        else if (elemType == "xs:complexType")
        {
            parseComplexType(it->second);
        }
        else if (elemType == "xs:attributeGroup")
        {
            parseAttributeGroup(it->second);
        }
        else if (elemType == "xs:attribute")
        {
            parseAttribute(it->second);
        }
        else if (elemType == "xs:sequence")
        {
            parseXSD(it->second.get_child("", pt::ptree()));
        }
        else if (elemType == "xs:element")
        {
            parseElement(it->second);
        }
        else if (elemType == "xs:key")
        {
            parseKey(it->second);
        }
        else if (elemType == "xs:keyref")
        {
            parseKeyRef(it->second);
        }
    }
}
Example #22
0
void readObjects(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		render_object* object = new render_object();
		std::string name = iter->first;
		std::string geom = iter->second.get_child("geometry").get_value<std::string>();
		object->geometry = scene->geometry[geom];
		std::string mat = iter->second.get_child("material").get_value<std::string>();
		object->material = scene->material[mat];
		readTransform(object, iter->second.get_child("transform"));
		scene->objects[name] = object;
	}
}
Example #23
0
bool get_string_list(const boost::property_tree::ptree& pt, std::vector<std::string>& seq)
{
	typedef bp::ptree::const_iterator c_it;
	std::vector<std::string> seq2;

	for(c_it it=pt.begin(); it!=pt.end(); ++it)
	{
		if(!it->first.empty() || !it->second.empty())
			return false;
		std::string stripped = pystring::strip(it->second.data());
		seq2.push_back(stripped);
	}

	seq.insert(seq.end(), seq2.begin(), seq2.end());
	return true;
}
// returns the number of comparisons completed, throws on failure.
Size Tester::compareResults(const ResultSet& leftResultSet, const ResultSet& rightResultSet,
		                    const boost::property_tree::ptree& pt) // will throw on failure
{

	Size comparisonsDone = 0;
	writeDiagnostics("Comparing results with: \nleft result:\n" + toString(leftResultSet)
		             + "right result:\n"                        + toString(rightResultSet) 
					 + "and property tree:\n"                   + toString(pt),
					 high, "Tester::compareResults");

	boost::property_tree::ptree::const_iterator iter = pt.begin();
    while(iter != pt.end())
    {  
	    if(iter->first == "comparison")
		{
			std::string categoryStr = pt_get<std::string>(iter->second, "category");
			ResultCategory category = stringToResultCategory(categoryStr);
			Real leftVal = leftResultSet.getValue(category);
	
			std::string comparison  = pt_get<std::string>(iter->second, "comparison_type");
			Real        tol         = pt_get<Real>       (iter->second, "tolerance");    
			std::string rightSource = pt_get<std::string>(iter->second, "right_source");

			Real rightVal;
			if(rightSource == "right_leg")
				rightVal = rightResultSet.getValue(category);
			else if( rightSource == "constant")
				rightVal = pt_get<Real>(iter->second, "constant");
			else QL_FAIL("'right_source' must be either 'right_leg' or 'constant'. Here it is: " 
				         << rightSource);

			std::string msg = m_currentTestID + "\ncategory:   " + categoryStr; // used when exception is thrown
			doComparison(leftVal, rightVal, comparison, tol, msg); // throws on failure
			comparisonsDone++;
		}
	    iter++;
    }    		
    // when there are no comparisons done, i.e. comparisonsDone == 0,
	// there may have been a problem readin the xml
	// so we will use a diagnostic level of 'low'
	// making it more likely the message will be shown to the user.
	writeDiagnostics("For test: " + m_currentTestID 
		             + ",\nthe number of comparisons done was: " + toString(comparisonsDone)+ "\n", 
		             comparisonsDone > 0 ? high : low, "Tester::compareResults");

	return comparisonsDone;
}
Example #25
0
void readTextures(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		std::string name = iter->first;
		std::string filename = iter->second.get_value<std::string>();
		ILuint texid;
		ilGenImages(1, &texid);
		ilBindImage(texid);
		ILboolean success = ilLoadImage((wchar_t*)filename.c_str());
		if (success)
		{
			success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
			if (!success)
			{
				printf("Error converting %s to RGBA\n", filename);
				ilDeleteImages(1, &texid);
				return;
			}
			GLuint image;
			glGenTextures(1, &image);
			glBindTexture(GL_TEXTURE_2D, image);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
			float maxAnistropy;
			glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnistropy);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnistropy);
			glTexImage2D(GL_TEXTURE_2D, 
						 0, 
						 ilGetInteger(IL_IMAGE_BPP),
						 ilGetInteger(IL_IMAGE_WIDTH),
						 ilGetInteger(IL_IMAGE_HEIGHT),
						 0,
						 ilGetInteger(IL_IMAGE_FORMAT),
						 GL_UNSIGNED_BYTE,
						 ilGetData());
			glGenerateMipmap(GL_TEXTURE_2D);
			scene->textures[name] = image;
			ilDeleteImages(1, &texid);
		}
		else
			printf("Error loading file %s\n", filename);
	}
}
Example #26
0
void readMaterials(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		material* mat = new material();
		std::string name = iter->first;
		mat->data.emissive = readVec4(iter->second.get_child("emmisive"));
		mat->data.ambient = readVec4(iter->second.get_child("ambient"));
		mat->data.diffuse = readVec4(iter->second.get_child("diffuse"));
		mat->data.specular = readVec4(iter->second.get_child("specular"));
		mat->data.shininess = iter->second.get_child("shininess").get_value<float>();
		std::string texture = iter->second.get_child("texture").get_value<std::string>();
		mat->texture = scene->textures[texture];
		mat->create();
		scene->material[name] = mat;
	}
}
void printTree (boost::property_tree::ptree &pt, int level) {
  if (pt.empty()) {
    std::cout << "\""<< pt.data()<< "\"";
  } else {
    if (level) std::cout << std::endl; 
    std::cout << indent(level) << "{" << std::endl;     
    for (boost::property_tree::ptree::iterator pos = pt.begin(); pos != pt.end();) {
      std::cout << indent(level+1) << "\"" << pos->first << "\": "; 
      printTree(pos->second, level + 1); 
      ++pos; 
      if (pos != pt.end()) {
        std::cout << ","; 
      }
      std::cout << std::endl;
    } 
    std::cout << indent(level) << " }";     
  } 
  return; 
}
// Reads in textures from the scene file
void readTextures(scene_data* scene, const boost::property_tree::ptree& pt)
{
	// Iterate through all the sub branches and read in the textures accordingly
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		// Get the name of the texture
		std::string name = iter->first;

		// Get the filename
		std::string filename = iter->second.get_value<std::string>();

		// Create the texture from the filename
		texture* tex = new texture(filename);
		if (!tex->create())
			printf("Error loading texture: %s\n", filename);
		else
			scene->textures[name] = tex;
	}
}
Example #29
0
void harp::mpi_group::load ( boost::mpi::communicator const & comm, boost::property_tree::ptree const & tree ) {

  handle_.reset();

  boost::property_tree::ptree psf_tree = tree.get_child ( "psf" );
  handle_ = mpi_load_psf ( comm, psf_tree );

  imgs_.clear();

  boost::property_tree::ptree::const_iterator v = tree.begin();

  while ( v != tree.end() ) {

    if ( v->first == "image" ) {
      imgs_.push_back ( mpi_load_image ( comm, v->second ) );
    }

    ++v;
  }

  return;
}
void
mergePropertyTrees (boost::property_tree::ptree &ptMerged,
                    const boost::property_tree::ptree &ptSecond, int level )
{
  // Value or object or array
  if (level > 0 && ptSecond.empty() ) {
    // Copy value
    ptMerged = ptSecond;
  } else if (level > 0 && ptSecond.count (std::string() ) == ptSecond.size() ) {
    // Copy array
    ptMerged = ptSecond;
  } else {
    auto it = ptSecond.begin();

    for (; it != ptSecond.end(); ++it) {
      boost::property_tree::ptree child = ptMerged.get_child (it->first.data(),
                                          boost::property_tree::ptree() );
      mergePropertyTrees (child, it->second, level + 1);

      ptMerged.erase (it->first.data() );
      ptMerged.add_child (it->first.data(), child);
    }
  }
}