mirror of https://github.com/KLayout/klayout.git
[consider merging] Adding an option '-of|--format' to strmxor and strmclip to specify the output format instead of taking it from the suffix
This commit is contained in:
parent
9f92c4eaa4
commit
7ae87404a0
|
|
@ -98,6 +98,20 @@ const std::string GenericWriterOptions::dxf_format_name = "DXF";
|
||||||
const std::string GenericWriterOptions::cif_format_name = "CIF";
|
const std::string GenericWriterOptions::cif_format_name = "CIF";
|
||||||
const std::string GenericWriterOptions::mag_format_name = "MAG";
|
const std::string GenericWriterOptions::mag_format_name = "MAG";
|
||||||
|
|
||||||
|
std::vector<std::string>
|
||||||
|
GenericWriterOptions::all_format_names ()
|
||||||
|
{
|
||||||
|
std::vector<std::string> names;
|
||||||
|
names.push_back (gds2_format_name);
|
||||||
|
names.push_back (gds2text_format_name);
|
||||||
|
names.push_back (oasis_format_name);
|
||||||
|
names.push_back (lstream_format_name);
|
||||||
|
names.push_back (dxf_format_name);
|
||||||
|
names.push_back (cif_format_name);
|
||||||
|
names.push_back (mag_format_name);
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::string &format)
|
GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::string &format)
|
||||||
{
|
{
|
||||||
|
|
@ -109,6 +123,15 @@ GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::strin
|
||||||
"given factor."
|
"given factor."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (format.empty ()) {
|
||||||
|
cmd << tl::arg (group +
|
||||||
|
"-of|--format=format", &m_format, "Specifies the output format",
|
||||||
|
"By default, the output format is derived from the file name suffix. "
|
||||||
|
"You can also specify the format directly using this option. Allowed format names are: "
|
||||||
|
+ tl::join (all_format_names (), ", ")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (format.empty () || format == gds2_format_name || format == gds2text_format_name || format == oasis_format_name) {
|
if (format.empty () || format == gds2_format_name || format == gds2text_format_name || format == oasis_format_name) {
|
||||||
cmd << tl::arg (group +
|
cmd << tl::arg (group +
|
||||||
"-od|--dbu-out=dbu", &m_dbu, "Uses the specified database unit",
|
"-od|--dbu-out=dbu", &m_dbu, "Uses the specified database unit",
|
||||||
|
|
@ -426,6 +449,22 @@ GenericWriterOptions::configure (db::SaveLayoutOptions &save_options, const db::
|
||||||
save_options.set_keep_instances (m_keep_instances);
|
save_options.set_keep_instances (m_keep_instances);
|
||||||
save_options.set_write_context_info (m_write_context_info);
|
save_options.set_write_context_info (m_write_context_info);
|
||||||
|
|
||||||
|
if (! m_format.empty ()) {
|
||||||
|
|
||||||
|
// check, if the format name is a valid one
|
||||||
|
std::vector<std::string> af = all_format_names ();
|
||||||
|
auto i = af.begin ();
|
||||||
|
while (i != af.end () && *i != m_format) {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if (i == af.end ()) {
|
||||||
|
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Invalid fornat name %s. Allowed names are: %s")), m_format, tl::join (af, ", ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
save_options.set_format (m_format);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
save_options.set_option_by_name ("gds2_max_vertex_count", m_gds2_max_vertex_count);
|
save_options.set_option_by_name ("gds2_max_vertex_count", m_gds2_max_vertex_count);
|
||||||
save_options.set_option_by_name ("gds2_no_zero_length_paths", m_gds2_no_zero_length_paths);
|
save_options.set_option_by_name ("gds2_no_zero_length_paths", m_gds2_no_zero_length_paths);
|
||||||
save_options.set_option_by_name ("gds2_multi_xy_records", m_gds2_multi_xy_records);
|
save_options.set_option_by_name ("gds2_multi_xy_records", m_gds2_multi_xy_records);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "bdCommon.h"
|
#include "bdCommon.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace tl
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
@ -60,6 +61,11 @@ public:
|
||||||
*/
|
*/
|
||||||
GenericWriterOptions (const db::SaveLayoutOptions &options);
|
GenericWriterOptions (const db::SaveLayoutOptions &options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets a list with all format names available
|
||||||
|
*/
|
||||||
|
static std::vector<std::string> all_format_names ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds the generic options to the command line parser object
|
* @brief Adds the generic options to the command line parser object
|
||||||
* The format string gives a hint about the target format. Certain options will be
|
* The format string gives a hint about the target format. Certain options will be
|
||||||
|
|
@ -114,6 +120,7 @@ public:
|
||||||
static const std::string mag_format_name;
|
static const std::string mag_format_name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_format;
|
||||||
double m_scale_factor;
|
double m_scale_factor;
|
||||||
double m_dbu;
|
double m_dbu;
|
||||||
bool m_dont_write_empty_cells;
|
bool m_dont_write_empty_cells;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue