Specify mount points from command line

This commit is contained in:
Thomas Krijnen
2017-11-24 12:15:08 +01:00
parent 0f0d060177
commit 839dd9aed6
3 changed files with 39 additions and 3 deletions
+6 -1
View File
@@ -108,8 +108,11 @@ int main(int argc, char** argv) {
std::string bounds, hdf5_profile;
uint32_t hdf5_chunk_size;
std::vector<std::string> entity_vector;
std::vector<std::string> hdf5_ref_attributes;
std::vector<std::string> hdf5_mount_points;
boost::program_options::options_description geom_options;
geom_options.add_options()
("plan",
@@ -161,6 +164,8 @@ int main(int argc, char** argv) {
("hdf5-fix-global-id", "")
("hdf5-instantiate-inverse", "")
("hdf5-instantiate-select", "")
("hdf5-mount", boost::program_options::value< std::vector<std::string> >(&hdf5_mount_points)->multitoken(),
"")
("hdf5-chunk-size", boost::program_options::value(&hdf5_chunk_size), "")
("hdf5-ref-attributes", boost::program_options::value< std::vector<std::string> >(&hdf5_ref_attributes)->multitoken(),
"")
@@ -322,7 +327,7 @@ int main(int argc, char** argv) {
}
} else if (input_extension == ".hdf") {
std::ofstream fs(output_filename.c_str());
IfcParse::IfcHdf5File::convert_to_spf(input_filename, fs);
IfcParse::IfcHdf5File::convert_to_spf(input_filename, fs, hdf5_mount_points);
success = true;
} else {
Logger::Message(Logger::LOG_ERROR, "Unknown input extension");
+32 -1
View File
@@ -2331,8 +2331,31 @@ void write_spf_header(const H5::Group& group, std::ostream& out) {
spf_header.write(out);
}
void IfcParse::IfcHdf5File::convert_to_spf(const std::string& name, std::ostream& output) {
void IfcParse::IfcHdf5File::convert_to_spf(const std::string& name, std::ostream& output, const boost::optional< std::vector<std::string> >& mount_points) {
H5::H5File f(name, H5F_ACC_RDONLY);
std::vector<H5::H5File*> children;
if (mount_points) {
std::transform(mount_points->begin(), mount_points->end(), std::back_inserter(children), [&f](const std::string& directive) {
auto split_string = [](const std::string& s, std::string& left, std::string& right) {
const size_t pos = s.find('=');
left = s.substr(0, pos);
if (pos != std::string::npos) {
right = s.substr(pos + 1);
}
};
std::string point, path;
split_string(directive, point, path);
H5::H5File* child = new H5::H5File(path, H5F_ACC_RDONLY);
f.mount(point, *child, H5::PropList::DEFAULT);
return child;
});
}
std::map<std::string, int> offset_mapping;
@@ -2352,4 +2375,12 @@ void IfcParse::IfcHdf5File::convert_to_spf(const std::string& name, std::ostream
output << "ENDSEC;\nEND-ISO-10303-21;\n";
}
}
std::for_each(children.begin(), children.end(), [](H5::H5File* child) {
child->close();
delete child;
});
f.close();
}
+1 -1
View File
@@ -211,7 +211,7 @@ namespace IfcParse {
{
};
static void convert_to_spf(const std::string& name, std::ostream& output);
static void convert_to_spf(const std::string& name, std::ostream& output, const boost::optional< std::vector<std::string> >& mount_points = boost::none);
};
}