Massive reduction of Qt dependencies, but also massive refactoring.

This commit is contained in:
Matthias Koefferlein 2018-07-03 00:51:36 +02:00
parent c532b75338
commit a82adbbe83
91 changed files with 823 additions and 728 deletions

View File

@ -24,7 +24,9 @@
#include "tlStaticObjects.h"
#include "rba.h"
#if defined(HAVE_QT)
#include <QCoreApplication>
#endif
BD_PUBLIC int BD_TARGET (int argc, char *argv []);
@ -33,7 +35,9 @@ BD_PUBLIC int BD_TARGET (int argc, char *argv []);
*/
static int main_cont (int &argc, char **argv)
{
#if defined(HAVE_QT)
QCoreApplication app (argc, argv);
#endif
return bd::_main_impl (&BD_TARGET, argc, argv);
}

View File

@ -29,6 +29,7 @@
#include "dbReader.h"
#include "tlLog.h"
#include "tlCommandLineParser.h"
#include "tlFileUtils.h"
#include "rba.h"
#include "pya.h"
#include "gsi.h"
@ -36,8 +37,6 @@
#include "libForceLink.h"
#include "rdbForceLink.h"
#include <QFileInfo>
struct RunnerData
{
std::string script;
@ -93,15 +92,15 @@ BD_PUBLIC int strmrun (int argc, char *argv[])
python.define_variable (v->first, v->second);
}
std::string script = tl::to_string (QFileInfo (tl::to_qstring (data.script)).absoluteFilePath ());
std::string script = tl::absolute_file_path (data.script);
std::string ext = tl::to_string (QFileInfo (tl::to_qstring (data.script)).suffix ());
std::string ext = tl::extension (data.script);
if (ext == "py") {
python.load_file (script);
} else if (ext == "rb") {
ruby.load_file (script);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Unknown suffix \"%1\" - must be either .rb or .py").arg (tl::to_qstring (ext))));
throw tl::Exception (tl::to_string (tr ("Unknown suffix \"%s\" - must be either .rb or .py")), ext);
}
return 0;

View File

@ -208,8 +208,12 @@ HEADERS = \
dbPlugin.h \
dbInit.h
RESOURCES = \
dbResources.qrc
!equals(HAVE_QT, "0") {
RESOURCES = \
dbResources.qrc \
}
INCLUDEPATH += $$TL_INC $$GSI_INC
DEPENDPATH += $$TL_INC $$GSI_INC

View File

@ -24,6 +24,7 @@
#include "dbCommonReader.h"
#include "dbStream.h"
#include "tlXMLParser.h"
namespace db
{
@ -74,7 +75,6 @@ public:
return false;
}
#if defined(HAVE_XML)
virtual tl::XMLElementBase *xml_reader_options_element () const
{
return new db::ReaderOptionsXMLElement<db::CommonReaderOptions> ("common",
@ -84,7 +84,6 @@ public:
tl::make_member (&db::CommonReaderOptions::enable_text_objects, "enable-text-objects")
);
}
#endif
};
static tl::RegisteredClass<db::StreamFormatDeclaration> reader_decl (new CommonFormatDeclaration (), 20, "Common");

View File

@ -26,10 +26,12 @@
#include "dbEdgeProcessor.h"
#include "dbReader.h"
#include "tlStream.h"
#include "tlFileUtils.h"
#include <QDir>
#include <QResource>
#include <QByteArray>
#if defined(HAVE_QT)
# include <QResource>
# include <QByteArray>
#endif
#include <cctype>
@ -141,6 +143,7 @@ TextGenerator::text_as_region (const std::string &t, double target_dbu, double m
return region;
}
#if defined(HAVE_QT)
void
TextGenerator::load_from_resource (const std::string &name)
{
@ -169,6 +172,7 @@ TextGenerator::load_from_resource (const std::string &name)
m_name = tl::to_string (QFileInfo (tl::to_qstring (name)).baseName ());
}
#endif
void
TextGenerator::load_from_file (const std::string &filename)
@ -188,7 +192,7 @@ TextGenerator::load_from_file (const std::string &filename)
read_from_layout (layout, l1.second, l2.second, l3.second);
}
m_name = tl::to_string (QFileInfo (tl::to_qstring (filename)).baseName ());
m_name = tl::basename (filename);
}
void
@ -318,6 +322,7 @@ TextGenerator::generators ()
s_fonts.clear ();
#if defined(HAVE_QT)
const char *resources[] = {
":/fonts/std_font.gds"
};
@ -332,23 +337,21 @@ TextGenerator::generators ()
s_fonts.pop_back ();
}
}
#endif
// scan for font files
for (std::vector<std::string>::const_iterator p = s_font_paths.begin (); p != s_font_paths.end (); ++p) {
QDir fp = QDir (tl::to_qstring (*p));
if (fp.exists ()) {
if (tl::file_exists (*p)) {
QStringList name_filters;
name_filters << QString::fromUtf8 ("*");
QStringList font_files = fp.entryList (name_filters, QDir::Files);
for (QStringList::const_iterator ff = font_files.begin (); ff != font_files.end (); ++ff) {
std::vector<std::string> font_files = tl::dir_entries (*p, true, false, true);
for (std::vector<std::string>::const_iterator ff = font_files.begin (); ff != font_files.end (); ++ff) {
try {
tl::log << "Loading font from " << tl::to_string (fp.filePath (*ff)) << " ..";
std::string ffp = tl::combine_path (*p, *ff);
tl::log << "Loading font from " << ffp << " ..";
s_fonts.push_back (TextGenerator ());
s_fonts.back ().load_from_file (tl::to_string (fp.filePath (*ff)));
s_fonts.back ().load_from_file (ffp);
} catch (tl::Exception &ex) {
tl::error << ex.msg ();
s_fonts.pop_back ();

View File

@ -76,10 +76,12 @@ public:
*/
TextGenerator ();
#if defined(HAVE_QT)
/**
* @brief Loads the font from the given resource
*/
void load_from_resource (const std::string &name);
#endif
/**
* @brief Loads the font from the given file

View File

@ -26,6 +26,8 @@
#include "tlException.h"
#include "tlLog.h"
#include "tlString.h"
#include "tlFileUtils.h"
#include "tlGlobPattern.h"
#ifdef _WIN32
# include <windows.h>
@ -34,9 +36,6 @@
#endif
#include <set>
#include <QFileInfo>
#include <QStringList>
#include <QDir>
namespace db
{
@ -108,8 +107,7 @@ get_module_path ()
wchar_t buffer[MAX_PATH];
int len;
if ((len = GetModuleFileName(h_module, buffer, MAX_PATH)) > 0) {
QFileInfo fi (QString::fromUtf16 ((const ushort *) buffer, len));
return tl::to_string (fi.absolutePath ());
return tl::absolute_file_path (tl::to_string (std::wstring (buffer, 0, len)));
}
}
@ -121,8 +119,7 @@ get_module_path ()
Dl_info info = { };
if (dladdr ((void *) &init, &info)) {
QFileInfo fi (QString::fromLocal8Bit (info.dli_fname));
return tl::to_string (fi.absolutePath ());
return tl::absolute_file_path (tl::to_string_from_local (info.dli_fname));
} else {
return std::string ();
}
@ -151,36 +148,37 @@ void init (const std::vector<std::string> &_paths)
// look next to the db library, but in "db_plugins" directory
const char *db_plugin_dir = "db_plugins";
std::string pp = tl::to_string (QDir (tl::to_qstring (*p)).filePath (QString::fromUtf8 (db_plugin_dir)));
std::string pp = tl::combine_path (*p, db_plugin_dir);
QStringList name_filters;
std::vector<std::string> ee = tl::dir_entries (pp, true, false);
tl::GlobPattern pattern;
#if defined(_WIN32)
name_filters << QString::fromUtf8 ("*.dll");
pattern.set_case_sensitive (false);
pattern = std::string ("*.dll");
#else
name_filters << QString::fromUtf8 ("*.so");
pattern = std::string ("*.so");
#endif
QStringList inst_modules = QDir (tl::to_qstring (pp)).entryList (name_filters);
inst_modules.sort ();
std::vector<std::string> inst_modules;
for (std::vector<std::string>::const_iterator e = ee.begin (); e != ee.end (); ++e) {
if (pattern.match (*e)) {
inst_modules.push_back (*e);
}
}
for (QStringList::const_iterator im = inst_modules.begin (); im != inst_modules.end (); ++im) {
std::sort (inst_modules.begin (), inst_modules.end ());
QFileInfo dbp_file (tl::to_qstring (pp), *im);
if (dbp_file.exists () && dbp_file.isReadable ()) {
std::string mn = tl::to_string (dbp_file.fileName ());
if (modules.find (mn) == modules.end ()) {
std::string m = tl::to_string (dbp_file.absoluteFilePath ());
try {
s_plugins.push_back (load_plugin (m));
modules.insert (mn);
} catch (tl::Exception (&ex)) {
tl::error << ex.msg ();
}
for (std::vector<std::string>::const_iterator im = inst_modules.begin (); im != inst_modules.end (); ++im) {
std::string imp = tl::combine_path (pp, *im);
if (modules.find (*im) == modules.end ()) {
try {
s_plugins.push_back (load_plugin (imp));
modules.insert (*im);
} catch (tl::Exception (&ex)) {
tl::error << ex.msg ();
}
}
}

View File

@ -23,6 +23,7 @@
#include "dbStream.h"
#include "tlClassRegistry.h"
#include "tlXMLParser.h"
#include <string.h>
@ -38,7 +39,6 @@ namespace db
// ------------------------------------------------------------------
// Implementation of load_options_xml_element_list
#if defined(HAVE_XML)
tl::XMLElementList load_options_xml_element_list ()
{
@ -74,8 +74,6 @@ tl::XMLElementList save_options_xml_element_list ()
return elements;
}
#endif
}

View File

@ -31,10 +31,8 @@
#include "dbLoadLayoutOptions.h"
#include "tlClassRegistry.h"
#if defined(HAVE_XML)
# include "tlXMLParser.h"
# include "tlXMLWriter.h"
#endif
#include "tlXMLParser.h"
#include "tlXMLWriter.h"
#include <string>
#include <vector>
@ -111,7 +109,6 @@ public:
*/
virtual bool can_write () const = 0;
#if defined(HAVE_XML)
/**
* @brief Delivers the XMLElement object that represents the reader options within a technology XML tree
*
@ -139,10 +136,8 @@ public:
{
return 0;
}
#endif
};
#if defined(HAVE_XML)
/**
* @brief A helper class for the XML serialization of the stream options (custom read adaptor)
*
@ -303,7 +298,6 @@ DB_PUBLIC tl::XMLElementList load_options_xml_element_list ();
* @brief Returns the XMLElement list that can represent a db::SaveLayoutOptions object
*/
DB_PUBLIC tl::XMLElementList save_options_xml_element_list ();
#endif
}

View File

@ -23,12 +23,10 @@
#include "dbTechnology.h"
#include "dbStream.h"
#include "tlFileUtils.h"
#include <stdio.h>
#include <QDir>
#include <QFileInfo>
namespace tl
{
template<> DB_PUBLIC tl::Registrar<db::TechnologyComponentProvider> *tl::Registrar<db::TechnologyComponentProvider>::instance = 0;
@ -148,7 +146,7 @@ Technologies::add_tech (Technology *tech, bool replace_same)
if (replace_same) {
*t = *tech;
} else {
throw tl::Exception (tl::to_string (tr ("A technology with this name already exists: %1").arg (tl::to_qstring (tech->name ()))));
throw tl::Exception (tl::to_string (tr ("A technology with this name already exists: ")) + tech->name ());
}
} else {
m_technologies.push_back (tech_ptr.release ());
@ -421,14 +419,8 @@ Technology::correct_path (const std::string &fp) const
{
if (base_path ().empty ()) {
return fp;
}
QString rfp = QDir (tl::to_qstring (base_path ())).relativeFilePath (tl::to_qstring (fp));
if (rfp.startsWith (QString::fromUtf8 (".."))) {
// upwards or beside - don't correct:
return fp;
} else {
return tl::to_string (rfp);
return tl::relative_path (base_path (), fp);
}
}
@ -440,8 +432,7 @@ Technology::load (const std::string &fn)
xml_struct.parse (source, *this);
// use the tech file's path as the default base path
std::string lyt_file = tl::to_string (QFileInfo (tl::to_qstring (fn)).absoluteDir ().path ());
set_default_base_path (lyt_file);
set_default_base_path (tl::absolute_path (fn));
set_tech_file_path (fn);
}
@ -461,11 +452,10 @@ Technology::build_effective_path (const std::string &p) const
return p;
}
QFileInfo f (tl::to_qstring (p));
if (f.isAbsolute ()) {
if (tl::is_absolute (p)) {
return p;
} else {
return tl::to_string (QDir (tl::to_qstring (base_path ())).filePath (tl::to_qstring (p)));
return tl::combine_path (base_path (), p);
}
}

View File

@ -29,9 +29,7 @@
#include "tlStableVector.h"
#include "tlString.h"
#include "tlEvents.h"
#if defined(HAVE_XML)
# include "tlXMLParser.h"
#endif
#include "tlXMLParser.h"
#include "tlTypeTraits.h"
#include "tlClassRegistry.h"
#include "dbStreamLayers.h"
@ -530,12 +528,10 @@ public:
*/
void save (const std::string &fn) const;
#if defined(HAVE_XML)
/**
* @brief Delivers the XMLElementList that specifies the technology's XML representation
*/
static tl::XMLElementList xml_elements ();
#endif
/**
* @brief Sets the technology component by the component name
@ -726,18 +722,14 @@ public:
*/
virtual TechnologyComponent *create_component () const = 0;
#if defined(HAVE_XML)
/**
* @brief Delivers the XMLElement object that represents this component within a technology XML tree
*
* The object returned is destroyed by the caller.
*/
virtual tl::XMLElementBase *xml_element () const = 0;
#endif
};
#if defined(HAVE_XML)
/**
* @brief A helper class for the XML serialization of the technology component (custom read adaptor)
*/
@ -758,7 +750,7 @@ public:
{
const TC *tc = dynamic_cast<const TC *> ((const_cast <db::Technology *> (mp_t))->component_by_name (m_name));
if (! tc) {
throw tl::Exception (tl::to_string (QObject::tr ("Unknown technology component: ")) + m_name);
throw tl::Exception (tl::to_string (tr ("Unknown technology component: ")) + m_name);
}
return *tc;
@ -809,7 +801,7 @@ public:
} else {
tc = dynamic_cast<TC *> (tc_basic->clone ());
if (! tc) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid technology component: ")) + m_name);
throw tl::Exception (tl::to_string (tr ("Invalid technology component: ")) + m_name);
}
}
@ -856,8 +848,6 @@ public:
}
};
#endif
}
namespace tl

View File

@ -65,10 +65,12 @@ static std::vector<const db::TextGenerator *> generators ()
}
Class<db::TextGenerator> decl_TextGenerator ("db", "TextGenerator",
#if defined(HAVE_QT)
method ("load_from_resource", &db::TextGenerator::load_from_resource, arg ("resource_path"),
"@brief Loads the given resource data (as layout data) into the generator\n"
"See the description of the class how the layout data is read."
) +
#endif
method ("load_from_file", &db::TextGenerator::load_from_file, arg ("path"),
"@brief Loads the given file into the generator\n"
"See the description of the class how the layout data is read."

View File

@ -22,10 +22,8 @@
#include "gsiDecl.h"
#include "dbTechnology.h"
#if defined(HAVE_XML)
# include "tlXMLWriter.h"
# include "tlXMLParser.h"
#endif
#include "tlXMLWriter.h"
#include "tlXMLParser.h"
namespace gsi
{
@ -62,7 +60,6 @@ static bool has_technology (const std::string &name)
return db::Technologies::instance ()->has_technology (name);
}
#if defined(HAVE_XML)
static std::string technologies_to_xml ()
{
return db::Technologies::instance ()->to_xml ();
@ -94,7 +91,6 @@ static std::string technology_to_xml (const db::Technology *tech)
return os.string ();
}
}
#endif
static db::TechnologyComponent *get_component (db::Technology *tech, const std::string &name)
{
@ -280,7 +276,6 @@ gsi::Class<db::Technology> technology_decl ("db", "Technology",
gsi::method ("remove_technology", &remove_technology, gsi::arg ("name"),
"@brief Removes the technology with the given name\n"
) +
#if defined(HAVE_XML)
gsi::method ("technologies_to_xml", &technologies_to_xml,
"@brief Returns a XML representation of all technologies registered in the system\n"
"\n"
@ -304,7 +299,6 @@ gsi::Class<db::Technology> technology_decl ("db", "Technology",
"\n"
"See \\technology_to_xml for details."
) +
#endif
gsi::method_ext ("component_names", &get_component_names,
"@brief Gets the names of all components available for \\component"
) +

View File

@ -35,7 +35,6 @@
#include "tlStaticObjects.h"
#include "tlUnitTest.h"
#include <QDir>
#include <memory>
class LIBT_PD

View File

@ -32,8 +32,6 @@
#include "tlStream.h"
#include "tlUnitTest.h"
#include <QDir>
class PD
: public db::PCellDeclaration
{

View File

@ -79,7 +79,6 @@ equals(HAVE_QT, "0") {
} else {
DEFINES += HAVE_QT
DEFINES += HAVE_XML
QT += network xml sql
equals(HAVE_QT5, "1") {

View File

@ -4,22 +4,29 @@ include(klayout.pri)
TEMPLATE = subdirs
SUBDIRS = \
klayout_main \
unit_tests \
tl \
gsi \
db \
rdb \
lym \
laybasic \
lay \
ant \
img \
edt \
lib \
plugins \
buddies \
fontgen \
plugins \
!equals(HAVE_QT, "0") {
# TODO: make unit_tests capable of running without Qt
SUBDIRS += \
unit_tests \
klayout_main \
laybasic \
lay \
ant \
lym \
img \
edt \
fontgen \
}
LANG_DEPENDS =
MAIN_DEPENDS =
@ -39,7 +46,7 @@ equals(HAVE_PYTHON, "1") {
LANG_DEPENDS += pya
pya.depends += gsi db
SUBDIRS += pymod
pymod.depends += pya lay
pymod.depends += pya
} else {
SUBDIRS += pyastub
pyastub.depends += gsi
@ -49,30 +56,45 @@ equals(HAVE_PYTHON, "1") {
gsi.depends += tl
db.depends += gsi
rdb.depends += db
laybasic.depends += rdb
ant.depends += laybasic
img.depends += laybasic
edt.depends += laybasic
equals(HAVE_RUBY, "1") {
SUBDIRS += drc
MAIN_DEPENDS += drc
drc.depends += rdb lym
}
lym.depends += gsi $$LANG_DEPENDS
lay.depends += laybasic ant img edt lym
lib.depends += db
equals(HAVE_QTBINDINGS, "1") {
SUBDIRS += gsiqt
gsiqt.depends += gsi db
laybasic.depends += gsiqt
pymod.depends += gsiqt
buddies.depends += plugins $$LANG_DEPENDS
plugins.depends += lib rdb db
!equals(HAVE_QT, "0") {
equals(HAVE_PYTHON, "1") {
pymod.depends += lay
}
equals(HAVE_RUBY, "1") {
SUBDIRS += drc
MAIN_DEPENDS += drc
drc.depends += rdb lym
}
equals(HAVE_QTBINDINGS, "1") {
SUBDIRS += gsiqt
gsiqt.depends += gsi db
laybasic.depends += gsiqt
equals(HAVE_PYTHON, "1") {
pymod.depends += gsiqt
}
}
plugins.depends += lay ant
laybasic.depends += rdb
ant.depends += laybasic
img.depends += laybasic
edt.depends += laybasic
lym.depends += gsi $$LANG_DEPENDS
lay.depends += laybasic ant img edt lym
klayout_main.depends += plugins $$MAIN_DEPENDS
unit_tests.depends += plugins $$MAIN_DEPENDS
}
plugins.depends += lay lib rdb ant
buddies.depends += plugins $$LANG_DEPENDS
klayout_main.depends += plugins $$MAIN_DEPENDS
unit_tests.depends += plugins $$MAIN_DEPENDS

View File

@ -216,59 +216,59 @@ BasicArc::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius1);
parameters.push_back (db::PCellParameterDeclaration ("radius1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius 1")));
parameters.back ().set_description (tl::to_string (tr ("Radius 1")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: radius
tl_assert (parameters.size () == p_radius2);
parameters.push_back (db::PCellParameterDeclaration ("radius2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius 2")));
parameters.back ().set_description (tl::to_string (tr ("Radius 2")));
parameters.back ().set_default (0.2);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #3: start angle
tl_assert (parameters.size () == p_start_angle);
parameters.push_back (db::PCellParameterDeclaration ("a1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Start angle")));
parameters.back ().set_description (tl::to_string (tr ("Start angle")));
parameters.back ().set_default (0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("degree")));
parameters.back ().set_unit (tl::to_string (tr ("degree")));
// parameter #4: end angle
tl_assert (parameters.size () == p_end_angle);
parameters.push_back (db::PCellParameterDeclaration ("a2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("End angle")));
parameters.back ().set_description (tl::to_string (tr ("End angle")));
parameters.back ().set_default (90);
parameters.back ().set_unit (tl::to_string (QObject::tr ("degree")));
parameters.back ().set_unit (tl::to_string (tr ("degree")));
// parameter #5: handle 1
tl_assert (parameters.size () == p_handle1);
parameters.push_back (db::PCellParameterDeclaration ("handle1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (0.1, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("S")));
parameters.back ().set_description (tl::to_string (tr ("S")));
// parameter #6: handle 1
tl_assert (parameters.size () == p_handle2);
parameters.push_back (db::PCellParameterDeclaration ("handle2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (0, 0.1));
parameters.back ().set_description (tl::to_string (QObject::tr ("E")));
parameters.back ().set_description (tl::to_string (tr ("E")));
// parameter #7: number of points
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points")));
parameters.back ().set_description (tl::to_string (tr ("Number of points")));
parameters.back ().set_default (64);
// parameter #8: used radius 1

View File

@ -154,28 +154,28 @@ BasicCircle::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius);
parameters.push_back (db::PCellParameterDeclaration ("radius"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius")));
parameters.back ().set_description (tl::to_string (tr ("Radius")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: handle
tl_assert (parameters.size () == p_handle);
parameters.push_back (db::PCellParameterDeclaration ("handle"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (-0.1, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("R")));
parameters.back ().set_description (tl::to_string (tr ("R")));
// parameter #3: number of points
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points")));
parameters.back ().set_description (tl::to_string (tr ("Number of points")));
parameters.back ().set_default (64);
// parameter #4: used radius

View File

@ -181,43 +181,43 @@ BasicDonut::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius1
tl_assert (parameters.size () == p_radius1);
parameters.push_back (db::PCellParameterDeclaration ("radius1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius 1")));
parameters.back ().set_description (tl::to_string (tr ("Radius 1")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: radius2
tl_assert (parameters.size () == p_radius2);
parameters.push_back (db::PCellParameterDeclaration ("radius2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius 2")));
parameters.back ().set_description (tl::to_string (tr ("Radius 2")));
parameters.back ().set_default (0.2);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #3: handle 1
tl_assert (parameters.size () == p_handle1);
parameters.push_back (db::PCellParameterDeclaration ("handle1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (-0.1, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("R1")));
parameters.back ().set_description (tl::to_string (tr ("R1")));
// parameter #4: handle 2
tl_assert (parameters.size () == p_handle2);
parameters.push_back (db::PCellParameterDeclaration ("handle2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (-0.2, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("R2")));
parameters.back ().set_description (tl::to_string (tr ("R2")));
// parameter #5: number of points
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points")));
parameters.back ().set_description (tl::to_string (tr ("Number of points")));
parameters.back ().set_default (64);
// parameter #6: used radius 1

View File

@ -185,43 +185,43 @@ BasicEllipse::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: x radius
tl_assert (parameters.size () == p_radius_x);
parameters.push_back (db::PCellParameterDeclaration ("radius_x"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius (x)")));
parameters.back ().set_description (tl::to_string (tr ("Radius (x)")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: y radius
tl_assert (parameters.size () == p_radius_y);
parameters.push_back (db::PCellParameterDeclaration ("radius_y"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius (y)")));
parameters.back ().set_description (tl::to_string (tr ("Radius (y)")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #3: x handle
tl_assert (parameters.size () == p_handle_x);
parameters.push_back (db::PCellParameterDeclaration ("handle_x"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (-0.2, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("Rx")));
parameters.back ().set_description (tl::to_string (tr ("Rx")));
// parameter #4: x handle
tl_assert (parameters.size () == p_handle_y);
parameters.push_back (db::PCellParameterDeclaration ("handle_y"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (-0.1, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("Ry")));
parameters.back ().set_description (tl::to_string (tr ("Ry")));
// parameter #5: number of points
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points")));
parameters.back ().set_description (tl::to_string (tr ("Number of points")));
parameters.back ().set_default (64);
// parameter #6: used x radius

View File

@ -198,51 +198,51 @@ BasicPie::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius);
parameters.push_back (db::PCellParameterDeclaration ("radius"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius")));
parameters.back ().set_description (tl::to_string (tr ("Radius")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: start angle
tl_assert (parameters.size () == p_start_angle);
parameters.push_back (db::PCellParameterDeclaration ("a1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Start angle")));
parameters.back ().set_description (tl::to_string (tr ("Start angle")));
parameters.back ().set_default (0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("degree")));
parameters.back ().set_unit (tl::to_string (tr ("degree")));
// parameter #3: end angle
tl_assert (parameters.size () == p_end_angle);
parameters.push_back (db::PCellParameterDeclaration ("a2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("End angle")));
parameters.back ().set_description (tl::to_string (tr ("End angle")));
parameters.back ().set_default (90);
parameters.back ().set_unit (tl::to_string (QObject::tr ("degree")));
parameters.back ().set_unit (tl::to_string (tr ("degree")));
// parameter #4: handle 1
tl_assert (parameters.size () == p_handle1);
parameters.push_back (db::PCellParameterDeclaration ("handle1"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (0.1, 0));
parameters.back ().set_description (tl::to_string (QObject::tr ("S")));
parameters.back ().set_description (tl::to_string (tr ("S")));
// parameter #5: handle 1
tl_assert (parameters.size () == p_handle2);
parameters.push_back (db::PCellParameterDeclaration ("handle2"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_shape);
parameters.back ().set_default (db::DPoint (0, 0.1));
parameters.back ().set_description (tl::to_string (QObject::tr ("E")));
parameters.back ().set_description (tl::to_string (tr ("E")));
// parameter #6: number of points
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points")));
parameters.back ().set_description (tl::to_string (tr ("Number of points")));
parameters.back ().set_default (64);
// parameter #7: used radius

View File

@ -120,15 +120,15 @@ BasicRoundPath::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius);
parameters.push_back (db::PCellParameterDeclaration ("radius"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius")));
parameters.back ().set_description (tl::to_string (tr ("Radius")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: handle
tl_assert (parameters.size () == p_path);
@ -144,7 +144,7 @@ BasicRoundPath::get_parameter_declarations () const
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points / full circle.")));
parameters.back ().set_description (tl::to_string (tr ("Number of points / full circle.")));
parameters.back ().set_default (64);
return parameters;

View File

@ -124,15 +124,15 @@ BasicRoundPolygon::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius);
parameters.push_back (db::PCellParameterDeclaration ("radius"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius")));
parameters.back ().set_description (tl::to_string (tr ("Radius")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: handle
tl_assert (parameters.size () == p_polygon);
@ -147,7 +147,7 @@ BasicRoundPolygon::get_parameter_declarations () const
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points / full circle.")));
parameters.back ().set_description (tl::to_string (tr ("Number of points / full circle.")));
parameters.back ().set_default (64);
return parameters;

View File

@ -146,23 +146,23 @@ BasicStrokedPolygon::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter #1: radius
tl_assert (parameters.size () == p_radius);
parameters.push_back (db::PCellParameterDeclaration ("radius"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Radius")));
parameters.back ().set_description (tl::to_string (tr ("Radius")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #2: width
tl_assert (parameters.size () == p_width);
parameters.push_back (db::PCellParameterDeclaration ("width"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Width")));
parameters.back ().set_description (tl::to_string (tr ("Width")));
parameters.back ().set_default (0.1);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter #3: handle
tl_assert (parameters.size () == p_shape);
@ -181,7 +181,7 @@ BasicStrokedPolygon::get_parameter_declarations () const
tl_assert (parameters.size () == p_npoints);
parameters.push_back (db::PCellParameterDeclaration ("npoints"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Number of points / full circle.")));
parameters.back ().set_description (tl::to_string (tr ("Number of points / full circle.")));
parameters.back ().set_default (64);
return parameters;

View File

@ -189,14 +189,14 @@ BasicText::get_parameter_declarations () const
tl_assert (parameters.size () == p_text);
parameters.push_back (db::PCellParameterDeclaration ("text"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_string);
parameters.back ().set_description (tl::to_string (QObject::tr ("Text")));
parameters.back ().set_description (tl::to_string (tr ("Text")));
parameters.back ().set_default ("");
// parameter: font name
tl_assert (parameters.size () == p_font_name);
parameters.push_back (db::PCellParameterDeclaration ("font_name"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_string);
parameters.back ().set_description (tl::to_string (QObject::tr ("Font")));
parameters.back ().set_description (tl::to_string (tr ("Font")));
parameters.back ().set_default (0);
std::vector<tl::Variant> choices;
@ -212,80 +212,80 @@ BasicText::get_parameter_declarations () const
tl_assert (parameters.size () == p_layer);
parameters.push_back (db::PCellParameterDeclaration ("layer"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_layer);
parameters.back ().set_description (tl::to_string (QObject::tr ("Layer")));
parameters.back ().set_description (tl::to_string (tr ("Layer")));
// parameter: magnification
tl_assert (parameters.size () == p_magnification);
parameters.push_back (db::PCellParameterDeclaration ("mag"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Magnification")));
parameters.back ().set_description (tl::to_string (tr ("Magnification")));
parameters.back ().set_default (1.0);
// parameter: inverse
tl_assert (parameters.size () == p_inverse);
parameters.push_back (db::PCellParameterDeclaration ("inverse"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_boolean);
parameters.back ().set_description (tl::to_string (QObject::tr ("Inverse")));
parameters.back ().set_description (tl::to_string (tr ("Inverse")));
parameters.back ().set_default (false);
// parameter: bias
tl_assert (parameters.size () == p_bias);
parameters.push_back (db::PCellParameterDeclaration ("bias"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Bias")));
parameters.back ().set_description (tl::to_string (tr ("Bias")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter: character spacing
tl_assert (parameters.size () == p_char_spacing);
parameters.push_back (db::PCellParameterDeclaration ("cspacing"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Additional character spacing")));
parameters.back ().set_description (tl::to_string (tr ("Additional character spacing")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter: line spacing
tl_assert (parameters.size () == p_line_spacing);
parameters.push_back (db::PCellParameterDeclaration ("lspacing"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Additional line spacing")));
parameters.back ().set_description (tl::to_string (tr ("Additional line spacing")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
// parameter: effective cell width
tl_assert (parameters.size () == p_eff_cell_width);
parameters.push_back (db::PCellParameterDeclaration ("eff_cw"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Computed parameters\tCell width")));
parameters.back ().set_description (tl::to_string (tr ("Computed parameters\tCell width")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
parameters.back ().set_readonly (true);
// parameter: effective cell height
tl_assert (parameters.size () == p_eff_cell_height);
parameters.push_back (db::PCellParameterDeclaration ("eff_ch"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Computed parameters\tCell height")));
parameters.back ().set_description (tl::to_string (tr ("Computed parameters\tCell height")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
parameters.back ().set_readonly (true);
// parameter: effective line width
tl_assert (parameters.size () == p_eff_line_width);
parameters.push_back (db::PCellParameterDeclaration ("eff_lw"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Computed parameters\tLine width")));
parameters.back ().set_description (tl::to_string (tr ("Computed parameters\tLine width")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
parameters.back ().set_readonly (true);
// parameter: effective design raster
tl_assert (parameters.size () == p_eff_design_raster);
parameters.push_back (db::PCellParameterDeclaration ("eff_dr"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_double);
parameters.back ().set_description (tl::to_string (QObject::tr ("Computed parameters\tDesign raster")));
parameters.back ().set_description (tl::to_string (tr ("Computed parameters\tDesign raster")));
parameters.back ().set_default (0.0);
parameters.back ().set_unit (tl::to_string (QObject::tr ("micron")));
parameters.back ().set_unit (tl::to_string (tr ("micron")));
parameters.back ().set_readonly (true);
// parameter: font number
@ -294,7 +294,7 @@ BasicText::get_parameter_declarations () const
tl_assert (parameters.size () == p_font);
parameters.push_back (db::PCellParameterDeclaration ("font"));
parameters.back ().set_type (db::PCellParameterDeclaration::t_int);
parameters.back ().set_description (tl::to_string (QObject::tr ("Font")));
parameters.back ().set_description (tl::to_string (tr ("Font")));
parameters.back ().set_default (0);
parameters.back ().set_hidden (true);

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -43,10 +43,10 @@ namespace db
CIFReader::CIFReader (tl::InputStream &s)
: m_stream (s),
m_progress (tl::to_string (QObject::tr ("Reading CIF file")), 1000),
m_progress (tl::to_string (tr ("Reading CIF file")), 1000),
m_dbu (0.001), m_wire_mode (0)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0fk lines")));
m_progress.set_format (tl::to_string (tr ("%.0fk lines")));
m_progress.set_format_unit (1000.0);
m_progress.set_unit (100000.0);
}
@ -94,8 +94,8 @@ CIFReader::warn (const std::string &msg)
{
// TODO: compress
tl::warn << msg
<< tl::to_string (QObject::tr (" (line=")) << m_stream.line_number ()
<< tl::to_string (QObject::tr (", cell=")) << m_cellname
<< tl::to_string (tr (" (line=")) << m_stream.line_number ()
<< tl::to_string (tr (", cell=")) << m_cellname
<< ")";
}

View File

@ -53,7 +53,7 @@ class DB_PLUGIN_PUBLIC CIFReaderException
{
public:
CIFReaderException (const std::string &msg, size_t l, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (line=%ld, cell=%s)")), msg, l, cell))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (line=%ld, cell=%s)")), msg, l, cell))
{ }
};

View File

@ -37,10 +37,10 @@ namespace db
CIFWriter::CIFWriter ()
: mp_stream (0),
m_progress (tl::to_string (QObject::tr ("Writing CIF file")), 10000),
m_progress (tl::to_string (tr ("Writing CIF file")), 10000),
m_needs_emit (false)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}

View File

@ -27,7 +27,6 @@
#include "dbCIFWriter.h"
#include "tlUnitTest.h"
#include <QDir>
#include <stdlib.h>
static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au, const char *map = 0, double dbu = 0.001, bool dummy_calls = false, bool blank_sep = false)

View File

@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = lay_plugin
!equals(HAVE_QT, "0") {
SUBDIRS = lay_plugin
}

View File

@ -38,12 +38,14 @@
#include <cctype>
#include <set>
#include <QString>
#include <QStringList>
#include <QFont>
#include <QFontMetrics>
#include <QPolygon>
#include <QPainterPath>
#if defined(HAVE_QT)
# include <QString>
# include <QStringList>
# include <QFont>
# include <QFontMetrics>
# include <QPolygon>
# include <QPainterPath>
#endif
namespace db
{
@ -55,12 +57,12 @@ static std::string zero_layer_name ("0");
DXFReader::DXFReader (tl::InputStream &s)
: m_stream (s),
m_progress (tl::to_string (QObject::tr ("Reading DXF file")), 1000),
m_progress (tl::to_string (tr ("Reading DXF file")), 1000),
m_dbu (0.001), m_unit (1.0), m_text_scaling (1.0), m_polyline_mode (0), m_circle_points (100), m_circle_accuracy (0.0), m_contour_accuracy (0.0),
m_ascii (false), m_initial (true), m_render_texts_as_polygons (false), m_keep_other_cells (false), m_line_number (0),
m_zero_layer (0)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0fk lines")));
m_progress.set_format (tl::to_string (tr ("%.0fk lines")));
m_progress.set_format_unit (1000.0);
m_progress.set_unit (100000.0);
}
@ -76,7 +78,7 @@ DXFReader::check_coord (double x)
// Note: we stay on the safe side by dropping one bit (*0.5)
if (x < std::numeric_limits <db::Coord>::min () * 0.5 ||
x > std::numeric_limits <db::Coord>::max () * 0.5) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
}
@ -305,11 +307,11 @@ DXFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
if (m_polyline_mode == 0 /*auto mode*/) {
m_polyline_mode = determine_polyline_mode ();
if (m_polyline_mode == 3) {
tl::log << tl::to_string (QObject::tr ("Automatic polyline mode: merge lines with width = 0 into polygons"));
tl::log << tl::to_string (tr ("Automatic polyline mode: merge lines with width = 0 into polygons"));
} else if (m_polyline_mode == 2) {
tl::log << tl::to_string (QObject::tr ("Automatic polyline mode: create polygons from closed polylines with width = 0"));
tl::log << tl::to_string (tr ("Automatic polyline mode: create polygons from closed polylines with width = 0"));
} else if (m_polyline_mode == 1) {
tl::log << tl::to_string (QObject::tr ("Automatic polyline mode: keep lines, make polygons from solid and hatch entities"));
tl::log << tl::to_string (tr ("Automatic polyline mode: keep lines, make polygons from solid and hatch entities"));
}
}
@ -353,13 +355,13 @@ DXFReader::warn (const std::string &msg)
// TODO: compress
if (m_ascii) {
tl::warn << msg
<< tl::to_string (QObject::tr (" (line=")) << m_line_number
<< tl::to_string (QObject::tr (", cell=")) << m_cellname
<< tl::to_string (tr (" (line=")) << m_line_number
<< tl::to_string (tr (", cell=")) << m_cellname
<< ")";
} else {
tl::warn << msg
<< tl::to_string (QObject::tr (" (position=")) << m_stream.pos ()
<< tl::to_string (QObject::tr (", cell=")) << m_cellname
<< tl::to_string (tr (" (position=")) << m_stream.pos ()
<< tl::to_string (tr (", cell=")) << m_cellname
<< ")";
}
}
@ -1192,7 +1194,9 @@ normalize_string (const std::string &in, bool for_mtext)
}
}
s += QString (QChar(code)).toUtf8 ().constData ();
std::wstring ws;
ws += wchar_t (code);
s += tl::to_string (ws);
} else if (for_mtext && *c == '\\' && c[1] && tolower(c[1]) == 'p') {
s += "\n";
@ -1248,6 +1252,8 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
if (m_render_texts_as_polygons) {
#if defined(HAVE_QT)
db::EdgeProcessor ep;
// we use a pixel size of 200 for reference, so we are less dependent on the accuracy of the
@ -1366,6 +1372,10 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
}
#else
error (tl::to_string (tr ("Render texts as polygons is not available (Qt not compiled in)")));
#endif
} else {
db::DText text (s, db::DTrans (text_trans), text_trans.ctrans (h * m_text_scaling / 100.0), db::NoFont, ha, va);
shapes.insert (safe_from_double (text));
@ -2739,7 +2749,7 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
if (! collected_edges.empty ()) {
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Merging edges")), 1000000, 10000);
tl::RelativeProgress progress (tl::to_string (tr ("Merging edges")), 1000000, 10000);
db::EdgesToContours e2c;

View File

@ -53,11 +53,11 @@ class DB_PLUGIN_PUBLIC DXFReaderException
{
public:
DXFReaderException (const std::string &msg, size_t p, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (position=%ld, cell=%s)")), msg.c_str (), p, cell))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (position=%ld, cell=%s)")), msg.c_str (), p, cell))
{ }
DXFReaderException (const std::string &msg, int line, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (line=%d, cell=%s)")), msg.c_str (), line, cell))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (line=%d, cell=%s)")), msg.c_str (), line, cell))
{ }
};

View File

@ -38,9 +38,9 @@ namespace db
DXFWriter::DXFWriter ()
: mp_stream (0),
m_progress (tl::to_string (QObject::tr ("Writing DXF file")), 10000)
m_progress (tl::to_string (tr ("Writing DXF file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}
@ -188,7 +188,7 @@ DXFWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::SaveLa
if (is_top_cell) {
if (top_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Top-level cell is not unique - DXF can only store a single top cell")));
throw tl::Exception (tl::to_string (tr ("Top-level cell is not unique - DXF can only store a single top cell")));
} else {
top_cell = &layout.cell (*cell);
}

View File

@ -116,7 +116,7 @@ static double get_dxf_contour_accuracy (const db::LoadLayoutOptions *options)
static void set_dxf_polyline_mode (db::LoadLayoutOptions *options, int mode)
{
if (mode < 0 || mode > 4) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid polygon mode")));
throw tl::Exception (tl::to_string (tr ("Invalid polygon mode")));
}
options->get_options<db::DXFReaderOptions> ().polyline_mode = mode;
@ -348,7 +348,7 @@ gsi::ClassExt<db::LoadLayoutOptions> dxf_reader_options (
static void set_dxf_polygon_mode (db::SaveLayoutOptions *options, int mode)
{
if (mode < 0 || mode > 3) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid polygon mode")));
throw tl::Exception (tl::to_string (tr ("Invalid polygon mode")));
}
options->get_options<db::DXFWriterOptions> ().polygon_mode = mode;

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -39,10 +39,10 @@ namespace db
GDS2ReaderText::GDS2ReaderText(tl::InputStream &s, int /*ignored*/)
: GDS2ReaderBase(), sStream(s),
mProgress (tl::to_string (QObject::tr ("Reading GDS2 text file")), 10000),
mProgress (tl::to_string (tr ("Reading GDS2 text file")), 10000),
storedRecId (0)
{
mProgress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
mProgress.set_format (tl::to_string (tr ("%.0f MB")));
mProgress.set_unit (1024 * 1024);
}
@ -253,7 +253,7 @@ GDS2ReaderText::get_double () throw (tl::Exception)
{
double x = 0;
if (! reader.try_read (x)) {
error (tl::to_string (QObject::tr ("Expected a floating-point number")));
error (tl::to_string (tr ("Expected a floating-point number")));
}
return x;
}
@ -270,7 +270,7 @@ GDS2ReaderText::get_int () throw (tl::Exception)
{
int x = 0;
if (! reader.try_read (x)) {
error (tl::to_string (QObject::tr ("Expected an integer number")));
error (tl::to_string (tr ("Expected an integer number")));
}
return x;
}
@ -280,10 +280,10 @@ GDS2ReaderText::get_short () throw (tl::Exception)
{
int x = 0;
if (! reader.try_read (x)) {
error (tl::to_string (QObject::tr ("Expected an integer number")));
error (tl::to_string (tr ("Expected an integer number")));
}
if (x < std::numeric_limits<short>::min() || x > std::numeric_limits<short>::max ()) {
error (tl::to_string (QObject::tr ("Value out of range for 16bit signed integer")));
error (tl::to_string (tr ("Value out of range for 16bit signed integer")));
}
return x;
}
@ -293,10 +293,10 @@ GDS2ReaderText::get_ushort () throw (tl::Exception)
{
unsigned int x = 0;
if (! reader.try_read (x)) {
error (tl::to_string (QObject::tr ("Expected an integer number")));
error (tl::to_string (tr ("Expected an integer number")));
}
if (x > std::numeric_limits<unsigned short>::max ()) {
error (tl::to_string (QObject::tr ("Value out of range for 16bit unsigned integer")));
error (tl::to_string (tr ("Value out of range for 16bit unsigned integer")));
}
return x;
}
@ -312,8 +312,8 @@ GDS2ReaderText::warn (const std::string &msg)
{
// TODO: compress
tl::warn << msg
<< tl::to_string (QObject::tr (", line number=")) << sStream.line_number()
<< tl::to_string (QObject::tr (", cell=")) << cellname ().c_str ()
<< tl::to_string (tr (", line number=")) << sStream.line_number()
<< tl::to_string (tr (", cell=")) << cellname ().c_str ()
<< ")";
}

View File

@ -40,7 +40,7 @@ class DB_PLUGIN_PUBLIC GDS2ReaderTextException
{
public:
GDS2ReaderTextException (const std::string &msg, size_t n, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (line number=%ld, cell=%s)")).c_str (), msg.c_str (), n, cell.c_str ()))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (line number=%ld, cell=%s)")).c_str (), msg.c_str (), n, cell.c_str ()))
{ }
};

View File

@ -43,9 +43,9 @@ namespace db
GDS2WriterText::GDS2WriterText()
: pStream(0),siCurrentRecord(0),bIsXCoordinate(true),
mProgress (tl::to_string (QObject::tr ("Writing GDS2 text file")), 10000)
mProgress (tl::to_string (tr ("Writing GDS2 text file")), 10000)
{
mProgress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
mProgress.set_format (tl::to_string (tr ("%.0f MB")));
mProgress.set_unit (1024 * 1024);
}

View File

@ -43,9 +43,9 @@ GDS2Reader::GDS2Reader (tl::InputStream &s)
m_recptr (0),
mp_rec_buf (0),
m_stored_rec (0),
m_progress (tl::to_string (QObject::tr ("Reading GDS2 file")), 10000)
m_progress (tl::to_string (tr ("Reading GDS2 file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}
@ -91,7 +91,7 @@ GDS2Reader::get_record ()
unsigned char *b = (unsigned char *) m_stream.get (4);
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
return 0;
}
@ -105,17 +105,17 @@ GDS2Reader::get_record ()
gds2h ((int16_t &) rec_id);
if (m_reclen < 4) {
error (tl::to_string (QObject::tr ("Invalid record length (less than 4)")));
error (tl::to_string (tr ("Invalid record length (less than 4)")));
}
if (m_reclen >= 0x8000) {
if (m_options.allow_big_records) {
warn (tl::to_string (QObject::tr ("Record length larger than 0x8000 encountered: interpreting as unsigned")));
warn (tl::to_string (tr ("Record length larger than 0x8000 encountered: interpreting as unsigned")));
} else {
error (tl::to_string (QObject::tr ("Record length larger than 0x8000 encountered (reader is configured not to allow such records)")));
error (tl::to_string (tr ("Record length larger than 0x8000 encountered (reader is configured not to allow such records)")));
}
}
if (m_reclen % 2 == 1) {
warn (tl::to_string (QObject::tr ("Odd record length")));
warn (tl::to_string (tr ("Odd record length")));
}
m_reclen -= 4;
@ -123,7 +123,7 @@ GDS2Reader::get_record ()
if (m_reclen > 0) {
mp_rec_buf = (unsigned char *) m_stream.get (m_reclen);
if (! mp_rec_buf) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
}
} else {
mp_rec_buf = 0;
@ -267,9 +267,9 @@ GDS2Reader::warn (const std::string &msg)
{
// TODO: compress
tl::warn << msg
<< tl::to_string (QObject::tr (" (position=")) << m_stream.pos ()
<< tl::to_string (QObject::tr (", record number=")) << m_recnum
<< tl::to_string (QObject::tr (", cell=")) << cellname ().c_str ()
<< tl::to_string (tr (" (position=")) << m_stream.pos ()
<< tl::to_string (tr (", record number=")) << m_recnum
<< tl::to_string (tr (", cell=")) << cellname ().c_str ()
<< ")";
}

View File

@ -49,7 +49,7 @@ class DB_PLUGIN_PUBLIC GDS2ReaderException
{
public:
GDS2ReaderException (const std::string &msg, size_t p, size_t n, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (position=%ld, record number=%ld, cell=%s)")), msg, p, n, cell))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (position=%ld, record number=%ld, cell=%s)")), msg, p, n, cell))
{ }
};

View File

@ -118,10 +118,10 @@ GDS2ReaderBase::finish_element ()
} else if (rec_id == sTEXT || rec_id == sPATH || rec_id == sBOUNDARY || rec_id == sBOX ||
rec_id == sAREF || rec_id == sSREF || rec_id == sENDSTR) {
unget_record (rec_id);
warn (tl::to_string (QObject::tr ("ENDEL record expected - assuming missing ENDEL")));
warn (tl::to_string (tr ("ENDEL record expected - assuming missing ENDEL")));
break;
} else {
error (tl::to_string (QObject::tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
error (tl::to_string (tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
}
}
@ -157,10 +157,10 @@ GDS2ReaderBase::finish_element (db::PropertiesRepository &rep)
} else if (rec_id == sTEXT || rec_id == sPATH || rec_id == sBOUNDARY || rec_id == sBOX ||
rec_id == sAREF || rec_id == sSREF || rec_id == sENDSTR) {
unget_record (rec_id);
warn (tl::to_string (QObject::tr ("ENDEL record expected - assuming missing ENDEL")));
warn (tl::to_string (tr ("ENDEL record expected - assuming missing ENDEL")));
break;
} else {
error (tl::to_string (QObject::tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
error (tl::to_string (tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
}
}
@ -241,17 +241,17 @@ GDS2ReaderBase::do_read (db::Layout &layout)
// read header
if (get_record () != sHEADER) {
error (tl::to_string (QObject::tr ("HEADER record expected")));
error (tl::to_string (tr ("HEADER record expected")));
}
if (get_record () != sBGNLIB) {
error (tl::to_string (QObject::tr ("BGNLIB record expected")));
error (tl::to_string (tr ("BGNLIB record expected")));
}
unsigned int mod_time[6] = { 0, 0, 0, 0, 0, 0 };
unsigned int access_time[6] = { 0, 0, 0, 0, 0, 0 };
get_time (mod_time, access_time);
layout.add_meta_info (MetaInfo ("mod_time", tl::to_string (QObject::tr ("Modification Time")), tl::sprintf ("%d/%d/%d %d:%02d:%02d", mod_time[1], mod_time[2], mod_time[0], mod_time[3], mod_time[4], mod_time[5])));
layout.add_meta_info (MetaInfo ("access_time", tl::to_string (QObject::tr ("Access Time")), tl::sprintf ("%d/%d/%d %d:%02d:%02d", access_time[1], access_time[2], access_time[0], access_time[3], access_time[4], access_time[5])));
layout.add_meta_info (MetaInfo ("mod_time", tl::to_string (tr ("Modification Time")), tl::sprintf ("%d/%d/%d %d:%02d:%02d", mod_time[1], mod_time[2], mod_time[0], mod_time[3], mod_time[4], mod_time[5])));
layout.add_meta_info (MetaInfo ("access_time", tl::to_string (tr ("Access Time")), tl::sprintf ("%d/%d/%d %d:%02d:%02d", access_time[1], access_time[2], access_time[0], access_time[3], access_time[4], access_time[5])));
long attr = 0;
db::PropertiesRepository::properties_set layout_properties;
@ -299,16 +299,16 @@ GDS2ReaderBase::do_read (db::Layout &layout)
double dbuu = get_double ();
double dbum = get_double ();
layout.add_meta_info (MetaInfo ("dbuu", tl::to_string (QObject::tr ("Database unit in user units")), tl::to_string (dbuu)));
layout.add_meta_info (MetaInfo ("dbum", tl::to_string (QObject::tr ("Database unit in meter")), tl::to_string (dbum)));
layout.add_meta_info (MetaInfo ("libname", tl::to_string (QObject::tr ("Library name")), m_libname));
layout.add_meta_info (MetaInfo ("dbuu", tl::to_string (tr ("Database unit in user units")), tl::to_string (dbuu)));
layout.add_meta_info (MetaInfo ("dbum", tl::to_string (tr ("Database unit in meter")), tl::to_string (dbum)));
layout.add_meta_info (MetaInfo ("libname", tl::to_string (tr ("Library name")), m_libname));
m_dbuu = dbuu;
m_dbu = dbum * 1e6; /*in micron*/
layout.dbu (m_dbu);
} else {
error (tl::to_string (QObject::tr ("Invalid record or data type")));
error (tl::to_string (tr ("Invalid record or data type")));
}
} while (true);
@ -338,7 +338,7 @@ GDS2ReaderBase::do_read (db::Layout &layout)
instances_with_props.erase (instances_with_props.begin (), instances_with_props.end ());
if (get_record () != sSTRNAME) {
error (tl::to_string (QObject::tr ("STRNAME record expected")));
error (tl::to_string (tr ("STRNAME record expected")));
}
get_string (m_cellname);
@ -413,7 +413,7 @@ GDS2ReaderBase::do_read (db::Layout &layout)
} else if (m_box_mode == 2) {
read_boundary (layout, *cell, true);
} else if (m_box_mode == 3) {
error (tl::to_string (QObject::tr ("BOX record encountered (reader is configured to produce an error in this case)")));
error (tl::to_string (tr ("BOX record encountered (reader is configured to produce an error in this case)")));
} else {
while (get_record () != sENDEL) { }
}
@ -424,7 +424,7 @@ GDS2ReaderBase::do_read (db::Layout &layout)
while (get_record () != sENDEL) { }
} else {
error (tl::to_string (QObject::tr ("Invalid record or data type")));
error (tl::to_string (tr ("Invalid record or data type")));
}
}
@ -451,7 +451,7 @@ GDS2ReaderBase::do_read (db::Layout &layout)
// check, if the last record is a ENDLIB
if (rec_id != sENDLIB) {
error (tl::to_string (QObject::tr ("ENDLIB record expected")));
error (tl::to_string (tr ("ENDLIB record expected")));
}
}
@ -471,7 +471,7 @@ GDS2ReaderBase::read_context_info_cell ()
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sSNAME) {
error (tl::to_string (QObject::tr ("SNAME record expected")));
error (tl::to_string (tr ("SNAME record expected")));
}
std::string cn = get_string ();
@ -481,7 +481,7 @@ GDS2ReaderBase::read_context_info_cell ()
rec_id = get_record ();
}
if (rec_id != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
std::vector <std::string> &strings = m_context_info.insert (std::make_pair (cn, std::vector <std::string> ())).first->second;
@ -504,13 +504,13 @@ GDS2ReaderBase::read_context_info_cell ()
strings [attr] = get_string ();
} else {
error (tl::to_string (QObject::tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
error (tl::to_string (tr ("ENDEL, PROPATTR or PROPVALUE record expected")));
}
}
} else {
error (tl::to_string (QObject::tr ("Invalid record inside a context info cell")));
error (tl::to_string (tr ("Invalid record inside a context info cell")));
}
}
@ -526,25 +526,25 @@ GDS2ReaderBase::read_boundary (db::Layout &layout, db::Cell &cell, bool from_box
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sLAYER) {
error (tl::to_string (QObject::tr ("LAYER record expected")));
error (tl::to_string (tr ("LAYER record expected")));
}
ld.layer = get_ushort ();
rec_id = get_record ();
if (from_box_record) {
if (rec_id != sBOXTYPE) {
error (tl::to_string (QObject::tr ("BOXTYPE record expected")));
error (tl::to_string (tr ("BOXTYPE record expected")));
}
} else {
if (rec_id != sDATATYPE) {
error (tl::to_string (QObject::tr ("DATATYPE record expected")));
error (tl::to_string (tr ("DATATYPE record expected")));
}
}
ld.datatype = get_ushort ();
if (get_record () != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
unsigned int xy_length = 0;
@ -609,7 +609,7 @@ GDS2ReaderBase::read_boundary (db::Layout &layout, db::Cell &cell, bool from_box
if ((rec_id = get_record ()) == sXY) {
xy_data = get_xy_data (xy_length);
if (! m_allow_multi_xy_records) {
error (tl::to_string (QObject::tr ("Multiple XY records detected on BOUNDARY element (reader is configured not to allow this)")));
error (tl::to_string (tr ("Multiple XY records detected on BOUNDARY element (reader is configured not to allow this)")));
}
} else {
unget_record (rec_id);
@ -637,7 +637,7 @@ GDS2ReaderBase::read_boundary (db::Layout &layout, db::Cell &cell, bool from_box
}
if (poly.hull ().size () < 3) {
warn (tl::to_string (QObject::tr ("BOUNDARY with less than 3 points ignored")));
warn (tl::to_string (tr ("BOUNDARY with less than 3 points ignored")));
finish_element ();
} else {
// this will copy the polyon:
@ -656,7 +656,7 @@ GDS2ReaderBase::read_boundary (db::Layout &layout, db::Cell &cell, bool from_box
while ((rec_id = get_record ()) == sXY) {
// read over multi-XY records
if (! m_allow_multi_xy_records) {
error (tl::to_string (QObject::tr ("Multiple XY records detected on BOUNDARY element (reader is configured not to allow this)")));
error (tl::to_string (tr ("Multiple XY records detected on BOUNDARY element (reader is configured not to allow this)")));
}
}
unget_record (rec_id);
@ -676,11 +676,11 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sLAYER) {
error (tl::to_string (QObject::tr ("LAYER record expected")));
error (tl::to_string (tr ("LAYER record expected")));
}
ld.layer = get_ushort ();
if (get_record () != sDATATYPE) {
error (tl::to_string (QObject::tr ("DATATYPE record expected")));
error (tl::to_string (tr ("DATATYPE record expected")));
}
ld.datatype = get_ushort ();
@ -693,7 +693,7 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
}
if (type != 0 && type != 1 && type != 2 && type != 4) {
warn (tl::to_string (QObject::tr ("Unsupported PATHTYPE")));
warn (tl::to_string (tr ("Unsupported PATHTYPE")));
type = 0;
}
@ -725,7 +725,7 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
}
if (rec_id != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
unsigned int xy_length = 0;
@ -752,7 +752,7 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
if ((rec_id = get_record ()) == sXY) {
xy_data = get_xy_data (xy_length);
if (! m_allow_multi_xy_records) {
error (tl::to_string (QObject::tr ("Multiple XY records detected on PATH element (reader is configured not to allow this)")));
error (tl::to_string (tr ("Multiple XY records detected on PATH element (reader is configured not to allow this)")));
}
} else {
unget_record (rec_id);
@ -772,11 +772,11 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
path.round (type == 1);
if (path.points () < 1) {
warn (tl::to_string (QObject::tr ("PATH with less than one point ignored")));
warn (tl::to_string (tr ("PATH with less than one point ignored")));
finish_element ();
} else {
if (path.points () < 2 && type != 1) {
warn (tl::to_string (QObject::tr ("PATH with less than two points encountered - interpretation may be different in other tools")));
warn (tl::to_string (tr ("PATH with less than two points encountered - interpretation may be different in other tools")));
}
std::pair<bool, db::properties_id_type> pp = finish_element (layout.properties_repository ());
if (pp.first) {
@ -791,7 +791,7 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
while ((rec_id = get_record ()) == sXY) {
// read over multi-XY records
if (! m_allow_multi_xy_records) {
error (tl::to_string (QObject::tr ("Multiple XY records detected on PATH element (reader is configured not to allow this)")));
error (tl::to_string (tr ("Multiple XY records detected on PATH element (reader is configured not to allow this)")));
}
}
unget_record (rec_id);
@ -811,11 +811,11 @@ GDS2ReaderBase::read_text (db::Layout &layout, db::Cell &cell)
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sLAYER) {
error (tl::to_string (QObject::tr ("LAYER record expected")));
error (tl::to_string (tr ("LAYER record expected")));
}
ld.layer = get_ushort ();
if (get_record () != sTEXTTYPE) {
error (tl::to_string (QObject::tr ("DATATYPE record expected")));
error (tl::to_string (tr ("DATATYPE record expected")));
}
ld.datatype = get_ushort ();
@ -871,11 +871,11 @@ GDS2ReaderBase::read_text (db::Layout &layout, db::Cell &cell)
double aorg = get_double ();
double a = aorg / 90.0;
if (a < -4 || a > 4) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid text rotation angle (%g is less than -360 or larger than 360)")), aorg));
warn (tl::sprintf (tl::to_string (tr ("Invalid text rotation angle (%g is less than -360 or larger than 360)")), aorg));
}
angle = int (a < 0 ? (a - 0.5) : (a + 0.5));
if (fabs (double (angle) - a) > 1e-9) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid text rotation angle (%g is not a multiple of 90)")), aorg));
warn (tl::sprintf (tl::to_string (tr ("Invalid text rotation angle (%g is not a multiple of 90)")), aorg));
}
while (angle < 0) {
angle += 4;
@ -892,21 +892,21 @@ GDS2ReaderBase::read_text (db::Layout &layout, db::Cell &cell)
}
if (rec_id != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
unsigned int xy_length = 0;
GDS2XY *xy_data = get_xy_data (xy_length);
if (xy_length == 0) {
error (tl::to_string (QObject::tr ("No point in XY record for text")));
error (tl::to_string (tr ("No point in XY record for text")));
} else if (xy_length > 1) {
warn (tl::to_string (QObject::tr ("More than one point in XY record for text")));
warn (tl::to_string (tr ("More than one point in XY record for text")));
}
db::Trans t (angle, mirror, pt_conv (xy_data [0]) - db::Point ());
if (get_record () != sSTRING) {
error (tl::to_string (QObject::tr ("STRING record expected")));
error (tl::to_string (tr ("STRING record expected")));
}
if (ll.first) {
@ -936,18 +936,18 @@ GDS2ReaderBase::read_box (db::Layout &layout, db::Cell &cell)
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sLAYER) {
error (tl::to_string (QObject::tr ("LAYER record expected")));
error (tl::to_string (tr ("LAYER record expected")));
}
ld.layer = get_ushort ();
if (get_record () != sBOXTYPE) {
error (tl::to_string (QObject::tr ("DATATYPE record expected")));
error (tl::to_string (tr ("DATATYPE record expected")));
}
ld.datatype = get_ushort ();
std::pair<bool, unsigned int> ll = open_dl (layout, ld, m_create_layers);
if (get_record () != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
unsigned int xy_length = 0;
@ -1032,7 +1032,7 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
rec_id = get_record ();
} while (rec_id == sELFLAGS || rec_id == sPLEX);
if (rec_id != sSNAME) {
error (tl::to_string (QObject::tr ("SNAME record expected")));
error (tl::to_string (tr ("SNAME record expected")));
}
db::cell_index_type ci = make_cell (layout, get_string (), true);
@ -1053,7 +1053,7 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
mirror = true;
}
if ((f & (4 | 2)) != 0) {
warn (tl::to_string (QObject::tr ("Absolute transformations are not supported")));
warn (tl::to_string (tr ("Absolute transformations are not supported")));
}
} else if (rec_id == sMAG) {
mag = get_double ();
@ -1064,7 +1064,7 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
angle_deg = get_double ();
double a = angle_deg / 90.0;
if (a < -4 || a > 4) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid rotation angle (%g is less than -360 or larger than 360)")), angle_deg));
warn (tl::sprintf (tl::to_string (tr ("Invalid rotation angle (%g is less than -360 or larger than 360)")), angle_deg));
}
angle = int (a < 0 ? (a - 0.5) : (a + 0.5));
if (fabs (double (angle) - a) > 1e-9) {
@ -1085,7 +1085,7 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
// Array reference
if (rec_id != sCOLROW) {
error (tl::to_string (QObject::tr ("COLROW record expected")));
error (tl::to_string (tr ("COLROW record expected")));
}
int cols = get_ushort ();
@ -1096,16 +1096,16 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
// Array reference
if (get_record () != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
// Create the instance
unsigned int xy_length = 0;
GDS2XY *xy_data = get_xy_data (xy_length);
if (xy_length < 3) {
error (tl::to_string (QObject::tr ("Too few points in XY record for AREF")));
error (tl::to_string (tr ("Too few points in XY record for AREF")));
} else if (xy_length > 3) {
warn (tl::to_string (QObject::tr ("More than three points in XY record for AREF")));
warn (tl::to_string (tr ("More than three points in XY record for AREF")));
}
// Create the instance
@ -1127,11 +1127,11 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
bool split_cols = false, split_rows = false;
if (cols > 1 && (c.x () % cols != 0 || c.y () % cols != 0)) {
warn (tl::to_string (QObject::tr ("Off-grid AREF column vector - AREF will be split into subarrays to preserve locations")));
warn (tl::to_string (tr ("Off-grid AREF column vector - AREF will be split into subarrays to preserve locations")));
split_cols = true;
}
if (rows > 1 && (r.x () % rows != 0 || r.y () % rows != 0)) {
warn (tl::to_string (QObject::tr ("Off-grid AREF row vector - AREF will be split into subarrays to preserve locations")));
warn (tl::to_string (tr ("Off-grid AREF row vector - AREF will be split into subarrays to preserve locations")));
split_rows = true;
}
@ -1238,16 +1238,16 @@ GDS2ReaderBase::read_ref (db::Layout &layout, db::Cell & /*cell*/, bool array, t
// Single reference
if (rec_id != sXY) {
error (tl::to_string (QObject::tr ("XY record expected")));
error (tl::to_string (tr ("XY record expected")));
}
// Create the instance
unsigned int xy_length = 0;
GDS2XY *xy_data = get_xy_data (xy_length);
if (xy_length < 1) {
error (tl::to_string (QObject::tr ("Too few points in XY record for SREF")));
error (tl::to_string (tr ("Too few points in XY record for SREF")));
} else if (xy_length > 1) {
warn (tl::to_string (QObject::tr ("More than one point in XY record for SREF")));
warn (tl::to_string (tr ("More than one point in XY record for SREF")));
}
// Create the instance

View File

@ -39,9 +39,9 @@ namespace db
// GDS2Writer implementation
GDS2Writer::GDS2Writer ()
: mp_stream (0), m_progress (tl::to_string (QObject::tr ("Writing GDS2 file")), 10000)
: mp_stream (0), m_progress (tl::to_string (tr ("Writing GDS2 file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}

View File

@ -86,9 +86,9 @@ GDS2WriterBase::write (db::Layout &layout, tl::OutputStream &stream, const db::S
db::GDS2WriterOptions gds2_options = options.get_options<db::GDS2WriterOptions> ();
layout.add_meta_info (MetaInfo ("dbuu", tl::to_string (QObject::tr ("Database unit in user units")), tl::to_string (dbu / std::max (1e-9, gds2_options.user_units))));
layout.add_meta_info (MetaInfo ("dbum", tl::to_string (QObject::tr ("Database unit in meter")), tl::to_string (dbu * 1e-6)));
layout.add_meta_info (MetaInfo ("libname", tl::to_string (QObject::tr ("Library name")), gds2_options.libname));
layout.add_meta_info (MetaInfo ("dbuu", tl::to_string (tr ("Database unit in user units")), tl::to_string (dbu / std::max (1e-9, gds2_options.user_units))));
layout.add_meta_info (MetaInfo ("dbum", tl::to_string (tr ("Database unit in meter")), tl::to_string (dbu * 1e-6)));
layout.add_meta_info (MetaInfo ("libname", tl::to_string (tr ("Library name")), gds2_options.libname));
std::vector <std::pair <unsigned int, db::LayerProperties> > layers;
options.get_valid_layers (layout, layers, db::SaveLayoutOptions::LP_AssignNumber);
@ -123,8 +123,8 @@ GDS2WriterBase::write (db::Layout &layout, tl::OutputStream &stream, const db::S
}
std::string str_time = tl::sprintf ("%d/%d/%d %d:%02d:%02d", time_data[1], time_data[2], time_data[0], time_data[3], time_data[4], time_data[5]);
layout.add_meta_info (MetaInfo ("mod_time", tl::to_string (QObject::tr ("Modification Time")), str_time));
layout.add_meta_info (MetaInfo ("access_time", tl::to_string (QObject::tr ("Access Time")), str_time));
layout.add_meta_info (MetaInfo ("mod_time", tl::to_string (tr ("Modification Time")), str_time));
layout.add_meta_info (MetaInfo ("access_time", tl::to_string (tr ("Access Time")), str_time));
bool multi_xy = gds2_options.multi_xy_records;
size_t max_cellname_length = std::max (gds2_options.max_cellname_length, (unsigned int)8);
@ -446,7 +446,7 @@ GDS2WriterBase::write_inst (double sf, const db::Instance &instance, bool normal
write_record_size (4 + 2 * 2);
write_record (sCOLROW);
if (amax > 32767 || bmax > 32767) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot write array references with more than 32767 columns or rows to GDS2 streams")));
throw tl::Exception (tl::to_string (tr ("Cannot write array references with more than 32767 columns or rows to GDS2 streams")));
}
write_short (std::max ((unsigned long) 1, bmax));
write_short (std::max ((unsigned long) 1, amax));

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -29,7 +29,6 @@
#include "dbTextWriter.h"
#include "tlUnitTest.h"
#include <QDir>
#include <stdlib.h>
void run_test (tl::TestBase *_this, const char *file, const char *file_ref, bool priv = false, const db::GDS2WriterOptions &opt = db::GDS2WriterOptions ())

View File

@ -65,7 +65,7 @@ DEFImporter::get_orient (bool optional)
} else if (optional) {
return db::FTrans (db::FTrans::r0);
} else {
error (tl::to_string (QObject::tr ("Invalid orientation specification: ")) + get ());
error (tl::to_string (tr ("Invalid orientation specification: ")) + get ());
return db::FTrans (db::FTrans::r0);
}
}
@ -576,7 +576,7 @@ DEFImporter::do_read (db::Layout &layout)
if (test ("RECT")) {
if (! test ("(")) {
error (tl::to_string (QObject::tr ("RECT routing specification not followed by coordinate list")));
error (tl::to_string (tr ("RECT routing specification not followed by coordinate list")));
}
// breaks wiring
@ -1016,7 +1016,7 @@ DEFImporter::do_read (db::Layout &layout)
db::CellInstArray inst (db::CellInst (cell->cell_index ()), db::Trans (ft.rot (), d));
instances.push_back (std::make_pair (inst_name, inst));
} else {
warn (tl::to_string (QObject::tr ("Macro not found in LEF file: ")) + model);
warn (tl::to_string (tr ("Macro not found in LEF file: ")) + model);
}
} else {
@ -1208,7 +1208,7 @@ DEFImporter::do_read (db::Layout &layout)
std::map<std::string, std::vector<db::Polygon> >::const_iterator r = regions.find (g->region_name);
if (r == regions.end ()) {
warn (tl::to_string (QObject::tr ("Not a valid region name: %1 in group %2").arg (tl::to_qstring (g->region_name).arg (tl::to_qstring (g->name)))));
warn (tl::sprintf (tl::to_string (tr ("Not a valid region name: %s in group %s")), g->region_name, g->name));
} else {
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Region);
if (dl.first) {

View File

@ -28,8 +28,6 @@
#include <cctype>
#include <QFileInfo>
namespace db
{
@ -374,8 +372,8 @@ LEFDEFImporter::read (tl::InputStream &stream, db::Layout &layout, LEFDEFLayerDe
{
m_fn = stream.filename ();
tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Reading ")) + m_fn, 1000);
progress.set_format (tl::to_string (QObject::tr ("%.0fk lines")));
tl::AbsoluteProgress progress (tl::to_string (tr ("Reading ")) + m_fn, 1000);
progress.set_format (tl::to_string (tr ("%.0fk lines")));
progress.set_format_unit (1000.0);
progress.set_unit (10000.0);
@ -425,9 +423,9 @@ void
LEFDEFImporter::warn (const std::string &msg)
{
tl::warn << msg
<< tl::to_string (QObject::tr (" (line=")) << mp_stream->line_number ()
<< tl::to_string (QObject::tr (", cell=")) << m_cellname
<< tl::to_string (QObject::tr (", file=")) << m_fn
<< tl::to_string (tr (" (line=")) << mp_stream->line_number ()
<< tl::to_string (tr (", cell=")) << m_cellname
<< tl::to_string (tr (", file=")) << m_fn
<< ")";
}

View File

@ -51,7 +51,7 @@ class DB_PLUGIN_PUBLIC LEFDEFReaderException
{
public:
LEFDEFReaderException (const std::string &msg, int line, const std::string &cell, const std::string &fn)
: db::ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (line=%d, cell=%s, file=%s)")), msg.c_str (), line, cell, fn))
: db::ReaderException (tl::sprintf (tl::to_string (tr ("%s (line=%d, cell=%s, file=%s)")), msg.c_str (), line, cell, fn))
{ }
};

View File

@ -23,6 +23,7 @@
#include "tlTimer.h"
#include "tlStream.h"
#include "tlFileUtils.h"
#include "dbReader.h"
#include "dbStream.h"
@ -30,9 +31,6 @@
#include "dbDEFImporter.h"
#include "dbLEFDEFImporter.h"
#include <QFileInfo>
#include <QDir>
namespace db
{
@ -110,10 +108,8 @@ private:
std::string correct_path (const std::string &fn)
{
QFileInfo fi (tl::to_qstring (fn));
if (! fi.isAbsolute ()) {
QDir input_dir (QFileInfo (tl::to_qstring (m_stream.absolute_path ())).dir ());
return tl::to_string (input_dir.filePath (fi.filePath ()));
if (! tl::is_absolute (fn)) {
return tl::combine_path (m_stream.absolute_path (), fn);
} else {
return fn;
}
@ -134,7 +130,7 @@ private:
if (import_lef) {
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Reading LEF file")));
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Reading LEF file")));
db::LEFImporter importer;
@ -143,17 +139,17 @@ private:
std::string lp = correct_path (*l);
tl::InputStream lef_stream (lp);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << lp;
tl::log << tl::to_string (tr ("Reading")) << " " << lp;
importer.read (lef_stream, layout, layers);
}
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << m_stream.source ();
tl::log << tl::to_string (tr ("Reading")) << " " << m_stream.source ();
importer.read (m_stream, layout, layers);
} else {
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Reading DEF file")));
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Reading DEF file")));
DEFImporter importer;
@ -162,24 +158,24 @@ private:
std::string lp = correct_path (*l);
tl::InputStream lef_stream (lp);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << lp;
tl::log << tl::to_string (tr ("Reading")) << " " << lp;
importer.read_lef (lef_stream, layout, layers);
}
// Additionally read all LEF files next to the DEF file
QDir input_dir (QFileInfo (tl::to_qstring (m_stream.absolute_path ())).dir ());
if (input_dir.exists () && input_dir.isReadable ()) {
std::string input_dir = tl::absolute_path (m_stream.absolute_path ());
if (tl::file_exists (input_dir)) {
QStringList entries = input_dir.entryList ();
for (QStringList::const_iterator e = entries.begin (); e != entries.end (); ++e) {
std::vector<std::string> entries = tl::dir_entries (input_dir);
for (std::vector<std::string>::const_iterator e = entries.begin (); e != entries.end (); ++e) {
if (is_lef_format (tl::to_string (*e))) {
if (is_lef_format (*e)) {
std::string lp = tl::to_string (input_dir.filePath (*e));
std::string lp = tl::combine_path (input_dir, *e);
tl::InputStream lef_stream (lp);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << lp;
tl::log << tl::to_string (tr ("Reading")) << " " << lp;
importer.read_lef (lef_stream, layout, layers);
}
@ -188,7 +184,7 @@ private:
}
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << m_stream.source ();
tl::log << tl::to_string (tr ("Reading")) << " " << m_stream.source ();
importer.read (m_stream, layout, layers);
}

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -29,7 +29,6 @@
#include "tlUnitTest.h"
#include <cstdlib>
#include <QDir>
static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au)
{

View File

@ -512,7 +512,7 @@ modal_variable<T>::get () const
{
if (! m_initialized) {
if (mp_diag) {
mp_diag->warn (tl::to_string (QObject::tr ("Modal variable accessed before being defined: ")) + m_name);
mp_diag->warn (tl::to_string (tr ("Modal variable accessed before being defined: ")) + m_name);
} else {
tl_assert (false);
}

View File

@ -72,7 +72,7 @@ private:
OASISReader::OASISReader (tl::InputStream &s)
: m_stream (s),
m_progress (tl::to_string (QObject::tr ("Reading OASIS file")), 10000),
m_progress (tl::to_string (tr ("Reading OASIS file")), 10000),
m_dbu (0.001),
m_expect_strict_mode (-1),
mm_repetition (this, "repetition"),
@ -108,7 +108,7 @@ OASISReader::OASISReader (tl::InputStream &s)
m_s_gds_property_name_id (0),
m_klayout_context_property_name_id (0)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
m_first_cellname = 0;
m_first_propname = 0;
@ -183,13 +183,13 @@ OASISReader::get_ulong_long ()
do {
unsigned char *b = (unsigned char *) m_stream.get (1);
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
return 0;
}
c = *b;
if (vm > std::numeric_limits <unsigned long long>::max () / 128 &&
(unsigned long long) (c & 0x7f) > (std::numeric_limits <unsigned long long>::max () / vm)) {
error (tl::to_string (QObject::tr ("Unsigned long value overflow")));
error (tl::to_string (tr ("Unsigned long value overflow")));
}
v += (unsigned long long) (c & 0x7f) * vm;
vm <<= 7;
@ -214,7 +214,7 @@ OASISReader::get_ulong_for_divider ()
{
unsigned long l = get_ulong ();
if (l == 0) {
error (tl::to_string (QObject::tr ("Divider must not be zero")));
error (tl::to_string (tr ("Divider must not be zero")));
}
return l;
}
@ -229,13 +229,13 @@ OASISReader::get_ulong ()
do {
unsigned char *b = (unsigned char *) m_stream.get (1);
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
return 0;
}
c = *b;
if (vm > std::numeric_limits <unsigned long>::max () / 128 &&
(unsigned long) (c & 0x7f) > (std::numeric_limits <unsigned long>::max () / vm)) {
error (tl::to_string (QObject::tr ("Unsigned long value overflow")));
error (tl::to_string (tr ("Unsigned long value overflow")));
}
v += (unsigned long) (c & 0x7f) * vm;
vm <<= 7;
@ -265,13 +265,13 @@ OASISReader::get_uint ()
do {
unsigned char *b = (unsigned char *) m_stream.get (1);
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
return 0;
}
c = *b;
if (vm > std::numeric_limits <unsigned int>::max () / 128 &&
(unsigned int) (c & 0x7f) > (std::numeric_limits <unsigned int>::max () / vm)) {
error (tl::to_string (QObject::tr ("Unsigned integer value overflow")));
error (tl::to_string (tr ("Unsigned integer value overflow")));
}
v += (unsigned int) (c & 0x7f) * vm;
vm <<= 7;
@ -342,7 +342,7 @@ OASISReader::get_real ()
unsigned char *b = (unsigned char *) m_stream.get (sizeof (i2f.i));
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
}
i2f.i = 0;
b += sizeof (i2f.i);
@ -361,7 +361,7 @@ OASISReader::get_real ()
unsigned char *b = (unsigned char *) m_stream.get (sizeof (i2f.i));
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
}
i2f.i = 0;
b += sizeof (i2f.i);
@ -372,7 +372,7 @@ OASISReader::get_real ()
return double (i2f.d);
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid real type %d")), t));
error (tl::sprintf (tl::to_string (tr ("Invalid real type %d")), t));
return 0.0;
}
}
@ -384,7 +384,7 @@ OASISReader::get_ucoord (unsigned long grid)
get (lx);
lx *= grid;
if (lx > (unsigned long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
return db::Coord (lx);
}
@ -396,7 +396,7 @@ OASISReader::get_ucoord_as_distance (unsigned long grid)
get (lx);
lx *= grid;
if (lx > (unsigned long long) (std::numeric_limits <distance_type>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
return distance_type (lx);
}
@ -409,7 +409,7 @@ OASISReader::get_coord (long grid)
lx *= grid;
if (lx < (long long) (std::numeric_limits <db::Coord>::min ()) ||
lx > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
return db::Coord (lx);
}
@ -423,7 +423,7 @@ OASISReader::get_2delta (long grid)
long long lx = l1 >> 2;
lx *= grid;
if (lx > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
db::Coord x = lx;
@ -449,7 +449,7 @@ OASISReader::get_3delta (long grid)
long long lx = l1 >> 3;
lx *= grid;
if (lx > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
db::Coord x = lx;
@ -486,7 +486,7 @@ OASISReader::get_gdelta (long grid)
lx *= grid;
if (lx < (long long) (std::numeric_limits <db::Coord>::min ()) ||
lx > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
long long ly;
@ -494,7 +494,7 @@ OASISReader::get_gdelta (long grid)
ly *= grid;
if (ly < (long long) (std::numeric_limits <db::Coord>::min ()) ||
ly > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
return db::Vector (db::Coord (lx), db::Coord (ly));
@ -504,7 +504,7 @@ OASISReader::get_gdelta (long grid)
long long lx = l1 >> 4;
lx *= grid;
if (lx > (long long) (std::numeric_limits <db::Coord>::max ())) {
error (tl::to_string (QObject::tr ("Coordinate value overflow")));
error (tl::to_string (tr ("Coordinate value overflow")));
}
db::Coord x = lx;
@ -545,8 +545,8 @@ OASISReader::warn (const std::string &msg)
} else {
// TODO: compress
tl::warn << msg
<< tl::to_string (QObject::tr (" (position=")) << m_stream.pos ()
<< tl::to_string (QObject::tr (", cell=")) << m_cellname
<< tl::to_string (tr (" (position=")) << m_stream.pos ()
<< tl::to_string (tr (", cell=")) << m_cellname
<< ")";
}
}
@ -652,31 +652,31 @@ OASISReader::read_offset_table ()
of = get_uint ();
m_table_cellname = get_ulong ();
if (m_table_cellname != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) {
warn (tl::to_string (QObject::tr ("CELLNAME offset table has unexpected strict mode")));
warn (tl::to_string (tr ("CELLNAME offset table has unexpected strict mode")));
}
of = get_uint ();
m_table_textstring = get_ulong ();
if (m_table_textstring != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) {
warn (tl::to_string (QObject::tr ("TEXTSTRING offset table has unexpected strict mode")));
warn (tl::to_string (tr ("TEXTSTRING offset table has unexpected strict mode")));
}
of = get_uint ();
m_table_propname = get_ulong ();
if (m_table_propname != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) {
warn (tl::to_string (QObject::tr ("PROPNAME offset table has unexpected strict mode")));
warn (tl::to_string (tr ("PROPNAME offset table has unexpected strict mode")));
}
of = get_uint ();
m_table_propstring = get_ulong ();
if (m_table_propstring != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) {
warn (tl::to_string (QObject::tr ("PROPSTRING offset table has unexpected strict mode")));
warn (tl::to_string (tr ("PROPSTRING offset table has unexpected strict mode")));
}
of = get_uint ();
m_table_layername = get_ulong ();
if (m_table_layername != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) {
warn (tl::to_string (QObject::tr ("LAYERNAME offset table has unexpected strict mode")));
warn (tl::to_string (tr ("LAYERNAME offset table has unexpected strict mode")));
}
// XNAME table ignored currently
@ -701,27 +701,27 @@ OASISReader::do_read (db::Layout &layout)
// read magic bytes
mb = (char *) m_stream.get (sizeof (magic_bytes) - 1);
if (! mb) {
error (tl::to_string (QObject::tr ("File too short")));
error (tl::to_string (tr ("File too short")));
return;
}
if (strncmp (mb, magic_bytes, sizeof (magic_bytes) - 1) != 0) {
error (tl::to_string (QObject::tr ("Format error (missing magic bytes)")));
error (tl::to_string (tr ("Format error (missing magic bytes)")));
}
// read first record
r = get_byte ();
if (r != 1 /*START*/) {
error (tl::to_string (QObject::tr ("Format error (START record expected)")));
error (tl::to_string (tr ("Format error (START record expected)")));
}
std::string v = get_str ();
if (v != "1.0") {
error (tl::sprintf (tl::to_string (QObject::tr ("Format error (only version 1.0 is supported, file has version %s)")), v));
error (tl::sprintf (tl::to_string (tr ("Format error (only version 1.0 is supported, file has version %s)")), v));
}
double res = get_real ();
if (res < 1e-6) {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid resolution of %g")), res));
error (tl::sprintf (tl::to_string (tr ("Invalid resolution of %g")), res));
}
// compute database unit in pixel per meter
@ -799,7 +799,7 @@ OASISReader::do_read (db::Layout &layout)
if (m_first_cellname == 0) {
m_first_cellname = m_table_start;
} else if (m_expect_strict_mode == 1 && m_in_table != InCELLNAME && m_first_cellname != 0) {
warn (tl::to_string (QObject::tr ("CELLNAME outside table in strict mode")));
warn (tl::to_string (tr ("CELLNAME outside table in strict mode")));
}
m_in_table = InCELLNAME;
@ -816,20 +816,20 @@ OASISReader::do_read (db::Layout &layout)
unsigned long id = cellname_id;
if (r == 3) {
if (cellname_id_mode == expl) {
error (tl::to_string (QObject::tr ("Explicit and implicit CELLNAME modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit CELLNAME modes cannot be mixed")));
}
cellname_id_mode = impl;
++cellname_id;
} else {
if (cellname_id_mode == impl) {
error (tl::to_string (QObject::tr ("Explicit and implicit CELLNAME modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit CELLNAME modes cannot be mixed")));
}
cellname_id_mode = expl;
get (id);
}
if (! m_cellnames.insert (std::make_pair (id, name)).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A CELLNAME with id %ld is present already")), id));
error (tl::sprintf (tl::to_string (tr ("A CELLNAME with id %ld is present already")), id));
}
reset_modal_variables ();
@ -844,7 +844,7 @@ OASISReader::do_read (db::Layout &layout)
if (m_first_textstring == 0) {
m_first_textstring = m_table_start;
} else if (m_expect_strict_mode == 1 && m_in_table != InTEXTSTRING && m_first_textstring != 0) {
warn (tl::to_string (QObject::tr ("TEXTSTRING outside table in strict mode")));
warn (tl::to_string (tr ("TEXTSTRING outside table in strict mode")));
}
m_in_table = InTEXTSTRING;
@ -862,20 +862,20 @@ OASISReader::do_read (db::Layout &layout)
unsigned long id = textstring_id;
if (r == 5) {
if (textstring_id_mode == expl) {
error (tl::to_string (QObject::tr ("Explicit and implicit TEXTSTRING modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit TEXTSTRING modes cannot be mixed")));
}
textstring_id_mode = impl;
++textstring_id;
} else {
if (textstring_id_mode == impl) {
error (tl::to_string (QObject::tr ("Explicit and implicit TEXTSTRING modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit TEXTSTRING modes cannot be mixed")));
}
textstring_id_mode = expl;
get (id);
}
if (! m_textstrings.insert (std::make_pair (id, name)).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A TEXTSTRING with id %ld is present already")), id));
error (tl::sprintf (tl::to_string (tr ("A TEXTSTRING with id %ld is present already")), id));
}
reset_modal_variables ();
@ -888,7 +888,7 @@ OASISReader::do_read (db::Layout &layout)
if (m_first_propname == 0) {
m_first_propname = m_table_start;
} else if (m_expect_strict_mode == 1 && m_in_table != InPROPNAME && m_first_propname != 0) {
warn (tl::to_string (QObject::tr ("PROPNAME outside table in strict mode")));
warn (tl::to_string (tr ("PROPNAME outside table in strict mode")));
}
m_in_table = InPROPNAME;
@ -905,20 +905,20 @@ OASISReader::do_read (db::Layout &layout)
unsigned long id = propname_id;
if (r == 7) {
if (propname_id_mode == expl) {
error (tl::to_string (QObject::tr ("Explicit and implicit PROPNAME modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit PROPNAME modes cannot be mixed")));
}
propname_id_mode = impl;
++propname_id;
} else {
if (propname_id_mode == impl) {
error (tl::to_string (QObject::tr ("Explicit and implicit PROPNAME modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit PROPNAME modes cannot be mixed")));
}
propname_id_mode = expl;
get (id);
}
if (! m_propnames.insert (std::make_pair (id, name)).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A PROPNAME with id %ld is present already")), id));
error (tl::sprintf (tl::to_string (tr ("A PROPNAME with id %ld is present already")), id));
}
// resolve forward references to property names
@ -949,7 +949,7 @@ OASISReader::do_read (db::Layout &layout)
if (s->first == s_gds_name_id) {
if (!s->second.is_list () || s->second.get_list ().size () != 2) {
error (tl::to_string (QObject::tr ("S_GDS_PROPERTY must have a value list with exactly two elements")));
error (tl::to_string (tr ("S_GDS_PROPERTY must have a value list with exactly two elements")));
}
new_set.insert (std::make_pair (rep.prop_name_id (s->second.get_list () [0]), s->second.get_list () [1]));
@ -980,7 +980,7 @@ OASISReader::do_read (db::Layout &layout)
if (m_first_propstring == 0) {
m_first_propstring = m_table_start;
} else if (m_expect_strict_mode == 1 && m_in_table != InPROPSTRING && m_first_propstring != 0) {
warn (tl::to_string (QObject::tr ("PROPSTRING outside table in strict mode")));
warn (tl::to_string (tr ("PROPSTRING outside table in strict mode")));
}
m_in_table = InPROPSTRING;
@ -997,20 +997,20 @@ OASISReader::do_read (db::Layout &layout)
unsigned long id = propstring_id;
if (r == 9) {
if (propstring_id_mode == expl) {
error (tl::to_string (QObject::tr ("Explicit and implicit PROPSTRING modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit PROPSTRING modes cannot be mixed")));
}
propstring_id_mode = impl;
++propstring_id;
} else {
if (propstring_id_mode == impl) {
error (tl::to_string (QObject::tr ("Explicit and implicit PROPSTRING modes cannot be mixed")));
error (tl::to_string (tr ("Explicit and implicit PROPSTRING modes cannot be mixed")));
}
propstring_id_mode = expl;
get (id);
}
if (! m_propstrings.insert (std::make_pair (id, name)).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A PROPSTRING with id %ld is present already")), id));
error (tl::sprintf (tl::to_string (tr ("A PROPSTRING with id %ld is present already")), id));
}
std::map<unsigned long, std::string>::iterator fw = m_propvalue_forward_references.find (id);
@ -1028,7 +1028,7 @@ OASISReader::do_read (db::Layout &layout)
if (m_first_layername == 0) {
m_first_layername = m_table_start;
} else if (m_expect_strict_mode == 1 && m_in_table != InLAYERNAME && m_first_layername != 0) {
warn (tl::to_string (QObject::tr ("LAYERNAME outside table in strict mode")));
warn (tl::to_string (tr ("LAYERNAME outside table in strict mode")));
}
m_in_table = InLAYERNAME;
@ -1059,7 +1059,7 @@ OASISReader::do_read (db::Layout &layout)
l1 = get_uint ();
l2 = get_uint ();
} else {
error (tl::to_string (QObject::tr ("Invalid LAYERNAME interval mode (layer)")));
error (tl::to_string (tr ("Invalid LAYERNAME interval mode (layer)")));
}
it = get_uint ();
@ -1076,7 +1076,7 @@ OASISReader::do_read (db::Layout &layout)
dt1 = get_uint ();
dt2 = get_uint ();
} else {
error (tl::to_string (QObject::tr ("Invalid LAYERNAME interval mode (datatype)")));
error (tl::to_string (tr ("Invalid LAYERNAME interval mode (datatype)")));
}
// add to the layer name map
@ -1153,7 +1153,7 @@ OASISReader::do_read (db::Layout &layout)
unsigned long id = 0;
get (id);
if (! m_defined_cells_by_id.insert (id).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A cell with id %ld is defined already")), id));
error (tl::sprintf (tl::to_string (tr ("A cell with id %ld is defined already")), id));
}
std::map <unsigned long, db::cell_index_type>::const_iterator c = m_cells_by_id.find (id);
@ -1187,12 +1187,12 @@ OASISReader::do_read (db::Layout &layout)
} else {
if (m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("CELL names must be references to CELLNAME ids in strict mode")));
warn (tl::to_string (tr ("CELL names must be references to CELLNAME ids in strict mode")));
}
std::string name = get_str ();
if (! m_defined_cells_by_name.insert (name).second) {
error (tl::sprintf (tl::to_string (QObject::tr ("A cell with name %s is defined already")), name.c_str ()));
error (tl::sprintf (tl::to_string (tr ("A cell with name %s is defined already")), name.c_str ()));
}
std::map <std::string, db::cell_index_type>::const_iterator c = m_cells_by_name.find (name);
@ -1219,7 +1219,7 @@ OASISReader::do_read (db::Layout &layout)
unsigned int type = get_uint ();
if (type != 0) {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid CBLOCK compression type %d")), type));
error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type));
}
get_uint (); // uncomp-byte-count - not needed
@ -1229,7 +1229,7 @@ OASISReader::do_read (db::Layout &layout)
m_stream.inflate ();
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid record type on global level %d")), int (r)));
error (tl::sprintf (tl::to_string (tr ("Invalid record type on global level %d")), int (r)));
}
}
@ -1248,19 +1248,19 @@ OASISReader::do_read (db::Layout &layout)
// read over tail and discard
mb = (char *) m_stream.get (pt + 254 - m_stream.pos ());
if (! mb) {
error (tl::to_string (QObject::tr ("Format error (too few bytes after END record)")));
error (tl::to_string (tr ("Format error (too few bytes after END record)")));
}
// check if there are no more bytes
mb = (char *) m_stream.get (254);
if (mb) {
error (tl::to_string (QObject::tr ("Format error (too many bytes after END record)")));
error (tl::to_string (tr ("Format error (too many bytes after END record)")));
}
for (std::map <unsigned long, const db::StringRef *>::const_iterator fw = m_text_forward_references.begin (); fw != m_text_forward_references.end (); ++fw) {
std::map <unsigned long, std::string>::const_iterator ts = m_textstrings.find (fw->first);
if (ts == m_textstrings.end ()) {
error (tl::sprintf (tl::to_string (QObject::tr ("No text string defined for text string id %ld")), fw->first));
error (tl::sprintf (tl::to_string (tr ("No text string defined for text string id %ld")), fw->first));
} else {
layout.string_repository ().change_string_ref (fw->second, ts->second);
}
@ -1268,7 +1268,7 @@ OASISReader::do_read (db::Layout &layout)
// all forward references to property names must be resolved
for (std::map <unsigned long, db::property_names_id_type>::const_iterator fw = m_propname_forward_references.begin (); fw != m_propname_forward_references.end (); ++fw) {
error (tl::sprintf (tl::to_string (QObject::tr ("No property name defined for property name id %ld")), fw->first));
error (tl::sprintf (tl::to_string (tr ("No property name defined for property name id %ld")), fw->first));
}
// resolve all propvalue forward referenced
@ -1285,7 +1285,7 @@ OASISReader::do_read (db::Layout &layout)
if (fw != m_propvalue_forward_references.end ()) {
ps->second = tl::Variant (fw->second);
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("No property value defined for property value id %ld")), id));
error (tl::sprintf (tl::to_string (tr ("No property value defined for property value id %ld")), id));
}
} else if (ps->second.is_list ()) {
@ -1309,7 +1309,7 @@ OASISReader::do_read (db::Layout &layout)
if (fw != m_propvalue_forward_references.end ()) {
*ll = tl::Variant (fw->second);
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("No property value defined for property value id %ld")), id));
error (tl::sprintf (tl::to_string (tr ("No property value defined for property value id %ld")), id));
}
}
}
@ -1333,7 +1333,7 @@ OASISReader::do_read (db::Layout &layout)
std::map <unsigned long, std::string>::const_iterator cn = m_cellnames.find (fw->first);
if (cn == m_cellnames.end ()) {
error (tl::sprintf (tl::to_string (QObject::tr ("No cellname defined for cell name id %ld")), fw->first));
error (tl::sprintf (tl::to_string (tr ("No cellname defined for cell name id %ld")), fw->first));
} else {
@ -1407,19 +1407,19 @@ OASISReader::do_read (db::Layout &layout)
// Check the table offsets vs. real occurance
if (m_first_cellname != 0 && m_first_cellname != m_table_cellname && m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("CELLNAME table offset does not match first occurance of CELLNAME in strict mode - %1 vs. %2").arg (m_table_cellname).arg (m_first_cellname)));
warn (tl::sprintf (tl::to_string (tr ("CELLNAME table offset does not match first occurance of CELLNAME in strict mode - %s vs. %s")), m_table_cellname, m_first_cellname));
}
if (m_first_propname != 0 && m_first_propname != m_table_propname && m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("PROPNAME table offset does not match first occurance of PROPNAME in strict mode - %1 vs. %2").arg (m_table_propname).arg (m_first_propname)));
warn (tl::sprintf (tl::to_string (tr ("PROPNAME table offset does not match first occurance of PROPNAME in strict mode - %s vs. %s")), m_table_propname, m_first_propname));
}
if (m_first_propstring != 0 && m_first_propstring != m_table_propstring && m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("PROPSTRING table offset does not match first occurance of PROPSTRING in strict mode - %1 vs. %2").arg (m_table_propstring).arg (m_first_propstring)));
warn (tl::sprintf (tl::to_string (tr ("PROPSTRING table offset does not match first occurance of PROPSTRING in strict mode - %s vs. %s")), m_table_propstring, m_first_propstring));
}
if (m_first_layername != 0 && m_first_layername != m_table_layername && m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("LAYERNAME table offset does not match first occurance of LAYERNAME in strict mode - %1 vs. %2").arg (m_table_layername).arg (m_first_layername)));
warn (tl::sprintf (tl::to_string (tr ("LAYERNAME table offset does not match first occurance of LAYERNAME in strict mode - %s vs. %s")), m_table_layername, m_first_layername));
}
if (m_first_textstring != 0 && m_first_textstring != m_table_textstring && m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("TEXTSTRING table offset does not match first occurance of TEXTSTRING in strict mode - %1 vs. %2").arg (m_table_textstring).arg (m_first_textstring)));
warn (tl::sprintf (tl::to_string (tr ("TEXTSTRING table offset does not match first occurance of TEXTSTRING in strict mode - %s vs. %s")), m_table_textstring, m_first_textstring));
}
}
@ -1433,7 +1433,7 @@ OASISReader::store_last_properties (db::PropertiesRepository &rep, db::Propertie
} else if (mm_last_property_is_sprop.get () && mm_last_property_name.get () == m_s_gds_property_name_id) {
if (mm_last_value_list.get ().size () != 2) {
error (tl::to_string (QObject::tr ("S_GDS_PROPERTY must have a value list with exactly two elements")));
error (tl::to_string (tr ("S_GDS_PROPERTY must have a value list with exactly two elements")));
}
properties.insert (std::make_pair (rep.prop_name_id (mm_last_value_list.get () [0]), mm_last_value_list.get () [1]));
@ -1473,7 +1473,7 @@ OASISReader::read_element_properties (db::PropertiesRepository &rep, bool ignore
unsigned int type = get_uint ();
if (type != 0) {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid CBLOCK compression type %d")), type));
error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type));
}
get_uint (); // uncomp-byte-count - not needed
@ -1533,7 +1533,7 @@ OASISReader::read_properties (db::PropertiesRepository &rep)
} else {
if (m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("PROPERTY names must be references to PROPNAME ids in strict mode")));
warn (tl::to_string (tr ("PROPERTY names must be references to PROPNAME ids in strict mode")));
}
mm_last_property_name = rep.prop_name_id (tl::Variant (get_str ()));
@ -1583,7 +1583,7 @@ OASISReader::read_properties (db::PropertiesRepository &rep)
} else if (t == 10 || t == 11 || t == 12) {
if (m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("PROPERTY strings must be references to PROPSTRING ids in strict mode")));
warn (tl::to_string (tr ("PROPERTY strings must be references to PROPSTRING ids in strict mode")));
}
if (m_read_properties) {
@ -1607,7 +1607,7 @@ OASISReader::read_properties (db::PropertiesRepository &rep)
}
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid property value type %d")), int (t)));
error (tl::sprintf (tl::to_string (tr ("Invalid property value type %d")), int (t)));
}
--n;
@ -1629,7 +1629,7 @@ OASISReader::read_pointlist (modal_variable <std::vector <db::Point> > &pointlis
unsigned long n = 0;
get (n);
if (n == 0) {
error (tl::to_string (QObject::tr ("Invalid point list: length is zero")).c_str ());
error (tl::to_string (tr ("Invalid point list: length is zero")).c_str ());
}
pointlist.get_non_const ().clear ();
@ -1661,7 +1661,7 @@ OASISReader::read_pointlist (modal_variable <std::vector <db::Point> > &pointlis
// synthesize the last point for polygons
if (for_polygon) {
if ((n % 2) != 0) {
warn (tl::to_string (QObject::tr ("Type 0 or 1 point list with odd number of points is illegal")));
warn (tl::to_string (tr ("Type 0 or 1 point list with odd number of points is illegal")));
}
if (h) {
pointlist.get_non_const ().push_back (db::Point (0, pos.y ()));
@ -1705,7 +1705,7 @@ OASISReader::read_pointlist (modal_variable <std::vector <db::Point> > &pointlis
}
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid point list type %d")), type));
error (tl::sprintf (tl::to_string (tr ("Invalid point list type %d")), type));
}
pointlist.set_initialized ();
@ -1840,7 +1840,7 @@ OASISReader::read_repetition ()
}
} else {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid repetition type %d")), type));
error (tl::sprintf (tl::to_string (tr ("Invalid repetition type %d")), type));
}
return mm_repetition.get ().size () > 1;
@ -1977,7 +1977,7 @@ OASISReader::do_read_placement (unsigned char r,
angle_deg = get_real ();
double a = angle_deg / 90.0;
if (a < -4 || a > 4) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid rotation angle (%g is less than -360 or larger than 360)")), angle_deg));
warn (tl::sprintf (tl::to_string (tr ("Invalid rotation angle (%g is less than -360 or larger than 360)")), angle_deg));
}
angle = int (a < 0 ? (a - 0.5) : (a + 0.5));
if (fabs (double (angle) - a) > 1e-6) {
@ -2128,7 +2128,7 @@ OASISReader::do_read_text (bool xy_absolute,
} else {
if (m_expect_strict_mode == 1) {
warn (tl::to_string (QObject::tr ("TEXT strings must be references to TEXTSTRING ids in strict mode")));
warn (tl::to_string (tr ("TEXT strings must be references to TEXTSTRING ids in strict mode")));
}
mm_text_string = get_str ();
@ -2435,7 +2435,7 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index,
db::Cell &cell = layout.cell (cell_index);
if (mm_polygon_point_list.get ().size () < 3) {
warn (tl::to_string (QObject::tr ("POLYGON with less than 3 points ignored")));
warn (tl::to_string (tr ("POLYGON with less than 3 points ignored")));
} else {
// convert the OASIS record into the polygon.
@ -2507,7 +2507,7 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index,
if (ll.first) {
if (mm_polygon_point_list.get ().size () < 3) {
warn (tl::to_string (QObject::tr ("POLYGON with less than 3 points ignored")));
warn (tl::to_string (tr ("POLYGON with less than 3 points ignored")));
} else {
// convert the OASIS record into the polygon.
@ -2600,7 +2600,7 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db:
if (ll.first) {
if (mm_path_point_list.get ().size () < 2) {
warn (tl::to_string (QObject::tr ("POLYGON with less than 2 points ignored")));
warn (tl::to_string (tr ("POLYGON with less than 2 points ignored")));
} else {
// convert the OASIS record into the path.
@ -2676,7 +2676,7 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db:
if (ll.first) {
if (mm_path_point_list.get ().size () < 2) {
warn (tl::to_string (QObject::tr ("PATH with less than 2 points ignored")));
warn (tl::to_string (tr ("PATH with less than 2 points ignored")));
} else {
// convert the OASIS record into the path.
@ -3095,7 +3095,7 @@ OASISReader::do_read_ctrapezoid (bool xy_absolute,db::cell_index_type cell_index
};
if (mm_ctrapezoid_type.get () >= sizeof (ctraps_table) / sizeof (ctraps_table [0])) {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid CTRAPEZOID type %d")), int (mm_ctrapezoid_type.get ())));
error (tl::sprintf (tl::to_string (tr ("Invalid CTRAPEZOID type %d")), int (mm_ctrapezoid_type.get ())));
}
db::Coord w = 0, h = 0;
@ -3538,7 +3538,7 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout)
unsigned int type = get_uint ();
if (type != 0) {
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid CBLOCK compression type %d")), type));
error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type));
}
get_uint (); // uncomp-byte-count - not needed

View File

@ -54,7 +54,7 @@ class DB_PLUGIN_PUBLIC OASISReaderException
{
public:
OASISReaderException (const std::string &msg, size_t p, const std::string &cell)
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (position=%ld, cell=%s)")), msg, p, cell))
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (position=%ld, cell=%s)")), msg, p, cell))
{ }
};
@ -255,7 +255,7 @@ private:
{
unsigned char *b = (unsigned char *) m_stream.get (1);
if (! b) {
error (tl::to_string (QObject::tr ("Unexpected end-of-file")));
error (tl::to_string (tr ("Unexpected end-of-file")));
return 0;
} else {
return *b;

View File

@ -670,9 +670,9 @@ OASISWriter::OASISWriter ()
m_propname_id (0),
m_propstring_id (0),
m_proptables_written (false),
m_progress (tl::to_string (QObject::tr ("Writing OASIS file")), 10000)
m_progress (tl::to_string (tr ("Writing OASIS file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}
@ -2367,7 +2367,7 @@ OASISWriter::write (const db::SimplePolygon &polygon, db::properties_id_type pro
}
if (m_pointlist.size () < 2) {
std::string msg = tl::to_string (QObject::tr ("Polygons with less than three points cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (QObject::tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
std::string msg = tl::to_string (tr ("Polygons with less than three points cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
if (m_options.permissive) {
tl::warn << msg;
return;
@ -2468,7 +2468,7 @@ OASISWriter::write (const db::Polygon &polygon, db::properties_id_type prop_id,
}
if (m_pointlist.size () < 2) {
std::string msg = tl::to_string (QObject::tr ("Polygons with less than three points cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (QObject::tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
std::string msg = tl::to_string (tr ("Polygons with less than three points cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
if (m_options.permissive) {
tl::warn << msg;
return;
@ -2644,9 +2644,9 @@ OASISWriter::write (const db::Path &path, db::properties_id_type prop_id, const
db::Coord w = safe_scale (m_sf, path.width ());
db::Coord hw = w / 2;
if (hw * 2 != w) {
std::string msg = tl::to_string (QObject::tr ("Circles with odd diameter cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (QObject::tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
std::string msg = tl::to_string (tr ("Circles with odd diameter cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
if (m_options.permissive) {
tl::warn << msg << " - " << tl::to_string (QObject::tr ("circle diameter is rounded"));
tl::warn << msg << " - " << tl::to_string (tr ("circle diameter is rounded"));
} else {
throw tl::Exception (msg);
}
@ -2716,9 +2716,9 @@ OASISWriter::write (const db::Path &path, db::properties_id_type prop_id, const
db::Coord w = safe_scale (m_sf, path.width ());
db::Coord hw = w / 2;
if (hw * 2 != w) {
std::string msg = tl::to_string (QObject::tr ("Paths with odd width cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (QObject::tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
std::string msg = tl::to_string (tr ("Paths with odd width cannot be written to OASIS files (cell ")) + mp_layout->cell_name (mp_cell->cell_index ()) + tl::to_string (tr (", position ")) + tl::to_string (start.x ()) + ", " + tl::to_string (start.y ()) + " DBU)";
if (m_options.permissive) {
tl::warn << msg << " - " << tl::to_string (QObject::tr ("path diameter is rounded"));
tl::warn << msg << " - " << tl::to_string (tr ("path diameter is rounded"));
} else {
throw tl::Exception (msg);
}

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -30,7 +30,6 @@
#include "tlUnitTest.h"
#include <cstdlib>
#include <QDir>
void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int compr, bool recompress)
{

View File

@ -28,7 +28,6 @@
#include "tlUnitTest.h"
#include <stdlib.h>
#include <QDir>
// Test the writer's capabilities to write polygon's with holes
TEST(1)

View File

@ -412,7 +412,7 @@ GerberDrillFileReader::process_line (const std::string &s)
// some file formats indicate "no tool" with this code ..
m_current_diameter = 0.0;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Undefined tool code %d")), tcode);
throw tl::Exception (tl::to_string (tr ("Undefined tool code %d")), tcode);
}
} else {
m_current_diameter = m_tools [tcode];
@ -766,11 +766,11 @@ GerberDrillFileReader::process_line (const std::string &s)
}
if (! ex.at_end ()) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Part of line ignored: %s")), ex.skip ()));
warn (tl::sprintf (tl::to_string (tr ("Part of line ignored: %s")), ex.skip ()));
}
} else if (!m_in_header && c != 0) {
warn (tl::to_string (QObject::tr ("Statement ignored")));
warn (tl::to_string (tr ("Statement ignored")));
}
}

View File

@ -28,10 +28,9 @@
#include "tlString.h"
#include "tlString.h"
#include "tlLog.h"
#include "tlFileUtils.h"
#include "dbShapeProcessor.h"
#include <QDir>
#include <cmath>
#include <cctype>
@ -75,7 +74,7 @@ static void parse_format (const std::string &format, int &l, int &t, bool &tz)
}
} catch (tl::Exception &ex) {
throw tl::Exception (tl::to_string (QObject::tr ("Gerber format specification '%s' is invalid: %s")), format, ex.msg ());
throw tl::Exception (tl::to_string (tr ("Gerber format specification '%s' is invalid: %s")), format, ex.msg ());
}
}
@ -114,9 +113,9 @@ GerberFileReader::GerberFileReader ()
m_orot (0.0), m_os (1.0), m_omx (false), m_omy (false),
m_ep (true /*report progress*/),
mp_layout (0), mp_top_cell (0), mp_stream (0),
m_progress (tl::to_string (QObject::tr ("Reading Gerber file")), 10000)
m_progress (tl::to_string (tr ("Reading Gerber file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
m_progress.set_unit (1024 * 1024);
}
@ -142,7 +141,7 @@ GerberFileReader::scan (tl::TextInputStream &stream)
try {
meta_data = do_scan();
} catch (tl::Exception &ex) {
throw tl::Exception (ex.msg () + tl::to_string (QObject::tr (" in line ")) + tl::to_string (stream.line_number ()));
throw tl::Exception (ex.msg () + tl::to_string (tr (" in line ")) + tl::to_string (stream.line_number ()));
}
mp_stream = 0;
@ -167,7 +166,7 @@ GerberFileReader::read (tl::TextInputStream &stream, db::Layout &layout, db::Cel
} catch (tl::BreakException &) {
throw;
} catch (tl::Exception &ex) {
throw tl::Exception (ex.msg () + tl::to_string (QObject::tr (" in line ")) + tl::to_string (stream.line_number ()));
throw tl::Exception (ex.msg () + tl::to_string (tr (" in line ")) + tl::to_string (stream.line_number ()));
}
flush ();
@ -195,13 +194,13 @@ GerberFileReader::format_string () const
void
GerberFileReader::warn (const std::string &warning)
{
tl::warn << warning << tl::to_string (QObject::tr (" in line ")) << mp_stream->line_number () << tl::to_string (QObject::tr (" (file ")) << mp_stream->source () << ")";
tl::warn << warning << tl::to_string (tr (" in line ")) << mp_stream->line_number () << tl::to_string (tr (" (file ")) << mp_stream->source () << ")";
}
void
GerberFileReader::error (const std::string &error)
{
tl::error << error << tl::to_string (QObject::tr (" in line ")) << mp_stream->line_number () << tl::to_string (QObject::tr (" (file ")) << mp_stream->source () << ")";
tl::error << error << tl::to_string (tr (" in line ")) << mp_stream->line_number () << tl::to_string (tr (" (file ")) << mp_stream->source () << ")";
}
void
@ -246,12 +245,12 @@ GerberFileReader::read_coord (tl::Extractor &ex)
number /= pow (10.0, ndigits);
} else if (m_omit_leading_zeroes) {
if (m_digits_after < 0) {
error (tl::to_string (QObject::tr ("Undefined number of digits - format missing")));
error (tl::to_string (tr ("Undefined number of digits - format missing")));
}
number /= pow (10.0, m_digits_after);
} else {
if (m_digits_before < 0) {
error (tl::to_string (QObject::tr ("Undefined number of digits - format missing")));
error (tl::to_string (tr ("Undefined number of digits - format missing")));
}
number /= pow (10.0, ndigits - m_digits_before);
}
@ -537,8 +536,7 @@ void
GerberImporter::load_project (const std::string &fn)
{
// use the file's absolute path as the base directory
QFileInfo fi (tl::to_qstring (fn));
m_dir = tl::to_string (fi.absolutePath ());
m_dir = tl::absolute_file_path (fn);
tl::InputStream stream (fn);
tl::TextInputStream text_stream (stream);
@ -552,7 +550,7 @@ GerberImporter::load_project (tl::TextInputStream &stream)
try {
do_load_project (stream);
} catch (tl::Exception &ex) {
throw tl::Exception (ex.msg () + tl::to_string (QObject::tr (" in line ")) + tl::to_string (stream.line_number ()));
throw tl::Exception (ex.msg () + tl::to_string (tr (" in line ")) + tl::to_string (stream.line_number ()));
}
}
@ -627,7 +625,7 @@ GerberImporter::do_load_project (tl::TextInputStream &stream)
l.read (m_dbu);
if (m_dbu < 1e-6) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid database unit %g")), m_dbu);
throw tl::Exception (tl::to_string (tr ("Invalid database unit %g")), m_dbu);
}
} else if (l.test ("cell-name")) {
@ -646,7 +644,7 @@ GerberImporter::do_load_project (tl::TextInputStream &stream)
l.read (m_circle_points);
if (m_circle_points < 4) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid number of points for full circle (%d)")), m_circle_points);
throw tl::Exception (tl::to_string (tr ("Invalid number of points for full circle (%d)")), m_circle_points);
}
} else if (l.test ("keep-path")) {
@ -762,7 +760,7 @@ GerberImporter::do_load_project (tl::TextInputStream &stream)
l.read (cp);
if (cp < 4) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid number of points for full circle (%d)")), m_circle_points);
throw tl::Exception (tl::to_string (tr ("Invalid number of points for full circle (%d)")), m_circle_points);
}
file.set_circle_points (cp);
@ -809,12 +807,12 @@ GerberImporter::do_load_project (tl::TextInputStream &stream)
m_reference_points.clear ();
if (ref_points.size () > 3) {
throw tl::Exception (tl::to_string (QObject::tr ("Not more than three reference points can be specified")));
throw tl::Exception (tl::to_string (tr ("Not more than three reference points can be specified")));
}
for (unsigned int i = 0; i < ref_points.size (); ++i) {
if (ref_points [i].first.empty () || ref_points [i].second.empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Reference point #%d is not fully specified (either PCB or layout coordinate is missing)")), int (i + 1));
throw tl::Exception (tl::to_string (tr ("Reference point #%d is not fully specified (either PCB or layout coordinate is missing)")), int (i + 1));
}
m_reference_points.push_back (std::make_pair (ref_points [i].first.center (), ref_points [i].second.center ()));
}
@ -885,12 +883,12 @@ GerberImporter::read (db::Layout &layout)
void
GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index)
{
tl::log << tl::to_string (QObject::tr ("Importing PCB data"));
tl::log << tl::to_string (tr ("Importing PCB data"));
std::set<unsigned int> inverse_layers;
{
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Importing PCB data")), m_files.size (), 1);
tl::RelativeProgress progress (tl::to_string (tr ("Importing PCB data")), m_files.size (), 1);
// derive the actual global transformation from the reference points
db::DCplxTrans global_trans (m_global_trans);
@ -921,7 +919,7 @@ GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index)
}
if (ru < 0 || rm < 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Unable to deduce rotation from reference points p1 and p2 (PCB and layout)")));
throw tl::Exception (tl::to_string (tr ("Unable to deduce rotation from reference points p1 and p2 (PCB and layout)")));
}
if (m_reference_points.size () > 2) {
@ -983,8 +981,8 @@ GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index)
}
QFileInfo fi (QDir (tl::to_qstring (m_dir)), tl::to_qstring (file->filename ()));
tl::InputStream input_file (tl::to_string (fi.absoluteFilePath ()));
std::string fp = tl::combine_path (tl::absolute_file_path (m_dir), file->filename ());
tl::InputStream input_file (fp);
tl::TextInputStream stream (input_file);
std::vector <tl::shared_ptr<db::GerberFileReader> > readers = get_readers ();
@ -1000,7 +998,7 @@ GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index)
}
if (! reader) {
throw tl::Exception (tl::to_string (QObject::tr ("Unable to determine format for file '%s'")), tl::to_string (fi.absoluteFilePath ()).c_str ());
throw tl::Exception (tl::to_string (tr ("Unable to determine format for file '%s'")), fp);
}
stream.reset ();
@ -1054,7 +1052,7 @@ GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index)
tl::log << "Inverting layer " << layout.get_properties (*l).to_string ();
sp.enable_progress (tl::to_string (QObject::tr ("Inverting layer")) + " " + tl::to_string (n + 1) + " " + tl::to_string (QObject::tr ("of")) + " " + tl::to_string (inverse_layers.size ()));
sp.enable_progress (tl::to_string (tr ("Inverting layer")) + " " + tl::to_string (n + 1) + " " + tl::to_string (tr ("of")) + " " + tl::to_string (inverse_layers.size ()));
sp.boolean (layout, cell, *l, layout, cell, bbox_layer, cell.shapes (*l), db::BooleanOp::BNotA, true);
// clear the result layer for all called cells (if there are some)

View File

@ -603,7 +603,7 @@ RS274XMacroAperture::do_produce_flash ()
try {
do_produce_flash_internal ();
} catch (tl::Exception &ex) {
throw tl::Exception (ex.msg () + " (" + tl::to_string (QObject::tr ("expanding macro")) + " " + m_name + ")");
throw tl::Exception (ex.msg () + " (" + tl::to_string (tr ("expanding macro")) + " " + m_name + ")");
}
}
@ -619,7 +619,7 @@ RS274XMacroAperture::read_exposure (tl::Extractor &ex, bool &clear, bool &clear_
} else if (pol == 2) {
clear = !clear_set || !clear;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid exposure code '%d'")), pol);
throw tl::Exception (tl::to_string (tr ("Invalid exposure code '%d'")), pol);
}
clear_set = true;
@ -698,7 +698,7 @@ RS274XMacroAperture::do_produce_flash_internal ()
db::DVector p (to - from);
if (p.sq_length () < 1e-10) {
throw tl::Exception (tl::to_string (QObject::tr ("Identical start and end point in type 2 or 20 aperture macro primitive")));
throw tl::Exception (tl::to_string (tr ("Identical start and end point in type 2 or 20 aperture macro primitive")));
}
clear_points ();
@ -756,7 +756,7 @@ RS274XMacroAperture::do_produce_flash_internal ()
ex.expect (",");
int n = int (read_expr (ex) + 0.5);
if (n < 1) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid point count in outline element in aperture macro")));
throw tl::Exception (tl::to_string (tr ("Invalid point count in outline element in aperture macro")));
}
std::vector<db::DPoint> points;
@ -833,7 +833,7 @@ RS274XMacroAperture::do_produce_flash_internal ()
ex.expect (",");
int n = int (read_expr (ex) + 0.5);
if (n < 3) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid point count in polygon element in aperture macro")));
throw tl::Exception (tl::to_string (tr ("Invalid point count in polygon element in aperture macro")));
}
ex.expect (",");

View File

@ -232,7 +232,7 @@ RS274XReader::do_read ()
param += stream ().get_char ();
if (stream ().at_end ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Unexpected EOF")));
throw tl::Exception (tl::to_string (tr ("Unexpected EOF")));
}
param += stream ().get_char ();
@ -274,7 +274,7 @@ RS274XReader::do_read ()
if (dcode.empty ()) {
if (graphics_stack_empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("AB closed without initial opening AB command")));
throw tl::Exception (tl::to_string (tr ("AB closed without initial opening AB command")));
} else {
db::Region region;
collect (region);
@ -283,7 +283,7 @@ RS274XReader::do_read ()
}
} else if (m_polygon_mode) {
warn (tl::to_string (QObject::tr ("AB command inside polygon sequence (G36/G37) - polygon ignored")));
warn (tl::to_string (tr ("AB command inside polygon sequence (G36/G37) - polygon ignored")));
} else {
push_state (dcode);
}
@ -318,7 +318,7 @@ RS274XReader::do_read ()
read_if_parameter (get_block ());
} else {
get_block ();
warn (tl::to_string (QObject::tr ("Parameter ignored: ")) + param);
warn (tl::to_string (tr ("Parameter ignored: ")) + param);
}
}
@ -441,7 +441,7 @@ RS274XReader::do_read ()
m_current_gcode = 1;
} else if (gcode >= 0) {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid 'G' code %d - ignored")), gcode));
warn (tl::sprintf (tl::to_string (tr ("Invalid 'G' code %d - ignored")), gcode));
}
} else if (c == 'X') {
@ -481,7 +481,7 @@ RS274XReader::do_read ()
// set current aperture
if (dcode >= int (m_apertures.size ()) || m_apertures[dcode] == 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Aperture code D%d is invalid or undefined")), dcode);
throw tl::Exception (tl::to_string (tr ("Aperture code D%d is invalid or undefined")), dcode);
}
m_current_aperture = m_apertures[dcode];
@ -496,11 +496,11 @@ RS274XReader::do_read ()
}
} else {
warn (tl::sprintf (tl::to_string (QObject::tr ("Invalid D code %d ignored")), dcode));
warn (tl::sprintf (tl::to_string (tr ("Invalid D code %d ignored")), dcode));
}
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid function code '%c'")), c);
throw tl::Exception (tl::to_string (tr ("Invalid function code '%c'")), c);
}
}
@ -527,11 +527,11 @@ RS274XReader::do_read ()
// flash
if (! m_current_aperture) {
throw tl::Exception (tl::to_string (QObject::tr ("No aperture defined (missing G54 block)")));
throw tl::Exception (tl::to_string (tr ("No aperture defined (missing G54 block)")));
}
if (m_polygon_mode) {
warn (tl::to_string (QObject::tr ("D03 blocks are ignored in polygon mode")));
warn (tl::to_string (tr ("D03 blocks are ignored in polygon mode")));
} else {
m_current_aperture->produce_flash (db::DCplxTrans (db::DVector (x, y)) * object_trans (), *this, ep (), is_clear_polarity ());
}
@ -588,7 +588,7 @@ RS274XReader::do_read ()
}
if (! has_center) {
warn (tl::sprintf (tl::to_string (QObject::tr ("No suitable center point found for G%d code: P1=%s P2=%s I=%g J=%g")),
warn (tl::sprintf (tl::to_string (tr ("No suitable center point found for G%d code: P1=%s P2=%s I=%g J=%g")),
m_current_gcode, from.to_string (), to.to_string (), i, j));
}
@ -624,7 +624,7 @@ RS274XReader::do_read ()
} else {
if (! m_current_aperture) {
throw tl::Exception (tl::to_string (QObject::tr ("No aperture defined (missing G54 block)")));
throw tl::Exception (tl::to_string (tr ("No aperture defined (missing G54 block)")));
}
m_current_aperture->produce_linear (db::DCplxTrans (db::DVector (m_x, m_y)) * object_trans (), pe - db::DPoint (m_x, m_y), *this, ep (), is_clear_polarity ());
@ -643,7 +643,7 @@ RS274XReader::do_read ()
} else if (m_current_gcode == 0) {
// is it correct to ignore G00?
warn (tl::to_string (QObject::tr ("Block with G00 interpolation mode is ignored")));
warn (tl::to_string (tr ("Block with G00 interpolation mode is ignored")));
} else if (m_current_gcode == 1 || m_current_gcode < 0) {
@ -653,7 +653,7 @@ RS274XReader::do_read ()
} else {
if (! m_current_aperture) {
throw tl::Exception (tl::to_string (QObject::tr ("No aperture defined (missing G54 block)")));
throw tl::Exception (tl::to_string (tr ("No aperture defined (missing G54 block)")));
}
m_current_aperture->produce_linear (db::DCplxTrans (db::DVector (m_x, m_y)) * object_trans (), db::DPoint (x, y) - db::DPoint (m_x, m_y), *this, ep (), is_clear_polarity ());
@ -661,7 +661,7 @@ RS274XReader::do_read ()
}
} else {
throw tl::Exception (tl::to_string (QObject::tr ("G00 or unspecified 'G' code requires D03")));
throw tl::Exception (tl::to_string (tr ("G00 or unspecified 'G' code requires D03")));
}
}
@ -676,7 +676,7 @@ RS274XReader::do_read ()
}
if (! graphics_stack_empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("AB block not closed")));
throw tl::Exception (tl::to_string (tr ("AB block not closed")));
}
}
@ -709,7 +709,7 @@ RS274XReader::read_as_parameter (const std::string &block)
} else if (block == "AYBX") {
m_axis_mapping = ab_yx;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid argument '%s' for AS parameter")), block);
throw tl::Exception (tl::to_string (tr ("Invalid argument '%s' for AS parameter")), block);
}
}
@ -752,7 +752,7 @@ RS274XReader::read_fs_parameter (const std::string &block)
ex.expect ("Y");
ex.read (j);
if (i != j) {
throw tl::Exception (tl::to_string (QObject::tr ("X and Y format must be identical currently")));
throw tl::Exception (tl::to_string (tr ("X and Y format must be identical currently")));
}
if (ex.test ("D")) {
@ -798,7 +798,7 @@ RS274XReader::read_mo_parameter (const std::string &block)
} else if (block == "MM") {
set_unit (1000);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid argument of M0 parameter - must be 'IN' or 'MM', not '%s'")), block);
throw tl::Exception (tl::to_string (tr ("Invalid argument of M0 parameter - must be 'IN' or 'MM', not '%s'")), block);
}
}
@ -846,7 +846,7 @@ RS274XReader::read_sf_parameter (const std::string &block)
}
if (fabs (sx - sy) > 1e-6) {
throw tl::Exception (tl::to_string (QObject::tr ("Different scalings for x and y axis is not supported currently.")));
throw tl::Exception (tl::to_string (tr ("Different scalings for x and y axis is not supported currently.")));
}
update_local_scale (sx);
@ -896,7 +896,7 @@ RS274XReader::read_lm_parameter (const std::string &block)
void
RS274XReader::read_ij_parameter (const std::string & /*block*/)
{
warn (tl::to_string (QObject::tr ("IJ parameters are ignored currently")));
warn (tl::to_string (tr ("IJ parameters are ignored currently")));
}
void
@ -958,7 +958,7 @@ RS274XReader::read_ir_parameter (const std::string &block)
void
RS274XReader::read_pf_parameter (const std::string & /*block*/)
{
warn (tl::to_string (QObject::tr ("PF parameters are ignored")));
warn (tl::to_string (tr ("PF parameters are ignored")));
}
void
@ -976,7 +976,7 @@ RS274XReader::read_ad_parameter (const std::string &block)
ex.read (dcode);
if (dcode < 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid D code for AD parameter")));
throw tl::Exception (tl::to_string (tr ("Invalid D code for AD parameter")));
}
while (int (m_apertures.size ()) <= dcode) {
@ -1000,7 +1000,7 @@ RS274XReader::read_ad_parameter (const std::string &block)
} else if (m_aperture_macros.find (name) != m_aperture_macros.end ()) {
m_apertures[dcode] = new RS274XMacroAperture (*this, name, m_aperture_macros[name], ex);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid aperture name '%s' (not a macro name and not a standard aperture) for AD parameter")), name);
throw tl::Exception (tl::to_string (tr ("Invalid aperture name '%s' (not a macro name and not a standard aperture) for AD parameter")), name);
}
}
@ -1015,11 +1015,11 @@ RS274XReader::install_block_aperture (const std::string &d, const db::Region &re
ex.read (dcode);
ex.expect_end ();
} catch (...) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid aperture code string for AB command")));
throw tl::Exception (tl::to_string (tr ("Invalid aperture code string for AB command")));
}
if (dcode < 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid D code for AB command")));
throw tl::Exception (tl::to_string (tr ("Invalid D code for AB command")));
}
while (int (m_apertures.size ()) <= dcode) {
@ -1048,7 +1048,7 @@ RS274XReader::read_am_parameter (const std::string &block)
void
RS274XReader::read_ko_parameter (const std::string & /*block*/)
{
warn (tl::to_string (QObject::tr ("KO parameters are not supported currently")));
warn (tl::to_string (tr ("KO parameters are not supported currently")));
}
void
@ -1075,7 +1075,7 @@ RS274XReader::read_lp_parameter (const std::string &block)
}
m_clear = false;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid argument '%s' for LP parameter")), block);
throw tl::Exception (tl::to_string (tr ("Invalid argument '%s' for LP parameter")), block);
}
}
@ -1130,7 +1130,7 @@ RS274XReader::read_sr_parameter (const std::string &block)
void
RS274XReader::read_if_parameter (const std::string & /*block*/)
{
warn (tl::to_string (QObject::tr ("IF parameters are not supported currently")));
warn (tl::to_string (tr ("IF parameters are not supported currently")));
}
}

View File

@ -1,8 +1,10 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -1,5 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = lay_plugin
!equals(HAVE_QT, "0") {
SUBDIRS = lay_plugin
}

View File

@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = lay_plugin
!equals(HAVE_QT, "0") {
SUBDIRS = lay_plugin
}

View File

@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = lay_plugin
!equals(HAVE_QT, "0") {
SUBDIRS = lay_plugin
}

View File

@ -841,14 +841,14 @@ NetTracer::trace (const db::Layout &layout, const db::Cell &cell, const NetTrace
try {
tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Tracing Net")), 1);
progress.set_format (tl::to_string (QObject::tr ("%.0f shapes")));
tl::AbsoluteProgress progress (tl::to_string (tr ("Tracing Net")), 1);
progress.set_format (tl::to_string (tr ("%.0f shapes")));
progress.set_unit (100);
progress.set_format_unit (1);
mp_progress = &progress;
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Net Tracing")));
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Net Tracing")));
m_stop_shape = stop;
m_start_shape = start;
@ -1062,8 +1062,8 @@ NetTracer::trace (const db::Layout &layout, const db::Cell &cell, const NetTrace
if (m_stop_shape.is_valid ()) {
tl::AbsoluteProgress search_progress (tl::to_string (QObject::tr ("Finding Path")), 100);
search_progress.set_format (tl::to_string (QObject::tr ("Iteration %.0f00")));
tl::AbsoluteProgress search_progress (tl::to_string (tr ("Finding Path")), 100);
search_progress.set_format (tl::to_string (tr ("Iteration %.0f00")));
search_progress.set_unit (100);
const NetTracerShape *stop = &m_shapes_graph.find (m_stop_shape)->first;
@ -1127,7 +1127,7 @@ NetTracer::trace (const db::Layout &layout, const db::Cell &cell, const NetTrace
m_shapes_found.clear ();
if (! found) {
throw tl::Exception (tl::to_string (QObject::tr ("Nets are not connected")));
throw tl::Exception (tl::to_string (tr ("Nets are not connected")));
}
const NetTracerShape *s = start;

View File

@ -185,7 +185,7 @@ NetTracerLayerExpressionInfo::get_expr (const db::LayerProperties &lp, const db:
if (s->symbol ().log_equal (lp)) {
std::set<std::string> us = used_symbols;
if (! us.insert (s->symbol ().to_string ()).second) {
throw tl::Exception (tl::to_string (QObject::tr ("Recursive expression through symbol %s")), s->symbol ());
throw tl::Exception (tl::to_string (tr ("Recursive expression through symbol %s")), s->symbol ());
}
return NetTracerLayerExpressionInfo::compile (s->expression ()).get (layout, tech, us);
}
@ -486,13 +486,13 @@ Net::define_layer (unsigned int l, const db::LayerProperties &lp, const db::Laye
// NetTracerTechnologyComponent implementation
NetTracerTechnologyComponent::NetTracerTechnologyComponent ()
: db::TechnologyComponent (net_tracer_component_name, tl::to_string (QObject::tr ("Connectivity")))
: db::TechnologyComponent (net_tracer_component_name, tl::to_string (tr ("Connectivity")))
{
// .. nothing yet ..
}
NetTracerTechnologyComponent::NetTracerTechnologyComponent (const NetTracerTechnologyComponent &d)
: db::TechnologyComponent (net_tracer_component_name, tl::to_string (QObject::tr ("Connectivity")))
: db::TechnologyComponent (net_tracer_component_name, tl::to_string (tr ("Connectivity")))
{
m_connections = d.m_connections;
m_symbols = d.m_symbols;
@ -505,25 +505,25 @@ NetTracerTechnologyComponent::get_tracer_data (const db::Layout &layout) const
int n = 1;
for (NetTracerTechnologyComponent::const_iterator c = begin (); c != end (); ++c, ++n) {
if (c->layer_a ().to_string ().empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Missing first layer specification on connectivity specification #%d")), n);
throw tl::Exception (tl::to_string (tr ("Missing first layer specification on connectivity specification #%d")), n);
}
if (c->layer_b ().to_string ().empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Missing second layer specification on connectivity specification #%d")), n);
throw tl::Exception (tl::to_string (tr ("Missing second layer specification on connectivity specification #%d")), n);
}
}
n = 1;
for (NetTracerTechnologyComponent::const_symbol_iterator s = begin_symbols (); s != end_symbols (); ++s, ++n) {
if (s->symbol ().to_string ().empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Missing symbol name on symbol specification #%d")), n);
throw tl::Exception (tl::to_string (tr ("Missing symbol name on symbol specification #%d")), n);
}
if (s->expression ().empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Missing expression on symbol specification #%d")), n);
throw tl::Exception (tl::to_string (tr ("Missing expression on symbol specification #%d")), n);
}
try {
std::auto_ptr<NetTracerLayerExpression> expr_in (NetTracerLayerExpressionInfo::compile (s->expression ()).get (layout, *this));
} catch (tl::Exception &ex) {
throw tl::Exception (tl::to_string (QObject::tr ("Error compiling expression '%s' (symbol #%d): %s")), s->expression (), n, ex.msg ());
throw tl::Exception (tl::to_string (tr ("Error compiling expression '%s' (symbol #%d): %s")), s->expression (), n, ex.msg ());
}
}

View File

@ -28,7 +28,9 @@
#include "dbLayerProperties.h"
#include "dbTechnology.h"
#include <QColor>
#if defined(HAVE_QT)
# include <QColor>
#endif
namespace db
{
@ -192,6 +194,7 @@ public:
return m_net_shapes.size ();
}
#if defined(HAVE_QT)
/**
* @brief Gets the color in which the net is drawn
*/
@ -207,6 +210,7 @@ public:
{
m_color = c;
}
#endif
/**
* @brief Get a name for the net
@ -349,7 +353,9 @@ private:
db::Shapes m_shapes;
std::map <unsigned int, std::pair <db::LayerProperties, db::LayerProperties> > m_layers;
std::map <unsigned int, std::string> m_cell_names;
#if defined(HAVE_QT)
QColor m_color;
#endif
db::DBox m_start_search_box, m_stop_search_box;
bool m_trace_path;

View File

@ -1,8 +1,11 @@
TEMPLATE = subdirs
SUBDIRS = db_plugin lay_plugin unit_tests
lay_plugin.depends += db_plugin
SUBDIRS = db_plugin unit_tests
unit_tests.depends += db_plugin
!equals(HAVE_QT, "0") {
SUBDIRS += lay_plugin
lay_plugin.depends += db_plugin
}

View File

@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = lay_plugin
!equals(HAVE_QT, "0") {
SUBDIRS = lay_plugin
}

View File

@ -37,9 +37,7 @@
#include "tlLog.h"
#include "tlStream.h"
#include "tlTimer.h"
#include <QCoreApplication>
#include <QDir>
#include "tlFileUtils.h"
namespace pya
{
@ -168,7 +166,10 @@ PythonInterpreter::PythonInterpreter ()
{
tl::SelfTimer timer (tl::verbosity () >= 21, "Initializing Python");
std::string app_path = tl::to_string (QCoreApplication::applicationFilePath ());
std::string app_path;
#if defined(HAVE_QT)
app_path = tl::to_string (QCoreApplication::applicationFilePath ());
#endif
#if PY_MAJOR_VERSION >= 3
@ -196,7 +197,7 @@ PythonInterpreter::PythonInterpreter ()
QFileInfo fi (inst_dir.absoluteFilePath (tl::to_qstring(".python-paths.txt")));
if (fi.exists ()) {
tl::log << tl::to_string (QObject::tr ("Reading Python path from ")) << tl::to_string (fi.filePath ());
tl::log << tl::to_string (tr ("Reading Python path from ")) << tl::to_string (fi.filePath ());
QFile paths_txt (fi.filePath ());
paths_txt.open (QIODevice::ReadOnly);
@ -223,9 +224,9 @@ PythonInterpreter::PythonInterpreter ()
Py_SetPath ((const wchar_t *) path.utf16 ());
} catch (tl::Exception &ex) {
tl::error << tl::to_string (QObject::tr ("Evaluation of Python path expression failed")) << ": " << ex.msg ();
tl::error << tl::to_string (tr ("Evaluation of Python path expression failed")) << ": " << ex.msg ();
} catch (...) {
tl::error << tl::to_string (QObject::tr ("Evaluation of Python path expression failed"));
tl::error << tl::to_string (tr ("Evaluation of Python path expression failed"));
}
}
@ -350,8 +351,8 @@ PythonInterpreter::add_path (const std::string &p)
void
PythonInterpreter::add_package_location (const std::string &package_path)
{
std::string path = tl::to_string (QDir (tl::to_qstring (package_path)).absoluteFilePath (QString::fromUtf8 ("python")));
if (QDir (tl::to_qstring (path)).exists () && m_package_paths.find (path) == m_package_paths.end ()) {
std::string path = tl::combine_path (tl::absolute_file_path (package_path), "python");
if (tl::file_exists (path) && m_package_paths.find (path) == m_package_paths.end ()) {
m_package_paths.insert (path);
add_path (path);
}
@ -367,7 +368,7 @@ void
PythonInterpreter::require (const std::string & /*filename*/)
{
// TOOD: is there a way to implement that?
throw tl::Exception (tl::to_string (QObject::tr ("'require' not implemented for Python interpreter")));
throw tl::Exception (tl::to_string (tr ("'require' not implemented for Python interpreter")));
}
void

View File

@ -52,7 +52,7 @@ long python2c_func<long>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return (long) (PyFloat_AsDouble (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to an integer")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to an integer")));
}
}
@ -75,7 +75,7 @@ char python2c_func<char>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return char (PyFloat_AsDouble (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to a character")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to a character")));
}
}
@ -92,7 +92,7 @@ unsigned long python2c_func<unsigned long>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return (unsigned long) (PyFloat_AsDouble (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to an integer")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to an integer")));
}
}
@ -109,7 +109,7 @@ long long python2c_func<long long>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return (long long) (PyFloat_AsDouble (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to an integer")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to an integer")));
}
}
@ -126,7 +126,7 @@ unsigned long long python2c_func<unsigned long long>::operator() (PyObject *rval
} else if (PyFloat_Check (rval)) {
return (unsigned long long) (PyFloat_AsDouble (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to an integer")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to an integer")));
}
}
@ -145,7 +145,7 @@ __int128 python2c_func<__int128>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return PyFloat_AsDouble (rval);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to an integer")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to an integer")));
}
}
#endif
@ -163,7 +163,7 @@ double python2c_func<double>::operator() (PyObject *rval)
} else if (PyFloat_Check (rval)) {
return PyFloat_AsDouble (rval);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to a floating-point value")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to a floating-point value")));
}
}
@ -188,10 +188,11 @@ std::string python2c_func<std::string>::operator() (PyObject *rval)
} else if (PyByteArray_Check (rval)) {
return std::string (PyByteArray_AsString (rval), PyByteArray_Size (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to a string")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to a string")));
}
}
#if defined(HAVE_QT)
template <>
QByteArray python2c_func<QByteArray>::operator() (PyObject *rval)
{
@ -213,7 +214,7 @@ QByteArray python2c_func<QByteArray>::operator() (PyObject *rval)
} else if (PyByteArray_Check (rval)) {
return QByteArray (PyByteArray_AsString (rval), PyByteArray_Size (rval));
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Argument cannot be converted to a byte array")));
throw tl::Exception (tl::to_string (tr ("Argument cannot be converted to a byte array")));
}
}
@ -223,6 +224,7 @@ QString python2c_func<QString>::operator() (PyObject *rval)
// TODO: directly convert Unicode strings to QString if possible
return tl::to_qstring (python2c<std::string> (rval));
}
#endif
template <>
tl::Variant python2c_func<tl::Variant>::operator() (PyObject *rval)
@ -531,6 +533,7 @@ PyObject *c2python_func<const char *>::operator() (const char *p)
#endif
}
#if defined(HAVE_QT)
template <>
PyObject *c2python_func<const QByteArray &>::operator() (const QByteArray &qba)
{
@ -544,7 +547,9 @@ PyObject *c2python_func<const QByteArray &>::operator() (const QByteArray &qba)
#endif
}
}
#endif
#if defined(HAVE_QT)
template <>
PyObject *c2python_func<const QString &>::operator() (const QString &qs)
{
@ -556,6 +561,7 @@ PyObject *c2python_func<const QString &>::operator() (const QString &qs)
return c2python (c);
}
}
#endif
}

View File

@ -35,8 +35,10 @@
#include "tlHeap.h"
#include <string>
#include <QString>
#include <QByteArray>
#if defined(HAVE_QT)
# include <QString>
# include <QByteArray>
#endif
#include <typeinfo>
@ -183,8 +185,10 @@ struct test_type_func<const char *>
};
template <> struct test_type_func<std::string> : public test_type_func<const char *> { };
#if defined(HAVE_QT)
template <> struct test_type_func<QString> : public test_type_func<const char *> { };
template <> struct test_type_func<QByteArray> : public test_type_func<const char *> { };
#endif
template <>
struct test_type_func<tl::Variant>
@ -329,8 +333,10 @@ template <> PYA_PUBLIC double python2c_func<double>::operator() (PyObject *rval)
template <> struct python2c_func<float> : public python2c_func_cast<float, double> { };
template <> PYA_PUBLIC std::string python2c_func<std::string>::operator() (PyObject *rval);
#if defined(HAVE_QT)
template <> PYA_PUBLIC QByteArray python2c_func<QByteArray>::operator() (PyObject *rval);
template <> PYA_PUBLIC QString python2c_func<QString>::operator() (PyObject *rval);
#endif
template <> struct python2c_func<void *> : public python2c_func_cast<void *, size_t> { };
@ -605,10 +611,13 @@ struct c2python_func<float>
template <> PYA_PUBLIC PyObject *c2python_func<const char *>::operator() (const char *);
#if defined(HAVE_QT)
template <> PYA_PUBLIC PyObject *c2python_func<const QString &>::operator() (const QString &c);
template <> struct c2python_func<QString> : public c2python_func<const QString &> { };
template <> PYA_PUBLIC PyObject *c2python_func<const QByteArray &>::operator() (const QByteArray &c);
template <> struct c2python_func<QByteArray> : public c2python_func<const QByteArray &> { };
#endif
template <> PYA_PUBLIC PyObject *c2python_func<const std::string &>::operator() (const std::string &c);
template <> struct c2python_func<std::string> : public c2python_func<const std::string &> { };

View File

@ -158,7 +158,7 @@ pya_static_attribute_descriptor_get (PyObject *self, PyObject * /*obj*/, PyObjec
return (*(attr->getter)) ((PyObject *) attr->type, NULL);
} else {
std::string msg;
msg += tl::to_string (QObject::tr ("Attribute not readable"));
msg += tl::to_string (tr ("Attribute not readable"));
msg += ": ";
msg += attr->type->tp_name;
msg += ".";
@ -186,7 +186,7 @@ pya_static_attribute_descriptor_set (PyObject *self, PyObject * /*obj*/, PyObjec
}
} else {
std::string msg;
msg += tl::to_string (QObject::tr ("Attribute cannot be changed"));
msg += tl::to_string (tr ("Attribute cannot be changed"));
msg += ": ";
msg += attr->type->tp_name;
msg += ".";
@ -448,7 +448,7 @@ pya_signal_add (PyObject *self, PyObject *args)
if (! PyCallable_Check (callable)) {
std::string msg;
msg += tl::to_string (QObject::tr ("Signal's += operator needs a callable object"));
msg += tl::to_string (tr ("Signal's += operator needs a callable object"));
PyErr_SetString (PyExc_AttributeError, msg.c_str ());
return NULL;
}
@ -466,7 +466,7 @@ pya_signal_inplace_add (PyObject *self, PyObject *callable)
{
if (! PyCallable_Check (callable)) {
std::string msg;
msg += tl::to_string (QObject::tr ("Signal's += operator needs a callable object"));
msg += tl::to_string (tr ("Signal's += operator needs a callable object"));
PyErr_SetString (PyExc_AttributeError, msg.c_str ());
return NULL;
}
@ -493,7 +493,7 @@ pya_signal_remove (PyObject *self, PyObject *args)
if (! PyCallable_Check (callable)) {
std::string msg;
msg += tl::to_string (QObject::tr ("Signal's -= operator needs a callable object"));
msg += tl::to_string (tr ("Signal's -= operator needs a callable object"));
PyErr_SetString (PyExc_AttributeError, msg.c_str ());
return NULL;
}
@ -514,7 +514,7 @@ pya_signal_inplace_remove (PyObject *self, PyObject *callable)
{
if (! PyCallable_Check (callable)) {
std::string msg;
msg += tl::to_string (QObject::tr ("Signal's -= operator needs a callable object"));
msg += tl::to_string (tr ("Signal's -= operator needs a callable object"));
PyErr_SetString (PyExc_AttributeError, msg.c_str ());
return NULL;
}
@ -541,7 +541,7 @@ pya_signal_set (PyObject *self, PyObject *args)
if (! PyCallable_Check (callable)) {
std::string msg;
msg += tl::to_string (QObject::tr ("Signal's 'set' method needs a callable object"));
msg += tl::to_string (tr ("Signal's 'set' method needs a callable object"));
PyErr_SetString (PyExc_AttributeError, msg.c_str ());
return NULL;
}

View File

@ -184,7 +184,7 @@ struct get_boxed_value_func
const gsi::ClassBase *bt = gsi::cls_decl <gsi::Value> ();
if (!cls_decl->is_derived_from (bt)) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Passing an object to pointer or reference requires a boxed type (pya.%s)")), bt->name ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Passing an object to pointer or reference requires a boxed type (pya.%s)")), bt->name ()));
}
PYAObjectBase *p = (PYAObjectBase *) arg;
@ -219,7 +219,7 @@ struct writer
if (arg == Py_None || arg == NULL) {
if (atype.is_ref () || atype.is_cref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference type cannot be passed None")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference type cannot be passed None")));
} else if (atype.is_ptr ()) {
aa->write<R *> ((R *)0);
} else if (atype.is_cptr ()) {
@ -234,7 +234,7 @@ struct writer
// references or pointers require a boxed object. Pointers also allow None.
void *vc = boxed_value_ptr (atype.type (), arg, *heap);
if (! vc && atype.is_ref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference or direct type cannot be passed None or an empty boxed value object")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference or direct type cannot be passed None or an empty boxed value object")));
}
aa->write<void *> (vc);
} else if (atype.is_cref ()) {
@ -282,7 +282,7 @@ struct writer<gsi::StringType>
void *vc = 0;
get_boxed_value_func<std::string> () (&vc, arg, heap);
if (! vc && atype.is_ref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
}
// NOTE: by convention we pass the ownership to the receiver for adaptors.
@ -327,7 +327,7 @@ struct writer<gsi::VectorType>
{
if (arg == Py_None || arg == NULL) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed nil")));
} else {
aa->write<void *> ((void *)0);
}
@ -348,7 +348,7 @@ struct writer<gsi::MapType>
{
if (arg == Py_None || arg == NULL) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed nil")));
} else {
aa->write<void *> ((void *)0);
}
@ -372,7 +372,7 @@ struct writer<gsi::ObjectType>
if (arg == Py_None || arg == NULL) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed null")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed null")));
} else {
aa->write<void *> ((void *) 0);
return;
@ -384,7 +384,7 @@ struct writer<gsi::ObjectType>
const gsi::ClassBase *cls_decl = PythonModule::cls_for_type (Py_TYPE (arg));
if (! cls_decl) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), Py_TYPE (arg)->tp_name));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), Py_TYPE (arg)->tp_name));
}
if (cls_decl->is_derived_from (atype.cls ())) {
@ -409,14 +409,14 @@ struct writer<gsi::ObjectType>
aa->write<void *> (new_obj);
} else {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), cls_decl->name ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), cls_decl->name ()));
}
} else {
const gsi::ClassBase *cls_decl = PythonModule::cls_for_type (Py_TYPE (arg));
if (! cls_decl) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), Py_TYPE (arg)->tp_name));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), Py_TYPE (arg)->tp_name));
}
if (cls_decl->is_derived_from (atype.cls ())) {
@ -436,7 +436,7 @@ struct writer<gsi::ObjectType>
aa->write<void *> (atype.cls ()->create_obj_from (cls_decl, p->obj ()));
} else {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), cls_decl->name ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), cls_decl->name ()));
}
}
@ -757,7 +757,7 @@ void PythonBasedVectorAdaptor::push (gsi::SerialArgs &r, tl::Heap &heap)
gsi::do_on_type<reader> () (mp_ainner->type (), &r, &member, (PYAObjectBase *) 0, *mp_ainner, &heap);
PyList_Append (m_array.get (), member.get ());
} else if (PyTuple_Check (m_array.get ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Tuples cannot be modified and cannot be used as out parameters")));
throw tl::Exception (tl::to_string (tr ("Tuples cannot be modified and cannot be used as out parameters")));
}
}

View File

@ -766,7 +766,7 @@ match_method (int mid, PyObject *self, PyObject *args, bool strict)
nargs_s += tl::to_string (*na);
}
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Invalid number of arguments (got %d, expected %s)")), argc, nargs_s));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Invalid number of arguments (got %d, expected %s)")), argc, nargs_s));
}
@ -837,7 +837,7 @@ match_method (int mid, PyObject *self, PyObject *args, bool strict)
if (! strict) {
return 0;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("No overload with matching arguments")));
throw tl::Exception (tl::to_string (tr ("No overload with matching arguments")));
}
}
@ -845,7 +845,7 @@ match_method (int mid, PyObject *self, PyObject *args, bool strict)
if (! strict) {
return 0;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Ambiguous overload variants - multiple method declarations match arguments")));
throw tl::Exception (tl::to_string (tr ("Ambiguous overload variants - multiple method declarations match arguments")));
}
}
@ -866,7 +866,7 @@ object_dup (PyObject *self, PyObject *args)
}
if (! cls_decl_self->can_copy ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No copy constructor provided for class '%s'")), cls_decl_self->name ());
throw tl::Exception (tl::to_string (tr ("No copy constructor provided for class '%s'")), cls_decl_self->name ());
}
PYAObjectBase *new_object = (PYAObjectBase *) Py_TYPE (self)->tp_alloc (Py_TYPE (self), 0);
@ -895,10 +895,10 @@ object_assign (PyObject *self, PyObject *args)
tl_assert (cls_decl_src != 0);
if (cls_decl_src != cls_decl_self) {
throw tl::Exception (tl::to_string (QObject::tr ("Type is not identical on assign")));
throw tl::Exception (tl::to_string (tr ("Type is not identical on assign")));
}
if (! cls_decl_self->can_copy ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No assignment provided for class '%s'")), cls_decl_self->name ());
throw tl::Exception (tl::to_string (tr ("No assignment provided for class '%s'")), cls_decl_self->name ());
}
cls_decl_self->assign (((PYAObjectBase *) self)->obj (), ((PYAObjectBase *) src)->obj ());
@ -1118,7 +1118,7 @@ method_adaptor (int mid, PyObject *self, PyObject *args)
tl::Heap heap;
if (p && p->const_ref () && ! meth->is_const ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot call non-const method on a const reference")));
throw tl::Exception (tl::to_string (tr ("Cannot call non-const method on a const reference")));
}
int argc = args == NULL ? 0 : int (PyTuple_Size (args));
@ -1348,7 +1348,7 @@ property_getter_adaptor (int mid, PyObject *self, PyObject *args)
int argc = args == NULL ? 0 : int (PyTuple_Size (args));
if (argc != 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Property getters must not have an argument")));
throw tl::Exception (tl::to_string (tr ("Property getters must not have an argument")));
}
ret = property_getter_impl (mid, self);
@ -1507,7 +1507,7 @@ property_setter_adaptor (int mid, PyObject *self, PyObject *args)
int argc = args == NULL ? 0 : int (PyTuple_Size (args));
if (argc != 1) {
throw tl::Exception (tl::to_string (QObject::tr ("Property setter needs exactly one argument")));
throw tl::Exception (tl::to_string (tr ("Property setter needs exactly one argument")));
}
PyObject *value = PyTuple_GetItem (args, 0);
@ -1912,7 +1912,7 @@ property_getter_impl (int mid, PyObject *self)
if (mt->begin_getters (mid) != mt->end_getters (mid)) {
meth = *mt->begin_getters (mid);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Internal error: cannot locate getter method")));
throw tl::Exception (tl::to_string (tr ("Internal error: cannot locate getter method")));
}
if (meth->is_signal ()) {
@ -1925,7 +1925,7 @@ property_getter_impl (int mid, PyObject *self)
// getter must not have arguments
if (meth->argsize () > 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Internal error: getters must not have arguments")));
throw tl::Exception (tl::to_string (tr ("Internal error: getters must not have arguments")));
}
void *obj = 0;
@ -1976,7 +1976,7 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
}
if (p && p->const_ref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot call a setter on a const reference")));
throw tl::Exception (tl::to_string (tr ("Cannot call a setter on a const reference")));
}
const MethodTable *mt = MethodTable::method_table_by_class (cls_decl);
@ -1993,7 +1993,7 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
}
if (mt->begin_setters (mid) == mt->end_setters (mid)) {
throw tl::Exception (tl::to_string (QObject::tr ("Internal error: cannot locate setter method")));
throw tl::Exception (tl::to_string (tr ("Internal error: cannot locate setter method")));
}
const gsi::MethodBase *meth = 0;
@ -2019,7 +2019,7 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
// no candidate -> error
if (! meth) {
throw tl::Exception (tl::to_string (QObject::tr ("Internal error: no setter compatible with one argument")));
throw tl::Exception (tl::to_string (tr ("Internal error: no setter compatible with one argument")));
}
// more than one candidate -> refine by checking the arguments
@ -2055,9 +2055,9 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
}
if (! meth) {
throw tl::Exception (tl::to_string (QObject::tr ("No setter overload with matching arguments")));
throw tl::Exception (tl::to_string (tr ("No setter overload with matching arguments")));
} else if (candidates > 1) {
throw tl::Exception (tl::to_string (QObject::tr ("Ambiguous overload variants - multiple setter declarations match arguments")));
throw tl::Exception (tl::to_string (tr ("Ambiguous overload variants - multiple setter declarations match arguments")));
}
void *obj = 0;
@ -2077,7 +2077,7 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
// assigning a signal to a signal works if it applies to the same handler -
// this simplifies the implementation of += and -=.
if (p->signal_handler (meth) != ((PYASignal *) value)->handler.get ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid assignment of signal to signal")));
throw tl::Exception (tl::to_string (tr ("Invalid assignment of signal to signal")));
}
} else if (value == Py_None) {
@ -2086,7 +2086,7 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
p->signal_handler (meth)->clear ();
} else if (! PyCallable_Check (value)) {
throw tl::Exception (tl::to_string (QObject::tr ("A signal needs to be assigned a callable object")));
throw tl::Exception (tl::to_string (tr ("A signal needs to be assigned a callable object")));
} else {
// assigning a callable
@ -2310,13 +2310,13 @@ PythonModule::check (const char *mod_name)
// All child classes must originate from this module or be known already
for (tl::weak_collection<gsi::ClassBase>::const_iterator cc = c->begin_child_classes (); cc != c->end_child_classes (); ++cc) {
if (! PythonClassClientData::py_type (*cc->declaration ()) && cc->module () != mod_name) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Class %s from module %s depends on %s.%s (try 'import %s' before 'import %s')")), c->name (), mod_name, cc->module (), cc->name (), pymod_name + "." + cc->module (), pymod_name + "." + mod_name));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Class %s from module %s depends on %s.%s (try 'import %s' before 'import %s')")), c->name (), mod_name, cc->module (), cc->name (), pymod_name + "." + cc->module (), pymod_name + "." + mod_name));
}
}
// Same for base class
if (c->base () && ! PythonClassClientData::py_type (*c->base ()) && c->base ()->module () != mod_name) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Class %s from module %s depends on %s.%s (try 'import %s' before 'import %s')")), c->name (), mod_name, c->base ()->module (), c->base ()->name (), pymod_name + "." + c->base ()->module (), pymod_name + "." + mod_name));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Class %s from module %s depends on %s.%s (try 'import %s' before 'import %s')")), c->name (), mod_name, c->base ()->module (), c->base ()->name (), pymod_name + "." + c->base ()->module (), pymod_name + "." + mod_name));
}
}
@ -2567,7 +2567,7 @@ PythonModule::make_classes (const char *mod_name)
doc += "\n\n";
}
doc += (*m)->doc ();
m_python_doc [*m] += tl::sprintf (tl::to_string (QObject::tr ("The object exposes a readable attribute '%s'. This is the getter.\n\n")), name);
m_python_doc [*m] += tl::sprintf (tl::to_string (tr ("The object exposes a readable attribute '%s'. This is the getter.\n\n")), name);
}
for (MethodTableEntry::method_iterator m = begin_setters; m != end_setters; ++m) {
@ -2575,7 +2575,7 @@ PythonModule::make_classes (const char *mod_name)
doc += "\n\n";
}
doc += (*m)->doc ();
m_python_doc [*m] += tl::sprintf (tl::to_string (QObject::tr ("The object exposes a writable attribute '%s'. This is the setter.\n\n")), name);
m_python_doc [*m] += tl::sprintf (tl::to_string (tr ("The object exposes a writable attribute '%s'. This is the setter.\n\n")), name);
}
PythonRef attr;
@ -2629,10 +2629,10 @@ PythonModule::make_classes (const char *mod_name)
// drop non-standard names
if (tl::verbosity () >= 20) {
tl::warn << tl::to_string (QObject::tr ("Class ")) << c->name () << ": " << tl::to_string (QObject::tr ("no Python mapping for method ")) << mt->name (mid);
tl::warn << tl::to_string (tr ("Class ")) << c->name () << ": " << tl::to_string (tr ("no Python mapping for method ")) << mt->name (mid);
}
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is not available for Python")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is not available for Python")));
} else {
@ -2659,7 +2659,7 @@ PythonModule::make_classes (const char *mod_name)
// drop non-standard names
if (tl::verbosity () >= 20) {
tl::warn << tl::to_string (QObject::tr ("Class ")) << c->name () << ": " << tl::to_string (QObject::tr ("no Python mapping for method (reserved word) ")) << name;
tl::warn << tl::to_string (tr ("Class ")) << c->name () << ": " << tl::to_string (tr ("no Python mapping for method (reserved word) ")) << name;
}
name += "_";
@ -2667,7 +2667,7 @@ PythonModule::make_classes (const char *mod_name)
}
if (name != raw_name) {
add_python_doc (*c, mt, mid, tl::sprintf (tl::to_string (QObject::tr ("This method is available as method '%s' in Python")), name));
add_python_doc (*c, mt, mid, tl::sprintf (tl::to_string (tr ("This method is available as method '%s' in Python")), name));
}
// create documentation
@ -2691,29 +2691,29 @@ PythonModule::make_classes (const char *mod_name)
// The str method is also routed via the tp_str implementation
alt_names.push_back ("__str__");
if (! has_inspect) {
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is also available as 'str(object)' and 'repr(object)'")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as 'str(object)' and 'repr(object)'")));
alt_names.push_back ("__repr__");
} else {
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is also available as 'str(object)'")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as 'str(object)'")));
}
} else if (name == "inspect" && m_first->compatible_with_num_args (0)) {
// The str method is also routed via the tp_str implementation
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is also available as 'repr(object)'")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as 'repr(object)'")));
alt_names.push_back ("__repr__");
} else if (name == "size" && m_first->compatible_with_num_args (0)) {
// The size method is also routed via the sequence methods protocol if there
// is a [] function
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is also available as 'len(object)'")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as 'len(object)'")));
alt_names.push_back ("__len__");
} else if (name == "each" && m_first->compatible_with_num_args (0) && m_first->ret_type ().is_iter ()) {
// each makes the object iterable
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method enables iteration of the object")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method enables iteration of the object")));
alt_names.push_back ("__iter__");
}
@ -2756,7 +2756,7 @@ PythonModule::make_classes (const char *mod_name)
} else if (tl::verbosity () >= 20) {
tl::warn << "Upper case method name encountered which cannot be used as a Python constant (more than one overload or at least one argument): " << c->name () << "." << name;
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is not available for Python")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is not available for Python")));
}
} else {
@ -2764,7 +2764,7 @@ PythonModule::make_classes (const char *mod_name)
if (m_first->ret_type ().type () == gsi::T_object && m_first->ret_type ().pass_obj () && name == "new") {
// The constructor is also routed via the pya_object_init implementation
add_python_doc (*c, mt, mid, tl::to_string (QObject::tr ("This method is the default initializer of the object")));
add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is the default initializer of the object")));
PyMethodDef *method = make_method_def ();
method->ml_name = "__init__";

View File

@ -160,7 +160,7 @@ Callee::call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
} catch (tl::ExitException &) {
throw;
} catch (tl::Exception &ex) {
throw tl::Exception (tl::to_string (QObject::tr ("Error calling method")) + " '" + mp_obj->cls_decl ()->name () + "." + meth->names () + "': " + ex.msg ());
throw tl::Exception (tl::to_string (tr ("Error calling method")) + " '" + mp_obj->cls_decl ()->name () + "." + meth->names () + "': " + ex.msg ());
} catch (...) {
throw;
}
@ -522,14 +522,14 @@ PYAObjectBase::destroy ()
}
if (!m_can_destroy && m_obj) {
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be destroyed explicitly")));
throw tl::Exception (tl::to_string (tr ("Object cannot be destroyed explicitly")));
}
// first create the object if it was not created yet and check if it has not been
// destroyed already (the former is to ensure that the object is created at least)
if (! m_obj) {
if (m_destroyed) {
throw tl::Exception (tl::to_string (QObject::tr ("Object has been destroyed already")));
throw tl::Exception (tl::to_string (tr ("Object has been destroyed already")));
} else {
m_obj = m_cls_decl->create ();
m_owned = true;
@ -555,7 +555,7 @@ PYAObjectBase::obj ()
{
if (! m_obj) {
if (m_destroyed) {
throw tl::Exception (tl::to_string (QObject::tr ("Object has been destroyed already")));
throw tl::Exception (tl::to_string (tr ("Object has been destroyed already")));
} else {
// delayed creation of a detached C++ object ..
set(cls_decl ()->create (), true, false, true);

View File

@ -41,14 +41,14 @@ namespace pya
} catch (tl::ExitException &ex) { \
PyErr_SetObject (PyExc_SystemExit, PyLong_FromLong (ex.status ())); \
} catch (std::exception &ex) { \
std::string msg = std::string(ex.what ()) + tl::to_string (QObject::tr (" in ")) + (where); \
std::string msg = std::string(ex.what ()) + tl::to_string (tr (" in ")) + (where); \
PyErr_SetString (PyExc_RuntimeError, msg.c_str ()); \
} catch (tl::Exception &ex) { \
std::string msg; \
msg = ex.msg () + tl::to_string (QObject::tr (" in ")) + (where); \
msg = ex.msg () + tl::to_string (tr (" in ")) + (where); \
PyErr_SetString (PyExc_RuntimeError, msg.c_str ()); \
} catch (...) { \
std::string msg = tl::to_string (QObject::tr ("Unspecific exception in ")) + (where); \
std::string msg = tl::to_string (tr ("Unspecific exception in ")) + (where); \
PyErr_SetString (PyExc_RuntimeError, msg.c_str ()); \
} \
}
@ -61,7 +61,7 @@ namespace pya
} catch (tl::Exception &ex) { \
PyErr_SetString (PyExc_RuntimeError, ex.msg ().c_str ()); \
} catch (...) { \
PyErr_SetString (PyExc_RuntimeError, tl::to_string (QObject::tr ("Unspecific exception in ")).c_str ()); \
PyErr_SetString (PyExc_RuntimeError, tl::to_string (tr ("Unspecific exception in ")).c_str ()); \
} \
}

View File

@ -4,34 +4,38 @@ SUBDIRS = \
db \
tl \
rdb \
lay \
equals(HAVE_QTBINDINGS, "1") {
equals(HAVE_QT5, "1") {
!equals(HAVE_QT, "0") {
SUBDIRS += \
QtCore \
QtGui \
QtNetwork \
QtSql \
QtWidgets \
QtDesigner \
QtMultimedia \
QtPrintSupport \
QtSvg \
QtXmlPatterns \
QtXml
SUBDIRS += lay
} else {
equals(HAVE_QTBINDINGS, "1") {
equals(HAVE_QT5, "1") {
SUBDIRS += \
QtCore \
QtGui \
QtXml \
QtSql \
QtNetwork \
QtDesigner
SUBDIRS += \
QtCore \
QtGui \
QtNetwork \
QtSql \
QtWidgets \
QtDesigner \
QtMultimedia \
QtPrintSupport \
QtSvg \
QtXmlPatterns \
QtXml
} else {
SUBDIRS += \
QtCore \
QtGui \
QtXml \
QtSql \
QtNetwork \
QtDesigner
}
}
}

View File

@ -33,6 +33,7 @@
#include "tlLog.h"
#include "tlTimer.h"
#include "tlExpression.h"
#include "tlFileUtils.h"
#include "rba.h"
#include "rbaInspector.h"
@ -48,12 +49,6 @@
#include <cctype>
#include <algorithm>
#include <QString>
#include <QByteArray>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#if !defined(HAVE_RUBY_VERSION_CODE)
# define HAVE_RUBY_VERSION_CODE 10901
#endif
@ -311,7 +306,7 @@ private:
break;
} else {
throw tl::Exception (tl::to_string (QObject::tr ("An event needs a block")));
throw tl::Exception (tl::to_string (tr ("An event needs a block")));
}
} else if ((*m)->is_callback()) {
@ -350,7 +345,7 @@ private:
nargs_s += tl::to_string (*na);
}
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Invalid number of arguments (got %d, expected %s)")), argc, nargs_s));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Invalid number of arguments (got %d, expected %s)")), argc, nargs_s));
}
@ -418,15 +413,15 @@ private:
}
if (! meth) {
throw tl::Exception (tl::to_string (QObject::tr ("No overload with matching arguments")));
throw tl::Exception (tl::to_string (tr ("No overload with matching arguments")));
}
if (candidates > 1) {
throw tl::Exception (tl::to_string (QObject::tr ("Ambiguous overload variants - multiple method declarations match arguments")));
throw tl::Exception (tl::to_string (tr ("Ambiguous overload variants - multiple method declarations match arguments")));
}
if (is_const && ! meth->is_const ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot call non-const method on a const reference")));
throw tl::Exception (tl::to_string (tr ("Cannot call non-const method on a const reference")));
}
return meth;
@ -670,20 +665,20 @@ struct RubyInterpreterPrivateData
#define RBA_CATCH(where) \
} catch (std::exception &ex) { \
__eclass = rb_eRuntimeError; \
__error_msg = rb_str_new2 ((std::string(ex.what ()) + tl::to_string (QObject::tr (" in ")) + (where)).c_str ()); \
__error_msg = rb_str_new2 ((std::string(ex.what ()) + tl::to_string (tr (" in ")) + (where)).c_str ()); \
} catch (tl::ExitException &ex) { \
__estatus = ex.status (); \
__eclass = rb_eSystemExit; \
__error_msg = rb_str_new2 ((ex.msg () + tl::to_string (QObject::tr (" in ")) + (where)).c_str ()); \
__error_msg = rb_str_new2 ((ex.msg () + tl::to_string (tr (" in ")) + (where)).c_str ()); \
} catch (rba::RubyError &ex) { \
__eclass = rb_eRuntimeError; \
__exc = ex.exc (); \
} catch (tl::Exception &ex) { \
__eclass = rb_eRuntimeError; \
__error_msg = rb_str_new2 ((ex.msg () + tl::to_string (QObject::tr (" in ")) + (where)).c_str ()); \
__error_msg = rb_str_new2 ((ex.msg () + tl::to_string (tr (" in ")) + (where)).c_str ()); \
} catch (...) { \
__eclass = rb_eRuntimeError; \
__error_msg = rb_str_new2 ((tl::to_string (QObject::tr ("Unspecific exception in ")) + (where)).c_str ()); \
__error_msg = rb_str_new2 ((tl::to_string (tr ("Unspecific exception in ")) + (where)).c_str ()); \
} \
} \
if (__exc != Qnil) { \
@ -777,10 +772,10 @@ assign (VALUE self, VALUE src)
void *obj_self = p->obj ();
if (cls_decl_src != cls_decl_self) {
throw tl::Exception (tl::to_string (QObject::tr ("Type is not identical on copy")));
throw tl::Exception (tl::to_string (tr ("Type is not identical on copy")));
}
if (! cls_decl_self->can_copy ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No assignment provided for class '%s'")), cls_decl_self->name ());
throw tl::Exception (tl::to_string (tr ("No assignment provided for class '%s'")), cls_decl_self->name ());
}
cls_decl_self->assign (obj_self, obj_src);
@ -1823,7 +1818,7 @@ RubyInterpreter::initialize (int &main_argc, char **main_argv, int (*main_func)
QFileInfo fi (inst_dir.absoluteFilePath (tl::to_qstring(".ruby-paths.txt")));
if (fi.exists ()) {
tl::log << tl::to_string (QObject::tr ("Reading Ruby path from ")) << tl::to_string (fi.filePath ());
tl::log << tl::to_string (tr ("Reading Ruby path from ")) << tl::to_string (fi.filePath ());
QFile paths_txt (fi.filePath ());
paths_txt.open (QIODevice::ReadOnly);
@ -1845,9 +1840,9 @@ RubyInterpreter::initialize (int &main_argc, char **main_argv, int (*main_func)
}
} catch (tl::Exception &ex) {
tl::error << tl::to_string (QObject::tr ("Evaluation of Ruby path expression failed")) << ": " << ex.msg ();
tl::error << tl::to_string (tr ("Evaluation of Ruby path expression failed")) << ": " << ex.msg ();
} catch (...) {
tl::error << tl::to_string (QObject::tr ("Evaluation of Ruby path expression failed"));
tl::error << tl::to_string (tr ("Evaluation of Ruby path expression failed"));
}
#endif
@ -1915,8 +1910,8 @@ RubyInterpreter::ignore_next_exception ()
void
RubyInterpreter::add_package_location (const std::string &package_path)
{
std::string path = tl::to_string (QDir (tl::to_qstring (package_path)).absoluteFilePath (QString::fromUtf8 ("ruby")));
if (QDir (tl::to_qstring (path)).exists () && d->package_paths.find (path) == d->package_paths.end ()) {
std::string path = tl::combine_path (tl::absolute_file_path (package_path), "ruby");
if (tl::file_exists (path) && d->package_paths.find (path) == d->package_paths.end ()) {
d->package_paths.insert (path);
add_path (path);
}
@ -2297,7 +2292,7 @@ namespace rba
static void fail (const char *file, int line)
{
throw tl::ScriptError (tl::to_string (QObject::tr ("Ruby support not compiled in")).c_str (), file, line, "missing_feature", std::vector<tl::BacktraceElement> ());
throw tl::ScriptError (tl::to_string (tr ("Ruby support not compiled in")).c_str (), file, line, "missing_feature", std::vector<tl::BacktraceElement> ());
}
RubyInterpreter::RubyInterpreter ()

View File

@ -313,6 +313,7 @@ inline std::string ruby2c<std::string> (VALUE rval)
return std::string (RSTRING_PTR(str), RSTRING_LEN(str));
}
#if defined(HAVE_QT)
template <>
inline QByteArray ruby2c<QByteArray> (VALUE rval)
{
@ -326,6 +327,7 @@ inline QString ruby2c<QString> (VALUE rval)
VALUE str = rba_safe_string_value (rval);
return tl::to_qstring (std::string (RSTRING_PTR(str), RSTRING_LEN(str)));
}
#endif
template <>
inline void *ruby2c<void *> (VALUE rval)
@ -448,6 +450,7 @@ inline VALUE c2ruby<std::string> (const std::string &c)
return rb_str_new (c.c_str (), c.size ());
}
#if defined(HAVE_QT)
template <>
inline VALUE c2ruby<QByteArray> (const QByteArray &qba)
{
@ -468,6 +471,7 @@ inline VALUE c2ruby<QString> (const QString &qs)
return rb_str_new (c.c_str (), c.size ());
}
}
#endif
template <>
inline VALUE c2ruby<void *> (void * const &s)

View File

@ -345,7 +345,7 @@ Proxy::call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
} catch (tl::ExitException & /*ex*/) {
throw;
} catch (tl::Exception &ex) {
throw tl::Exception (tl::to_string (QObject::tr ("Error calling method")) + " '" + m_cls_decl->name () + "::" + meth->names () + "': " + ex.msg ());
throw tl::Exception (tl::to_string (tr ("Error calling method")) + " '" + m_cls_decl->name () + "::" + meth->names () + "': " + ex.msg ());
} catch (...) {
throw;
}
@ -360,14 +360,14 @@ Proxy::destroy ()
}
if (!m_can_destroy && m_obj) {
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be destroyed explicitly")));
throw tl::Exception (tl::to_string (tr ("Object cannot be destroyed explicitly")));
}
// first create the object if it was not created yet and check if it has not been
// destroyed already (the former is to ensure that the object is created at least)
if (! m_obj) {
if (m_destroyed) {
throw tl::Exception (tl::to_string (QObject::tr ("Object has been destroyed already")));
throw tl::Exception (tl::to_string (tr ("Object has been destroyed already")));
} else {
m_obj = m_cls_decl->create ();
m_owned = true;
@ -676,12 +676,12 @@ Proxy::obj ()
{
if (! m_obj) {
if (m_destroyed) {
throw tl::Exception (tl::to_string (QObject::tr ("Object has been destroyed already")));
throw tl::Exception (tl::to_string (tr ("Object has been destroyed already")));
} else if (cls_decl ()->can_default_create()) {
// delayed creation of a detached C++ object ..
set (cls_decl ()->create (), true, false, true, m_self);
} else {
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be default-created (missing arguments to 'new'?)")));
throw tl::Exception (tl::to_string (tr ("Object cannot be default-created (missing arguments to 'new'?)")));
}
}
@ -811,7 +811,7 @@ SignalHandler::static_assign (VALUE self, VALUE proc)
if (proc != self) {
if (TYPE (proc) != T_DATA || rb_obj_is_kind_of (proc, rb_cProc) != Qtrue) {
std::string msg = tl::to_string (QObject::tr ("Single argument to signal must be a Proc object"));
std::string msg = tl::to_string (tr ("Single argument to signal must be a Proc object"));
VALUE args [1];
args [0] = rb_str_new2 (msg.c_str ());
rb_exc_raise (rb_class_new_instance(1, args, rb_eRuntimeError));
@ -832,7 +832,7 @@ VALUE
SignalHandler::static_add (VALUE self, VALUE proc)
{
if (TYPE (proc) != T_DATA || rb_obj_is_kind_of (proc, rb_cProc) != Qtrue) {
std::string msg = tl::to_string (QObject::tr ("Single argument to signal's add method must be a Proc object"));
std::string msg = tl::to_string (tr ("Single argument to signal's add method must be a Proc object"));
VALUE args [1];
args [0] = rb_str_new2 (msg.c_str ());
rb_exc_raise (rb_class_new_instance(1, args, rb_eRuntimeError));

View File

@ -192,7 +192,7 @@ struct get_boxed_value_func
Proxy *p = 0;
Data_Get_Struct (arg, Proxy, p);
if (!p->cls_decl ()->is_derived_from (bt)) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Passing an object to pointer or reference requires a boxed type (RBA::%s)")), bt->name ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Passing an object to pointer or reference requires a boxed type (RBA::%s)")), bt->name ()));
}
gsi::Value *bo = reinterpret_cast<gsi::Value *> (p->obj ());
@ -241,7 +241,7 @@ struct writer
if (arg == Qnil) {
if (atype.is_ref () || atype.is_cref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference type cannot be passed nil")));
} else if (atype.is_ptr ()) {
aa->write<R *> ((R *)0);
} else if (atype.is_cptr ()) {
@ -256,7 +256,7 @@ struct writer
// references or pointers require a boxed object. Pointers also allow nil.
void *vc = boxed_value_ptr (atype.type (), arg, *heap);
if (! vc && atype.is_ref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
}
aa->write<void *> (vc);
} else if (atype.is_cref ()) {
@ -300,7 +300,7 @@ struct writer<gsi::StringType>
void *vc = 0;
get_boxed_value_func<std::string> () (&vc, arg, heap);
if (! vc && atype.is_ref ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
throw tl::Exception (tl::to_string (tr ("Arguments or return values of reference or direct type cannot be passed nil or an empty boxed value object")));
}
// NOTE: by convention we pass the ownership to the receiver for adaptors.
@ -345,7 +345,7 @@ struct writer<gsi::VectorType>
{
if (arg == Qnil) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed nil")));
} else {
aa->write<void *> ((void *)0);
}
@ -366,7 +366,7 @@ struct writer<gsi::MapType>
{
if (arg == Qnil) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed nil")));
} else {
aa->write<void *> ((void *)0);
}
@ -389,7 +389,7 @@ struct writer <gsi::ObjectType>
if (arg == Qnil) {
if (! (atype.is_ptr () || atype.is_cptr ())) {
throw tl::Exception (tl::to_string (QObject::tr ("Arguments of reference or direct type cannot be passed nil")));
throw tl::Exception (tl::to_string (tr ("Arguments of reference or direct type cannot be passed nil")));
} else {
aa->write<void *> ((void *) 0);
}
@ -397,7 +397,7 @@ struct writer <gsi::ObjectType>
} else {
if (TYPE (arg) != T_DATA) {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
}
Proxy *p = 0;
@ -423,7 +423,7 @@ struct writer <gsi::ObjectType>
aa->write<void *> (new_obj);
} else {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
}
} else {
@ -442,7 +442,7 @@ struct writer <gsi::ObjectType>
aa->write<void *> (atype.cls ()->create_obj_from (p->cls_decl (), p->obj ()));
} else {
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s, got %s)")), atype.cls ()->name (), rba_class_name (arg).c_str ()));
}
}

View File

@ -15,6 +15,10 @@ equals(HAVE_CURL, "1") {
}
}
equals(HAVE_EXPAT, "1") {
LIBS += -lexpat
}
FORMS =
SOURCES = \

View File

@ -441,6 +441,18 @@ static std::pair<std::string, bool> absolute_path_of_existing (const std::string
#endif
}
bool is_absolute (const std::string &s)
{
std::vector<std::string> parts = split_path (s);
if (parts.size () > 1 && is_drive (parts [0])) {
return is_part_with_separator (parts [1]);
} else if (! parts.empty ()) {
return is_part_with_separator (parts.front ());
} else {
return false;
}
}
std::string absolute_file_path (const std::string &s)
{
std::vector<std::string> parts = split_path (s);
@ -562,6 +574,32 @@ bool is_dir (const std::string &p)
}
}
std::string relative_path (const std::string &base, const std::string &p)
{
std::vector<std::string> rem;
std::vector<std::string> parts = split_path (p);
while (! parts.empty ()) {
if (is_same_file (base, tl::join (parts, ""))) {
// combine the remaining path
std::reverse (rem.begin (), rem.end ());
if (! rem.empty ()) {
rem[0] = tl::trimmed_part (rem.front ());
}
return tl::join (rem, "");
}
rem.push_back (parts.back ());
parts.pop_back ();
}
return p;
}
std::string combine_path (const std::string &p1, const std::string &p2)
{
#if defined(_WIN32)

View File

@ -34,6 +34,11 @@ namespace tl
*/
bool TL_PUBLIC is_parent_path (const std::string &parent, const std::string &path);
/**
* @brief Returns true if s is an absolute path
*/
bool TL_PUBLIC is_absolute (const std::string &s);
/**
* @brief Recursively remove the given directory, the files from that directory and all sub-directories (version with std::string)
* @return True, if successful. false otherwise.
@ -120,6 +125,12 @@ bool TL_PUBLIC rm_dir (const std::string &path);
*/
bool TL_PUBLIC is_same_file (const std::string &a, const std::string &b);
/**
* @brief Gets the relative path of p vs. base
* If p cannot be resolved relative to base, p is returned.
*/
std::string TL_PUBLIC relative_path (const std::string &base, const std::string &p);
/**
* @brief Combines the two path components into one path
*/

View File

@ -100,13 +100,17 @@ void initialize_codecs ()
std::string system_to_string (const std::string &s)
{
// TODO: this fallback implementation assumes the system encoding is UTF-8
return s;
return tl::to_string_from_local (s.c_str ());
}
std::string string_to_system (const std::string &s)
{
// TODO: this fallback implementation assumes the system encoding is UTF-8
return tl::to_local (s);
}
std::string tr (const char *s)
{
// TODO: this is a fallback implementation without translation
return std::string (s);
}

View File

@ -30,7 +30,7 @@
#if defined(HAVE_QT)
# include <QString>
// provides QObject for QObject::tr
// provides QObject for tr
# include <QObject>
#endif
@ -38,12 +38,12 @@
* @brief Generic tr function for non-Qt and Qt builds
*/
#if defined(HAVE_QT)
QString tr (const char *s)
inline QString tr (const char *s)
{
return QObject::tr (s);
}
#else
std::string tr (const char *s);
std::string TL_PUBLIC tr (const char *s);
#endif
namespace tl