mirror of https://github.com/KLayout/klayout.git
First (major) steps towards a Qt-less basic build.
This commit is contained in:
parent
507189b1d4
commit
239b7ca3ff
|
|
@ -31,14 +31,14 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::Box &b)
|
||||
{
|
||||
if (! test_extractor_impl (ex, b)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an box specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an box specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> void extractor_impl (tl::Extractor &ex, db::DBox &b)
|
||||
{
|
||||
if (! test_extractor_impl (ex, b)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an box specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an box specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ public:
|
|||
std::auto_ptr<tl::RelativeProgress> progress (0);
|
||||
if (m_report_progress) {
|
||||
if (m_progress_desc.empty ()) {
|
||||
progress.reset (new tl::RelativeProgress (tl::to_string (QObject::tr ("Processing")), m_pp.size (), 1000));
|
||||
progress.reset (new tl::RelativeProgress (tl::to_string (tr ("Processing")), m_pp.size (), 1000));
|
||||
} else {
|
||||
progress.reset (new tl::RelativeProgress (m_progress_desc, m_pp.size (), 1000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ CellMapping::create_missing_mapping (db::Layout &layout_a, db::cell_index_type /
|
|||
void
|
||||
CellMapping::create_from_geometry (const db::Layout &layout_a, db::cell_index_type cell_index_a, const db::Layout &layout_b, db::cell_index_type cell_index_b)
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Cell mapping")));
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Cell mapping")));
|
||||
|
||||
if (tl::verbosity () >= 20) {
|
||||
tl::info << "Cell mapping - first step: mapping instance count and instance identity";
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_XML)
|
||||
virtual tl::XMLElementBase *xml_reader_options_element () const
|
||||
{
|
||||
return new db::ReaderOptionsXMLElement<db::CommonReaderOptions> ("common",
|
||||
|
|
@ -83,6 +84,7 @@ public:
|
|||
tl::make_member (&db::CommonReaderOptions::enable_text_objects, "enable-text-objects")
|
||||
);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
static tl::RegisteredClass<db::StreamFormatDeclaration> reader_decl (new CommonFormatDeclaration (), 20, "Common");
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::Edge &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> void extractor_impl (tl::Extractor &ex, db::DEdge &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::EdgePair &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> void extractor_impl (tl::Extractor &ex, db::DEdgePair &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ namespace tl
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::EdgePairs &b)
|
||||
{
|
||||
if (! test_extractor_impl (ex, b)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge pair collection specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge pair collection specification")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1580,11 +1580,11 @@ EdgeProcessor::process (db::EdgeSink &es, EdgeEvaluatorBase &op)
|
|||
std::auto_ptr<tl::AbsoluteProgress> progress (0);
|
||||
if (m_report_progress) {
|
||||
if (m_progress_desc.empty ()) {
|
||||
progress.reset (new tl::AbsoluteProgress (tl::to_string (QObject::tr ("Processing")), 1000));
|
||||
progress.reset (new tl::AbsoluteProgress (tl::to_string (tr ("Processing")), 1000));
|
||||
} else {
|
||||
progress.reset (new tl::AbsoluteProgress (m_progress_desc, 1000));
|
||||
}
|
||||
progress->set_format (tl::to_string (QObject::tr ("%.0f%%")));
|
||||
progress->set_format (tl::to_string (tr ("%.0f%%")));
|
||||
progress->set_unit (todo_max / 100);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1362,7 +1362,7 @@ namespace tl
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Edges &b)
|
||||
{
|
||||
if (! test_extractor_impl (ex, b)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an edge collection specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an edge collection specification")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ static void collect_cell_signatures (const db::Layout &layout, const std::vector
|
|||
void
|
||||
FuzzyCellMapping::create (const db::Layout &layout_a, db::cell_index_type cell_index_a, const db::Layout &layout_b, db::cell_index_type cell_index_b)
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Cell mapping")));
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Cell mapping")));
|
||||
|
||||
if (tl::verbosity () >= 20) {
|
||||
tl::info << "Cell mapping";
|
||||
|
|
@ -321,16 +321,16 @@ FuzzyCellMapping::create (const db::Layout &layout_a, db::cell_index_type cell_i
|
|||
}
|
||||
|
||||
std::map <db::cell_index_type, CellSignature> ma;
|
||||
collect_cell_signatures (layout_a, la, cell_index_a, ma, tl::to_string (QObject::tr ("Collecting cell signatures (A)")));
|
||||
collect_cell_signatures (layout_a, la, cell_index_a, ma, tl::to_string (tr ("Collecting cell signatures (A)")));
|
||||
|
||||
if (tl::verbosity () >= 40) {
|
||||
tl::info << "Signatures (b):";
|
||||
}
|
||||
|
||||
std::map <db::cell_index_type, CellSignature> mb;
|
||||
collect_cell_signatures (layout_b, lb, cell_index_b, mb, tl::to_string (QObject::tr ("Collecting cell signatures (B)")));
|
||||
collect_cell_signatures (layout_b, lb, cell_index_b, mb, tl::to_string (tr ("Collecting cell signatures (B)")));
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Finding matching cells")), ma.size () * ma.size ());
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Finding matching cells")), ma.size () * ma.size ());
|
||||
|
||||
for (std::map <db::cell_index_type, CellSignature>::const_iterator m = ma.begin (); m != ma.end (); ++m) {
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ TextGenerator::load_from_resource (const std::string &name)
|
|||
{
|
||||
QResource res (tl::to_qstring (name));
|
||||
if (res.size () == 0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to load font resource from ")) + name);
|
||||
throw tl::Exception (tl::to_string (tr ("Unable to load font resource from ")) + name);
|
||||
}
|
||||
|
||||
QByteArray data = qUncompress (QByteArray ((const char *) res.data (), int (res.size ())));
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ std::vector<std::string>
|
|||
hershey_font_names ()
|
||||
{
|
||||
std::vector<std::string> ff;
|
||||
ff.push_back (tl::to_string (QObject::tr ("Default")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Gothic")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Sans Serif")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Stick")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Times Italic")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Times Thin")));
|
||||
ff.push_back (tl::to_string (QObject::tr ("Times")));
|
||||
ff.push_back (tl::to_string (tr ("Default")));
|
||||
ff.push_back (tl::to_string (tr ("Gothic")));
|
||||
ff.push_back (tl::to_string (tr ("Sans Serif")));
|
||||
ff.push_back (tl::to_string (tr ("Stick")));
|
||||
ff.push_back (tl::to_string (tr ("Times Italic")));
|
||||
ff.push_back (tl::to_string (tr ("Times Thin")));
|
||||
ff.push_back (tl::to_string (tr ("Times")));
|
||||
return ff;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ static PluginDescriptor load_plugin (const std::string &pp)
|
|||
// there is no "dlopen" on mingw, so we need to emulate it.
|
||||
HINSTANCE handle = LoadLibraryW ((const wchar_t *) tl::to_qstring (pp).constData ());
|
||||
if (! handle) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin: %s with error message: %s ")), pp, GetLastError ());
|
||||
throw tl::Exception (tl::to_string (tr ("Unable to load plugin: %s with error message: %s ")), pp, GetLastError ());
|
||||
return desc;
|
||||
}
|
||||
init_func = reinterpret_cast<dbp_init_func_t> (GetProcAddress (handle, init_func_name));
|
||||
|
|
@ -71,7 +71,7 @@ static PluginDescriptor load_plugin (const std::string &pp)
|
|||
void *handle;
|
||||
handle = dlopen (tl::string_to_system (pp).c_str (), RTLD_LAZY);
|
||||
if (! handle) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin: %s")), pp);
|
||||
throw tl::Exception (tl::to_string (tr ("Unable to load plugin: %s")), pp);
|
||||
}
|
||||
init_func = reinterpret_cast<dbp_init_func_t> (dlsym (handle, init_func_name));
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ static PluginDescriptor load_plugin (const std::string &pp)
|
|||
}
|
||||
}
|
||||
|
||||
tl::log << tl::sprintf (tl::to_string (QObject::tr ("Loaded plugin: %s")), pp);
|
||||
tl::log << tl::sprintf (tl::to_string (tr ("Loaded plugin: %s")), pp);
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1057,7 +1057,7 @@ Instances::instance_type
|
|||
Instances::replace (const instance_type &ref, const cell_inst_wp_array_type &inst)
|
||||
{
|
||||
if (ref.instances () != this) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
throw tl::Exception (tl::to_string (tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
}
|
||||
|
||||
const cell_inst_wp_array_type *cp = ref.basic_ptr (cell_inst_wp_array_type::tag ());
|
||||
|
|
@ -1080,7 +1080,7 @@ Instances::instance_type
|
|||
Instances::replace (const instance_type &ref, const cell_inst_array_type &inst)
|
||||
{
|
||||
if (ref.instances () != this) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
throw tl::Exception (tl::to_string (tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
}
|
||||
|
||||
const cell_inst_array_type *cp = ref.basic_ptr (cell_inst_array_type::tag ());
|
||||
|
|
@ -1121,7 +1121,7 @@ void
|
|||
Instances::erase_inst_by_iter (Tag tag, ET editable_tag, I iter)
|
||||
{
|
||||
if (iter.vector () != &inst_tree (tag, editable_tag).objects ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Trying to erase an object from a list that it does not belong to")));
|
||||
throw tl::Exception (tl::to_string (tr ("Trying to erase an object from a list that it does not belong to")));
|
||||
}
|
||||
|
||||
if (mp_cell) {
|
||||
|
|
@ -1468,7 +1468,7 @@ Instances::instance_type
|
|||
Instances::replace_prop_id (const instance_type &ref, db::properties_id_type prop_id)
|
||||
{
|
||||
if (ref.instances () != this) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
throw tl::Exception (tl::to_string (tr ("Trying to replace an object in a list that it does not belong to")));
|
||||
}
|
||||
|
||||
if (! ref.is_null ()) {
|
||||
|
|
|
|||
|
|
@ -328,14 +328,14 @@ template<> bool test_extractor_impl (tl::Extractor &ex, db::LayerOffset &e)
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::LayerProperties &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a layer specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a layer specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::LayerOffset &e)
|
||||
{
|
||||
if (! test_extractor_impl (ex, e)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a layer offset specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a layer offset specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1271,13 +1271,13 @@ Layout::update () const
|
|||
void
|
||||
Layout::do_update ()
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (QObject::tr ("Sorting")));
|
||||
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Sorting")));
|
||||
|
||||
// establish a progress report since this operation can take some time.
|
||||
// HINT: because of some gcc bug, automatic destruction of the tl::Progress
|
||||
// object does not work. We overcome this problem by creating the object with new
|
||||
// and catching exceptions.
|
||||
tl::RelativeProgress *pr = new tl::RelativeProgress (tl::to_string (QObject::tr ("Sorting layout")), m_cells_size, 1000);
|
||||
tl::RelativeProgress *pr = new tl::RelativeProgress (tl::to_string (tr ("Sorting layout")), m_cells_size, 1000);
|
||||
pr->set_desc ("");
|
||||
|
||||
try {
|
||||
|
|
@ -1287,12 +1287,12 @@ Layout::do_update ()
|
|||
if (hier_dirty ()) {
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 31, "Updating relations");
|
||||
pr->set_desc (tl::to_string (QObject::tr ("Updating relations")));
|
||||
pr->set_desc (tl::to_string (tr ("Updating relations")));
|
||||
update_relations ();
|
||||
}
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 31, "Topological sort");
|
||||
pr->set_desc (tl::to_string (QObject::tr ("Topological sorting")));
|
||||
pr->set_desc (tl::to_string (tr ("Topological sorting")));
|
||||
tl_assert (topological_sort ());
|
||||
}
|
||||
}
|
||||
|
|
@ -1312,7 +1312,7 @@ Layout::do_update ()
|
|||
tl::SelfTimer timer (tl::verbosity () >= 31, "Updating bounding boxes");
|
||||
unsigned int layers = 0;
|
||||
pr->set (0);
|
||||
pr->set_desc (tl::to_string (QObject::tr ("Updating bounding boxes")));
|
||||
pr->set_desc (tl::to_string (tr ("Updating bounding boxes")));
|
||||
for (bottom_up_iterator c = begin_bottom_up (); c != end_bottom_up (); ++c) {
|
||||
++*pr;
|
||||
cell_type &cp (cell (*c));
|
||||
|
|
@ -1333,7 +1333,7 @@ Layout::do_update ()
|
|||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 31, "Sorting shapes");
|
||||
pr->set (0);
|
||||
pr->set_desc (tl::to_string (QObject::tr ("Sorting shapes")));
|
||||
pr->set_desc (tl::to_string (tr ("Sorting shapes")));
|
||||
for (bottom_up_iterator c = begin_bottom_up (); c != end_bottom_up (); ++c) {
|
||||
++*pr;
|
||||
cell_type &cp (cell (*c));
|
||||
|
|
@ -1347,7 +1347,7 @@ Layout::do_update ()
|
|||
tl::SelfTimer timer (tl::verbosity () >= 31, "Sorting instances");
|
||||
size_t layers = 0;
|
||||
pr->set (0);
|
||||
pr->set_desc (tl::to_string (QObject::tr ("Sorting instances")));
|
||||
pr->set_desc (tl::to_string (tr ("Sorting instances")));
|
||||
for (bottom_up_iterator c = begin_bottom_up (); c != end_bottom_up (); ++c) {
|
||||
++*pr;
|
||||
cell_type &cp (cell (*c));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ tl::Variant LayoutContextHandler::eval_bracket (const std::string &content) cons
|
|||
lp.read (ex);
|
||||
|
||||
if (! ex.at_end ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid layer source expression: ")) + content);
|
||||
throw tl::Exception (tl::to_string (tr ("Not a valid layer source expression: ")) + content);
|
||||
}
|
||||
|
||||
for (db::LayerIterator l = mp_layout->begin_layers (); l != mp_layout->end_layers (); ++l) {
|
||||
|
|
@ -60,7 +60,7 @@ tl::Variant LayoutContextHandler::eval_bracket (const std::string &content) cons
|
|||
if (mp_layout_nc) {
|
||||
return tl::Variant (mp_layout_nc->insert_layer (lp));
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid layer: ")) + lp.to_string ());
|
||||
throw tl::Exception (tl::to_string (tr ("Not a valid layer: ")) + lp.to_string ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ tl::Variant LayoutContextHandler::eval_double_bracket (const std::string &s) con
|
|||
|
||||
db::Library *lib = db::LibraryManager::instance ().lib_ptr_by_name (libname);
|
||||
if (! lib) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid library name: ")) + libname);
|
||||
throw tl::Exception (tl::to_string (tr ("Not a valid library name: ")) + libname);
|
||||
}
|
||||
|
||||
db::LayoutContextHandler lib_context (&lib->layout (), true);
|
||||
|
|
@ -100,7 +100,7 @@ tl::Variant LayoutContextHandler::eval_double_bracket (const std::string &s) con
|
|||
|
||||
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cell name: ")) + s);
|
||||
throw tl::Exception (tl::to_string (tr ("Not a valid cell name: ")) + s);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout
|
|||
}
|
||||
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Layout diff")), common_cells.size (), 1);
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Layout diff")), common_cells.size (), 1);
|
||||
|
||||
// compare cell by cell
|
||||
|
||||
|
|
|
|||
|
|
@ -1438,7 +1438,7 @@ public:
|
|||
FilterStateBase *do_create_state (db::Layout *layout, tl::Eval &eval) const
|
||||
{
|
||||
if (! layout->is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot execute a delete query on a non-editable layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot execute a delete query on a non-editable layout")));
|
||||
}
|
||||
return new DeleteFilterState (this, eval, layout, m_pids, m_transparent);
|
||||
}
|
||||
|
|
@ -1541,7 +1541,7 @@ public:
|
|||
FilterStateBase *do_create_state (db::Layout *layout, tl::Eval &eval) const
|
||||
{
|
||||
if (! layout->is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot execute a with .. do query on a non-editable layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot execute a with .. do query on a non-editable layout")));
|
||||
}
|
||||
return new WithDoFilterState (this, m_do_expression, eval, layout, m_transparent);
|
||||
}
|
||||
|
|
@ -1886,7 +1886,7 @@ public:
|
|||
void execute (const tl::ExpressionParserContext &context, tl::Variant &out, const std::vector<tl::Variant> &args) const
|
||||
{
|
||||
if (args.size () > 0) {
|
||||
throw tl::EvalError (tl::to_string (QObject::tr ("Query function does not allow parameters")), context);
|
||||
throw tl::EvalError (tl::to_string (tr ("Query function does not allow parameters")), context);
|
||||
}
|
||||
|
||||
out = tl::Variant ();
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ merge_layouts (db::Layout &target,
|
|||
// provide the property mapper
|
||||
db::PropertyMapper pm (target, source);
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Merge cells")), all_cells_to_copy.size (), 1);
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Merge cells")), all_cells_to_copy.size (), 1);
|
||||
|
||||
// actually to the mapping
|
||||
for (std::set<db::cell_index_type>::const_iterator c = all_cells_to_copy.begin (); c != all_cells_to_copy.end (); ++c) {
|
||||
|
|
@ -305,7 +305,7 @@ copy_or_move_shapes (db::Layout &target,
|
|||
// provide the property mapper
|
||||
db::PropertyMapper pm (target, source);
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Merge cells")), all_cells_to_copy.size () * layer_mapping.size (), 1);
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Merge cells")), all_cells_to_copy.size () * layer_mapping.size (), 1);
|
||||
|
||||
// and copy
|
||||
for (std::set<db::cell_index_type>::const_iterator c = all_cells_to_copy.begin (); c != all_cells_to_copy.end (); ++c) {
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ Manager::transaction (const std::string &description, transaction_id_t join_with
|
|||
|
||||
// close transactions that are still open (was an assertion before)
|
||||
if (m_opened) {
|
||||
tl::warn << tl::to_string (QObject::tr ("Transaction still opened: ")) << m_current->second;
|
||||
tl::warn << tl::to_string (tr ("Transaction still opened: ")) << m_current->second;
|
||||
commit ();
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ Manager::undo ()
|
|||
m_replay = true;
|
||||
--m_current;
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Undoing")), m_current->first.size (), 10);
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Undoing")), m_current->first.size (), 10);
|
||||
|
||||
try {
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ Manager::redo ()
|
|||
tl_assert (! m_opened);
|
||||
tl_assert (! m_replay);
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Redoing")), m_current->first.size (), 10);
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Redoing")), m_current->first.size (), 10);
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
|||
|
|
@ -818,7 +818,7 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::Matrix2d &m)
|
||||
{
|
||||
if (! test_extractor_impl (ex, m)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a 2d matrix specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a 2d matrix specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -899,7 +899,7 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::Matrix3d &m)
|
||||
{
|
||||
if (! test_extractor_impl (ex, m)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a 3d matrix specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a 3d matrix specification")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -603,14 +603,14 @@ namespace tl
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Path &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a path specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a path specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DPath &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a path specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a path specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::point<C> &p)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a point specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a point specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -481,28 +481,28 @@ namespace tl
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Polygon &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a polygon specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a polygon specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DPolygon &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a polygon specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a polygon specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::SimplePolygon &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a polygon specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a polygon specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DSimplePolygon &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a polygon specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a polygon specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include "tlAlgorithm.h"
|
||||
#include "tlAssert.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ Reader::Reader (tl::InputStream &stream)
|
|||
}
|
||||
|
||||
if (! mp_actual_reader) {
|
||||
throw db::ReaderException (tl::to_string (QObject::tr ("Stream has unknown format: ")) + stream.source ());
|
||||
throw db::ReaderException (tl::to_string (tr ("Stream has unknown format: ")) + stream.source ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1890,7 +1890,7 @@ namespace tl
|
|||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Region &b)
|
||||
{
|
||||
if (! test_extractor_impl (ex, b)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected an region collection specification")));
|
||||
ex.error (tl::to_string (tr ("Expected an region collection specification")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ Shapes::do_insert (const Shapes::shape_type &shape, const Trans &t, tl::func_del
|
|||
case shape_type::TextPtrArray:
|
||||
// Arrays are not supported yet
|
||||
// TODO: implement
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'insert' with transformation does not support shape arrays")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'insert' with transformation does not support shape arrays")));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -588,7 +588,7 @@ Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type p
|
|||
{
|
||||
tl_assert (! ref.is_array_member ());
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace_prop_id' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace_prop_id' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (ref.with_props ()) {
|
||||
|
|
@ -721,7 +721,7 @@ Shapes::transform (const Shapes::shape_type &ref, const Trans &t)
|
|||
{
|
||||
tl_assert (! ref.is_array_member ());
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'transform' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'transform' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
switch (ref.m_type) {
|
||||
|
|
@ -823,7 +823,7 @@ Shapes::replace (const Shapes::shape_type &ref, const Sh &sh)
|
|||
{
|
||||
tl_assert (! ref.is_array_member ());
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
switch (ref.m_type) {
|
||||
|
|
@ -1016,7 +1016,7 @@ Shapes::shape_type
|
|||
Shapes::find_shape_by_tag (Tag tag, const shape_type &shape) const
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'find' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'find' is permitted only in editable mode")));
|
||||
}
|
||||
if (! shape.has_prop_id ()) {
|
||||
typename db::layer<typename Tag::object_type, db::stable_layer_tag>::iterator i = get_layer<typename Tag::object_type, db::stable_layer_tag> ().find (*shape.basic_ptr (tag));
|
||||
|
|
@ -1042,7 +1042,7 @@ Shapes::replace_prop_id (const Sh *pos, db::properties_id_type prop_id)
|
|||
{
|
||||
if (pos->properties_id () != prop_id) {
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
db::layer_op<Sh, db::stable_layer_tag>::queue_or_append (manager (), this, false /*not insert*/, *pos);
|
||||
|
|
@ -1060,7 +1060,7 @@ Shapes::shape_type
|
|||
Shapes::replace_prop_id_iter (typename db::object_tag<Sh>, const Iter &iter, db::properties_id_type prop_id)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
|
|
@ -1080,7 +1080,7 @@ Shapes::shape_type
|
|||
Shapes::reinsert_member_with_props (typename db::object_tag<Sh1>, const shape_type &ref, const Sh2 &sh)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
// the shape types are not equal - resolve into erase and insert (of new)
|
||||
|
|
@ -1099,7 +1099,7 @@ Shapes::shape_type
|
|||
Shapes::replace_member_with_props (typename db::object_tag<Sh1>, const shape_type &ref, const Sh2 &sh)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
// the shape types are not equal - resolve into erase and insert (of new)
|
||||
|
|
@ -1149,7 +1149,7 @@ Shapes::replace_member_with_props (typename db::object_tag<Sh> tag, const shape_
|
|||
} else {
|
||||
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'replace' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (! ref.with_props ()) {
|
||||
|
|
|
|||
|
|
@ -959,7 +959,7 @@ public:
|
|||
void erase (Tag /*tag*/, StableTag /*stable_tag*/, typename db::layer<typename Tag::object_type, StableTag>::iterator pos)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
db::layer_op<typename Tag::object_type, StableTag>::queue_or_append (manager (), this, false /*not insert*/, *pos);
|
||||
|
|
@ -1022,7 +1022,7 @@ public:
|
|||
typename db::layer<typename Tag::object_type, StableTag>::iterator to)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
db::layer_op<typename Tag::object_type, StableTag>::queue_or_append (manager (), this, false /*not insert*/, from, to);
|
||||
|
|
@ -1048,7 +1048,7 @@ public:
|
|||
void erase_positions (Tag /*tag*/, StableTag /*stable_tag*/, I first, I last)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
db::layer_op<typename Tag::object_type, StableTag>::queue_or_append (manager (), this, false /*not insert*/, first, last, true /*dummy*/);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ bool
|
|||
Shapes::is_valid_shape_by_tag (Tag /*tag*/, const shape_type &shape) const
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'is_valid' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'is_valid' is permitted only in editable mode")));
|
||||
}
|
||||
if (! shape.has_prop_id ()) {
|
||||
return iterator_from_shape (get_layer<typename Tag::object_type, db::stable_layer_tag> (), shape).is_valid ();
|
||||
|
|
@ -327,7 +327,7 @@ void
|
|||
Shapes::erase_shape_by_tag_ws (Tag /*tag*/, StableTag /*stable_tag*/, const shape_type &shape)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
if (! shape.has_prop_id ()) {
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ void
|
|||
Shapes::erase_shape (const Shapes::shape_type &shape)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
switch (shape.m_type) {
|
||||
|
|
@ -492,7 +492,7 @@ void
|
|||
Shapes::erase_shapes (const std::vector<Shapes::shape_type> &shapes)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function 'erase' is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'erase' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
for (std::vector<shape_type>::const_iterator s = shapes.begin (); s != shapes.end (); ) {
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ void set_default_editable_mode (bool editable)
|
|||
void check_editable_mode (const char *f_str)
|
||||
{
|
||||
if (! ms_editable) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function '%s' is permitted only in editable mode")), f_str);
|
||||
throw tl::Exception (tl::to_string (tr ("Function '%s' is permitted only in editable mode")), f_str);
|
||||
}
|
||||
}
|
||||
|
||||
void check_editable_mode ()
|
||||
{
|
||||
if (! ms_editable) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Operation is permitted only in editable mode")));
|
||||
throw tl::Exception (tl::to_string (tr ("Operation is permitted only in editable mode")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ namespace db
|
|||
// ------------------------------------------------------------------
|
||||
// Implementation of load_options_xml_element_list
|
||||
|
||||
#if defined(HAVE_XML)
|
||||
|
||||
tl::XMLElementList load_options_xml_element_list ()
|
||||
{
|
||||
tl::XMLElementList elements;
|
||||
|
|
@ -72,6 +74,8 @@ tl::XMLElementList save_options_xml_element_list ()
|
|||
return elements;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@
|
|||
#include "dbLoadLayoutOptions.h"
|
||||
|
||||
#include "tlClassRegistry.h"
|
||||
#include "tlXMLParser.h"
|
||||
#include "tlXMLWriter.h"
|
||||
#if defined(HAVE_XML)
|
||||
# include "tlXMLParser.h"
|
||||
# include "tlXMLWriter.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
@ -109,6 +111,7 @@ 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
|
||||
*
|
||||
|
|
@ -136,8 +139,10 @@ public:
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(HAVE_XML)
|
||||
/**
|
||||
* @brief A helper class for the XML serialization of the stream options (custom read adaptor)
|
||||
*
|
||||
|
|
@ -298,6 +303,7 @@ 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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ LayerMap::from_string_file_format (const std::string &s)
|
|||
}
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
throw tl::Exception (ex.msg () + tl::to_string (QObject::tr (" in line ")) + tl::to_string (lnr));
|
||||
throw tl::Exception (ex.msg () + tl::to_string (tr (" in line ")) + tl::to_string (lnr));
|
||||
}
|
||||
|
||||
return lm;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class DB_PUBLIC LayerSpecFormatException
|
|||
{
|
||||
public:
|
||||
LayerSpecFormatException (const char *s)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Not a valid layer map expression: '..%s' (use '/' to separated layer and datatype, ',' to list numbers for layer or datatype, '-' to create ranges and ';' to concatenate multiple subexpressions)")), s)
|
||||
: tl::Exception (tl::to_string (tr ("Not a valid layer map expression: '..%s' (use '/' to separated layer and datatype, ',' to list numbers for layer or datatype, '-' to create ranges and ';' to concatenate multiple subexpressions)")), s)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ Technologies::add_tech (Technology *tech, bool replace_same)
|
|||
if (replace_same) {
|
||||
*t = *tech;
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::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: %1").arg (tl::to_qstring (tech->name ()))));
|
||||
}
|
||||
} else {
|
||||
m_technologies.push_back (tech_ptr.release ());
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@
|
|||
#include "tlStableVector.h"
|
||||
#include "tlString.h"
|
||||
#include "tlEvents.h"
|
||||
#include "tlXMLParser.h"
|
||||
#if defined(HAVE_XML)
|
||||
# include "tlXMLParser.h"
|
||||
#endif
|
||||
#include "tlTypeTraits.h"
|
||||
#include "tlClassRegistry.h"
|
||||
#include "dbStreamLayers.h"
|
||||
|
|
@ -528,10 +530,12 @@ 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
|
||||
|
|
@ -722,14 +726,18 @@ 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)
|
||||
*/
|
||||
|
|
@ -848,6 +856,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@
|
|||
#include "dbLayoutDiff.h"
|
||||
|
||||
#include "tlUnitTest.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
|
@ -110,7 +109,7 @@ void compare_layouts (tl::TestBase *_this, const db::Layout &layout, const std::
|
|||
fn += tl::sprintf (".%d", n);
|
||||
}
|
||||
|
||||
if (QFileInfo (tl::to_qstring (fn)).exists ()) {
|
||||
if (tl::file_exists (fn)) {
|
||||
|
||||
if (n == 1 && any) {
|
||||
throw tl::Exception (tl::sprintf ("Inconsistent reference variants for %s: there can be either variants (.1,.2,... suffix) or a single file (without suffix)", au_file));
|
||||
|
|
@ -138,8 +137,8 @@ void compare_layouts (tl::TestBase *_this, const db::Layout &layout, const std::
|
|||
|
||||
if (! equal) {
|
||||
_this->raise (tl::sprintf ("Compare failed - see\n actual: %s\n golden: %s%s",
|
||||
tl::to_string (QFileInfo (tl::to_qstring (tmp_file)).absoluteFilePath ()),
|
||||
tl::to_string (QFileInfo (tl::to_qstring (au_file)).absoluteFilePath ()),
|
||||
tl::absolute_file_path (tmp_file),
|
||||
tl::absolute_file_path (au_file),
|
||||
(n > 1 ? "\nand variants" : "")));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ namespace tl
|
|||
template<> void extractor_impl (tl::Extractor &ex, db::Text &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a text specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a text specification")));
|
||||
}
|
||||
}
|
||||
|
||||
template<> void extractor_impl (tl::Extractor &ex, db::DText &p)
|
||||
{
|
||||
if (! test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a text specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a text specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "tlExpression.h"
|
||||
#include "tlProgress.h"
|
||||
#include "tlThreadedWorkers.h"
|
||||
#include "tlThreads.h"
|
||||
#include "gsiDecl.h"
|
||||
|
||||
#include <cmath>
|
||||
|
|
@ -290,7 +291,7 @@ public:
|
|||
|
||||
void next_progress ()
|
||||
{
|
||||
QMutexLocker locker (&m_mutex);
|
||||
tl::MutexLocker locker (&m_mutex);
|
||||
++m_progress;
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +299,7 @@ public:
|
|||
{
|
||||
unsigned int p;
|
||||
{
|
||||
QMutexLocker locker (&m_mutex);
|
||||
tl::MutexLocker locker (&m_mutex);
|
||||
p = m_progress;
|
||||
}
|
||||
|
||||
|
|
@ -316,7 +317,7 @@ private:
|
|||
TilingProcessor *mp_proc;
|
||||
bool m_has_tiles;
|
||||
unsigned int m_progress;
|
||||
QMutex m_mutex;
|
||||
tl::Mutex m_mutex;
|
||||
};
|
||||
|
||||
class TilingProcessorTask
|
||||
|
|
@ -711,15 +712,15 @@ TilingProcessor::output (const std::string &name, db::Edges &edges)
|
|||
tl::Variant
|
||||
TilingProcessor::receiver (const std::vector<tl::Variant> &args)
|
||||
{
|
||||
QMutexLocker locker (&m_output_mutex);
|
||||
tl::MutexLocker locker (&m_output_mutex);
|
||||
|
||||
if (args.size () != 1) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("_rec function requires one argument: the handle of the output channel")));
|
||||
throw tl::Exception (tl::to_string (tr ("_rec function requires one argument: the handle of the output channel")));
|
||||
}
|
||||
|
||||
size_t index = args[0].to<size_t> ();
|
||||
if (index >= m_outputs.size ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid handle in _rec function call")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid handle in _rec function call")));
|
||||
}
|
||||
|
||||
gsi::Proxy *proxy = new gsi::Proxy (gsi::cls_decl<TileOutputReceiver> ());
|
||||
|
|
@ -733,17 +734,17 @@ TilingProcessor::receiver (const std::vector<tl::Variant> &args)
|
|||
void
|
||||
TilingProcessor::put (size_t ix, size_t iy, const db::Box &tile, const std::vector<tl::Variant> &args)
|
||||
{
|
||||
QMutexLocker locker (&m_output_mutex);
|
||||
tl::MutexLocker locker (&m_output_mutex);
|
||||
|
||||
if (args.size () < 2 || args.size () > 3) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("_output function requires two or three arguments: handle and object and a clip flag (optional)")));
|
||||
throw tl::Exception (tl::to_string (tr ("_output function requires two or three arguments: handle and object and a clip flag (optional)")));
|
||||
}
|
||||
|
||||
bool clip = ((args.size () <= 2 || args [2].to_bool ()) && ! tile.empty ());
|
||||
|
||||
size_t index = args[0].to<size_t> ();
|
||||
if (index >= m_outputs.size ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid handle (first argument) in _output function call")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid handle (first argument) in _output function call")));
|
||||
}
|
||||
|
||||
m_outputs[index].receiver->put (ix, iy, tile, m_outputs[index].id, args[1], dbu (), m_outputs[index].trans, clip);
|
||||
|
|
@ -909,7 +910,7 @@ TilingProcessor::execute (const std::string &desc)
|
|||
}
|
||||
|
||||
if (job.has_error ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Errors occured during processing. First error message says:\n")) + job.error_messages ().front ());
|
||||
throw tl::Exception (tl::to_string (tr ("Errors occured during processing. First error message says:\n")) + job.error_messages ().front ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "tlExpression.h"
|
||||
#include "tlTypeTraits.h"
|
||||
#include "tlThreads.h"
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
|
@ -661,7 +662,7 @@ private:
|
|||
bool m_dbu_specific_set;
|
||||
bool m_scale_to_dbu;
|
||||
std::vector<std::string> m_scripts;
|
||||
QMutex m_output_mutex;
|
||||
tl::Mutex m_output_mutex;
|
||||
tl::Eval m_top_eval;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::simple_trans<C> &t)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, t)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a transformation specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a transformation specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::disp_trans<C> &t)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, t)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a transformation specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a transformation specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::complex_trans<I, F, R> &t)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, t)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected transformation specification")));
|
||||
ex.error (tl::to_string (tr ("Expected transformation specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::combined_trans<C1, C2> &t)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, t)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected transformation/magnification specification")));
|
||||
ex.error (tl::to_string (tr ("Expected transformation/magnification specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ void DB_PUBLIC
|
|||
extractor_impl (tl::Extractor &ex, db::FTrans &t)
|
||||
{
|
||||
if (! test_extractor_impl (ex, t)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected rotation/mirror code (r0,r90,r180,r270,m0,m45,m90,m135)")));
|
||||
ex.error (tl::to_string (tr ("Expected rotation/mirror code (r0,r90,r180,r270,m0,m45,m90,m135)")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace {
|
|||
void _extractor_impl (tl::Extractor &ex, db::vector<C> &p)
|
||||
{
|
||||
if (! _test_extractor_impl (ex, p)) {
|
||||
ex.error (tl::to_string (QObject::tr ("Expected a vector specification")));
|
||||
ex.error (tl::to_string (tr ("Expected a vector specification")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Writer::Writer (const db::SaveLayoutOptions &options)
|
|||
}
|
||||
}
|
||||
if (! mp_writer) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown stream format: %s")), m_options.format ());
|
||||
throw tl::Exception (tl::to_string (tr ("Unknown stream format: %s")), m_options.format ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -690,14 +690,14 @@ struct cell_inst_array_defs
|
|||
static void check_is_editable (const db::Instances *insts)
|
||||
{
|
||||
if (! insts->is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function permitted on editable layouts only")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function permitted on editable layouts only")));
|
||||
}
|
||||
}
|
||||
|
||||
static void check_is_editable (const db::Cell *cell)
|
||||
{
|
||||
if (cell->layout () && ! cell->layout ()->is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Function permitted on editable layouts only")));
|
||||
throw tl::Exception (tl::to_string (tr ("Function permitted on editable layouts only")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -745,7 +745,7 @@ static db::Shapes::shape_iterator begin_touching_shapes_um (const db::Cell *s, u
|
|||
{
|
||||
const db::Layout *layout = s->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
}
|
||||
return s->begin_touching (layer_index, db::CplxTrans (layout->dbu ()).inverted () * box, flags);
|
||||
}
|
||||
|
|
@ -754,7 +754,7 @@ static db::Shapes::shape_iterator begin_touching_shapes_all_um (const db::Cell *
|
|||
{
|
||||
const db::Layout *layout = s->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
}
|
||||
return s->begin_touching (layer_index, db::CplxTrans (layout->dbu ()).inverted () * box, db::ShapeIterator::All);
|
||||
}
|
||||
|
|
@ -763,7 +763,7 @@ static db::Shapes::shape_iterator begin_overlapping_shapes_um (const db::Cell *s
|
|||
{
|
||||
const db::Layout *layout = s->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
}
|
||||
return s->begin_overlapping (layer_index, db::CplxTrans (layout->dbu ()).inverted () * box, flags);
|
||||
}
|
||||
|
|
@ -772,7 +772,7 @@ static db::Shapes::shape_iterator begin_overlapping_shapes_all_um (const db::Cel
|
|||
{
|
||||
const db::Layout *layout = s->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer search box")));
|
||||
}
|
||||
return s->begin_overlapping (layer_index, db::CplxTrans (layout->dbu ()).inverted () * box, db::ShapeIterator::All);
|
||||
}
|
||||
|
|
@ -790,7 +790,7 @@ static db::Instance insert_dcell_inst_array_with_props (db::Cell *c, const db::D
|
|||
{
|
||||
const db::Layout *layout = c->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot insert a micrometer-unit cell instance array")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot insert a micrometer-unit cell instance array")));
|
||||
}
|
||||
|
||||
db::CellInstArray inst = cell_inst_array_defs<db::DCellInstArray>::transform_array (dinst, db::CplxTrans (layout->dbu ()).inverted ());
|
||||
|
|
@ -815,7 +815,7 @@ static db::Instance replace_dinst_with_props (db::Cell *c, const db::Instance &o
|
|||
{
|
||||
const db::Layout *layout = c->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit cell instance array")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit cell instance array")));
|
||||
}
|
||||
|
||||
db::CellInstArray inst = cell_inst_array_defs<db::DCellInstArray>::transform_array (dinst, db::CplxTrans (layout->dbu ()).inverted ());
|
||||
|
|
@ -890,7 +890,7 @@ static void delete_cell_property (db::Cell *c, const tl::Variant &key)
|
|||
|
||||
db::Layout *layout = c->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot delete properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot delete properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
@ -913,7 +913,7 @@ static void set_cell_property (db::Cell *c, const tl::Variant &key, const tl::Va
|
|||
|
||||
db::Layout *layout = c->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot set properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot set properties")));
|
||||
}
|
||||
|
||||
db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key);
|
||||
|
|
@ -938,7 +938,7 @@ static tl::Variant get_cell_property (db::Cell *c, const tl::Variant &key)
|
|||
|
||||
db::Layout *layout = c->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot retrieve properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot retrieve properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
@ -1215,10 +1215,10 @@ begin_shapes_rec (const db::Cell *cell, unsigned int layer)
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell is not inside layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell is not inside layout")));
|
||||
}
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, *cell, layer);
|
||||
}
|
||||
|
|
@ -1228,10 +1228,10 @@ begin_shapes_rec_touching (const db::Cell *cell, unsigned int layer, db::Box reg
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell is not inside layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell is not inside layout")));
|
||||
}
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, *cell, layer, region, false);
|
||||
}
|
||||
|
|
@ -1241,10 +1241,10 @@ begin_shapes_rec_touching_um (const db::Cell *cell, unsigned int layer, db::DBox
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell is not inside layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell is not inside layout")));
|
||||
}
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, *cell, layer, db::CplxTrans (layout->dbu ()).inverted () * region, false);
|
||||
}
|
||||
|
|
@ -1254,10 +1254,10 @@ begin_shapes_rec_overlapping (const db::Cell *cell, unsigned int layer, db::Box
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell is not inside layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell is not inside layout")));
|
||||
}
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, *cell, layer, region, true);
|
||||
}
|
||||
|
|
@ -1267,10 +1267,10 @@ begin_shapes_rec_overlapping_um (const db::Cell *cell, unsigned int layer, db::D
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell is not inside layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell is not inside layout")));
|
||||
}
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, *cell, layer, db::CplxTrans (layout->dbu ()).inverted () * region, true);
|
||||
}
|
||||
|
|
@ -1278,16 +1278,16 @@ begin_shapes_rec_overlapping_um (const db::Cell *cell, unsigned int layer, db::D
|
|||
static void copy_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::LayerMapping &layer_mapping)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
const db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
if (target_layout != source_layout) {
|
||||
|
|
@ -1306,16 +1306,16 @@ static void copy_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db:
|
|||
static void copy_shapes1 (db::Cell *cell, const db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy shapes within the same cell")));
|
||||
}
|
||||
db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
if (layout != source_cell.layout ()) {
|
||||
if (! source_cell.layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
db::LayerMapping lm;
|
||||
lm.create_full (*layout, *source_cell.layout ());
|
||||
|
|
@ -1330,10 +1330,10 @@ static void copy_shapes1 (db::Cell *cell, const db::Cell &source_cell)
|
|||
static void copy_instances (db::Cell *cell, const db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy instances within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy instances within the same cell")));
|
||||
}
|
||||
if (cell->layout () != source_cell.layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cells do not reside in the same layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cells do not reside in the same layout")));
|
||||
}
|
||||
|
||||
for (db::Cell::const_iterator i = source_cell.begin (); ! i.at_end (); ++i) {
|
||||
|
|
@ -1344,16 +1344,16 @@ static void copy_instances (db::Cell *cell, const db::Cell &source_cell)
|
|||
static std::vector<db::cell_index_type> copy_tree (db::Cell *cell, const db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
const db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1375,16 +1375,16 @@ static std::vector<db::cell_index_type> copy_tree (db::Cell *cell, const db::Cel
|
|||
static void copy_tree_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
const db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1401,16 +1401,16 @@ static void copy_tree_shapes2 (db::Cell *cell, const db::Cell &source_cell, cons
|
|||
static void copy_tree_shapes3 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot copy shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
const db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1424,16 +1424,16 @@ static void copy_tree_shapes3 (db::Cell *cell, const db::Cell &source_cell, cons
|
|||
static void move_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::LayerMapping &layer_mapping)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
if (target_layout != source_layout) {
|
||||
|
|
@ -1454,16 +1454,16 @@ static void move_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::Layer
|
|||
static void move_shapes1 (db::Cell *cell, db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move shapes within the same cell")));
|
||||
}
|
||||
db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
if (layout != source_cell.layout ()) {
|
||||
if (! source_cell.layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
db::LayerMapping lm;
|
||||
lm.create_full (*layout, *source_cell.layout ());
|
||||
|
|
@ -1479,10 +1479,10 @@ static void move_shapes1 (db::Cell *cell, db::Cell &source_cell)
|
|||
static void move_instances (db::Cell *cell, db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move instances within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move instances within the same cell")));
|
||||
}
|
||||
if (cell->layout () != source_cell.layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cells do not reside in the same layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cells do not reside in the same layout")));
|
||||
}
|
||||
|
||||
for (db::Cell::const_iterator i = source_cell.begin (); ! i.at_end (); ++i) {
|
||||
|
|
@ -1495,16 +1495,16 @@ static void move_instances (db::Cell *cell, db::Cell &source_cell)
|
|||
static std::vector<db::cell_index_type> move_tree (db::Cell *cell, db::Cell &source_cell)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1528,16 +1528,16 @@ static std::vector<db::cell_index_type> move_tree (db::Cell *cell, db::Cell &sou
|
|||
static void move_tree_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1554,16 +1554,16 @@ static void move_tree_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::
|
|||
static void move_tree_shapes3 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm)
|
||||
{
|
||||
if (cell == &source_cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot move shapes within the same cell")));
|
||||
}
|
||||
|
||||
db::Layout *target_layout = cell->layout ();
|
||||
if (! target_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside in a layout")));
|
||||
}
|
||||
db::Layout *source_layout = source_cell.layout ();
|
||||
if (! source_layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source cell does not reside in a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout")));
|
||||
}
|
||||
|
||||
db::PropertyMapper pm (*target_layout, *source_layout);
|
||||
|
|
@ -1578,7 +1578,7 @@ static void
|
|||
fill_region1 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cell_index, const db::Box &fc_box, const db::Point *origin)
|
||||
{
|
||||
if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid fill cell footprint (empty or zero width/height)")));
|
||||
}
|
||||
db::fill_region (cell, fr, fill_cell_index, fc_box, origin ? *origin : db::Point (), origin == 0, 0, db::Vector (), 0);
|
||||
}
|
||||
|
|
@ -1588,7 +1588,7 @@ fill_region2 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cel
|
|||
db::Region *remaining_parts, const db::Vector &fill_margin, db::Region *remaining_polygons)
|
||||
{
|
||||
if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid fill cell footprint (empty or zero width/height)")));
|
||||
}
|
||||
db::fill_region (cell, fr, fill_cell_index, fc_box, origin ? *origin : db::Point (), origin == 0, remaining_parts, fill_margin, remaining_polygons);
|
||||
}
|
||||
|
|
@ -1597,7 +1597,7 @@ static db::Instance cell_inst_dtransform_simple (db::Cell *cell, const db::Insta
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1608,7 +1608,7 @@ static db::Instance cell_inst_dtransform_cplx (db::Cell *cell, const db::Instanc
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1619,7 +1619,7 @@ static db::Instance cell_inst_dtransform_into_simple (db::Cell *cell, const db::
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1630,7 +1630,7 @@ static db::Instance cell_inst_dtransform_into_cplx (db::Cell *cell, const db::In
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1641,7 +1641,7 @@ static void cell_dtransform_into_simple (db::Cell *cell, const db::DTrans &t)
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1652,7 +1652,7 @@ static void cell_dtransform_into_cplx (db::Cell *cell, const db::DCplxTrans &t)
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit transformation")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1663,7 +1663,7 @@ static db::DBox cell_dbbox (const db::Cell *cell)
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot get the micrometer-unit bounding box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot get the micrometer-unit bounding box")));
|
||||
}
|
||||
|
||||
return cell->bbox () * layout->dbu ();
|
||||
|
|
@ -1673,7 +1673,7 @@ static db::DBox cell_dbbox_per_layer (const db::Cell *cell, unsigned int layer_i
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot get the micrometer-unit bounding box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot get the micrometer-unit bounding box")));
|
||||
}
|
||||
|
||||
return cell->bbox (layer_index) * layout->dbu ();
|
||||
|
|
@ -1683,7 +1683,7 @@ static db::Cell::overlapping_iterator cell_begin_overlapping_inst_um (const db::
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit search boxes")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit search boxes")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -1694,7 +1694,7 @@ static db::Cell::touching_iterator cell_begin_touching_inst_um (const db::Cell *
|
|||
{
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cell does not reside inside a layout - cannot use a micrometer-unit search boxes")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot use a micrometer-unit search boxes")));
|
||||
}
|
||||
|
||||
db::CplxTrans dbu_trans (layout->dbu ());
|
||||
|
|
@ -3077,7 +3077,7 @@ static double inst_dbu (const db::Instance *inst)
|
|||
{
|
||||
const db::Layout *layout = layout_ptr_const (inst);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance is not a part of a layout - cannot determine database unit")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance is not a part of a layout - cannot determine database unit")));
|
||||
}
|
||||
return layout->dbu ();
|
||||
}
|
||||
|
|
@ -3159,13 +3159,13 @@ static void set_parent_cell_ptr (db::Instance *i, db::Cell *new_parent)
|
|||
{
|
||||
db::Cell *parent = parent_cell_ptr (i);
|
||||
if (! parent) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance does not reside in a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance does not reside in a cell")));
|
||||
}
|
||||
if (! parent->layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance does not reside in a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance does not reside in a cell")));
|
||||
}
|
||||
if (new_parent->layout () != parent->layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source and target layouts are not identical")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source and target layouts are not identical")));
|
||||
}
|
||||
|
||||
if (new_parent != parent) {
|
||||
|
|
@ -3186,7 +3186,7 @@ static void delete_property (db::Instance *i, const tl::Variant &key)
|
|||
|
||||
db::Layout *layout = layout_ptr (i);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance does not reside inside a layout - cannot delete properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot delete properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
@ -3208,7 +3208,7 @@ static void set_property (db::Instance *i, const tl::Variant &key, const tl::Var
|
|||
|
||||
db::Layout *layout = layout_ptr (i);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance does not reside inside a layout - cannot set properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot set properties")));
|
||||
}
|
||||
|
||||
db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key);
|
||||
|
|
@ -3232,7 +3232,7 @@ static tl::Variant get_property (const db::Instance *i, const tl::Variant &key)
|
|||
|
||||
const db::Layout *layout = layout_ptr_const (i);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance does not reside inside a layout - cannot retrieve properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot retrieve properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
@ -3664,7 +3664,7 @@ db::Box inst_bbox_per_layer (const db::Instance *inst, unsigned int layer_index)
|
|||
{
|
||||
const db::Layout *layout = layout_ptr_const (inst);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Instance is not a part of a layout - cannot compute micrometer bounding box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Instance is not a part of a layout - cannot compute micrometer bounding box")));
|
||||
}
|
||||
|
||||
db::box_convert <db::CellInst> bc (*layout, layer_index);
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
#include "dbLoadLayoutOptions.h"
|
||||
#include "gsiDecl.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace dn
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ static db::cell_index_type cell_by_name (db::Layout *l, const char *name)
|
|||
{
|
||||
std::pair<bool, db::cell_index_type> c = l->cell_by_name (name);
|
||||
if (! c.first) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("No such cell: '%s'")), name));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("No such cell: '%s'")), name));
|
||||
}
|
||||
return c.second;
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ static db::properties_id_type properties_id (db::Layout *layout, const std::vect
|
|||
|
||||
for (std::vector<tl::Variant>::const_iterator v = properties.begin (); v != properties.end (); ++v) {
|
||||
if (! v->is_list () || v->get_list ().size () != 2) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Expected a list of pairs of variants (found at least one that is not a pair)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Expected a list of pairs of variants (found at least one that is not a pair)")));
|
||||
}
|
||||
db::property_names_id_type name_id = layout->properties_repository ().prop_name_id (v->get_list ()[0]);
|
||||
props.insert (std::make_pair (name_id, v->get_list () [1]));
|
||||
|
|
@ -529,7 +529,7 @@ write_simple (db::Layout *layout, const std::string &filename)
|
|||
{
|
||||
db::SaveLayoutOptions options;
|
||||
if (! options.set_format_from_filename (filename)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot determine format from filename")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot determine format from filename")));
|
||||
}
|
||||
|
||||
db::Writer writer (options);
|
||||
|
|
@ -555,10 +555,10 @@ static db::RecursiveShapeIterator
|
|||
begin_shapes (const db::Layout *layout, db::cell_index_type starting_cell, unsigned int layer)
|
||||
{
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
if (! layout->is_valid_cell_index (starting_cell)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid cell index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid cell index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, layout->cell (starting_cell), layer);
|
||||
}
|
||||
|
|
@ -573,10 +573,10 @@ static db::RecursiveShapeIterator
|
|||
begin_shapes_touching (const db::Layout *layout, db::cell_index_type starting_cell, unsigned int layer, db::Box region)
|
||||
{
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
if (! layout->is_valid_cell_index (starting_cell)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid cell index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid cell index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, layout->cell (starting_cell), layer, region, false);
|
||||
}
|
||||
|
|
@ -591,10 +591,10 @@ static db::RecursiveShapeIterator
|
|||
begin_shapes_overlapping (const db::Layout *layout, db::cell_index_type starting_cell, unsigned int layer, db::Box region)
|
||||
{
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
if (! layout->is_valid_cell_index (starting_cell)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid cell index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid cell index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, layout->cell (starting_cell), layer, region, true);
|
||||
}
|
||||
|
|
@ -609,10 +609,10 @@ static db::RecursiveShapeIterator
|
|||
begin_shapes_touching_um (const db::Layout *layout, db::cell_index_type starting_cell, unsigned int layer, db::DBox region)
|
||||
{
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
if (! layout->is_valid_cell_index (starting_cell)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid cell index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid cell index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, layout->cell (starting_cell), layer, db::CplxTrans (layout->dbu ()).inverted () * region, false);
|
||||
}
|
||||
|
|
@ -627,10 +627,10 @@ static db::RecursiveShapeIterator
|
|||
begin_shapes_overlapping_um (const db::Layout *layout, db::cell_index_type starting_cell, unsigned int layer, db::DBox region)
|
||||
{
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid layer index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid layer index")));
|
||||
}
|
||||
if (! layout->is_valid_cell_index (starting_cell)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid cell index")));
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid cell index")));
|
||||
}
|
||||
return db::RecursiveShapeIterator (*layout, layout->cell (starting_cell), layer, db::CplxTrans (layout->dbu ()).inverted () * region, true);
|
||||
}
|
||||
|
|
@ -706,7 +706,7 @@ static std::vector<std::string> pcell_names (const db::Layout *layout)
|
|||
static db::Cell *cell_from_index (db::Layout *ly, db::cell_index_type ci)
|
||||
{
|
||||
if (! ly->is_valid_cell_index (ci)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cell index: ")) + tl::to_string (ci));
|
||||
throw tl::Exception (tl::to_string (tr ("Not a valid cell index: ")) + tl::to_string (ci));
|
||||
}
|
||||
return &ly->cell (ci);
|
||||
}
|
||||
|
|
@ -740,7 +740,7 @@ static db::Cell *top_cell (db::Layout *layout)
|
|||
if (! tc) {
|
||||
tc = &layout->cell (*td);
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("The layout has multiple top cells")));
|
||||
throw tl::Exception (tl::to_string (tr ("The layout has multiple top cells")));
|
||||
}
|
||||
++td;
|
||||
}
|
||||
|
|
@ -2000,7 +2000,7 @@ static db::SaveLayoutOptions *new_v ()
|
|||
static bool set_format_from_filename (db::SaveLayoutOptions *opt, const std::string &fn)
|
||||
{
|
||||
if (! opt->set_format_from_filename (fn)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot determine format from filename")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot determine format from filename")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static double shape_dbu (const db::Shape *s)
|
|||
{
|
||||
const db::Layout *layout = layout_ptr_const (s);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not reside inside a layout - cannot obtain database unit")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot obtain database unit")));
|
||||
}
|
||||
return layout->dbu ();
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ static db::Shapes *shapes_checked (db::Shape *s)
|
|||
{
|
||||
db::Shapes *shapes = s->shapes ();
|
||||
if (! shapes) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not reside inside a shape container - cannot change the shape")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a shape container - cannot change the shape")));
|
||||
}
|
||||
return shapes;
|
||||
}
|
||||
|
|
@ -65,21 +65,21 @@ static db::Shapes *shapes_checked (db::Shape *s)
|
|||
static void check_is_path (const db::Shape *s)
|
||||
{
|
||||
if (! s->is_path ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape is not a path")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape is not a path")));
|
||||
}
|
||||
}
|
||||
|
||||
static void check_is_text (const db::Shape *s)
|
||||
{
|
||||
if (! s->is_text ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape is not a text")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape is not a text")));
|
||||
}
|
||||
}
|
||||
|
||||
static void check_is_box (const db::Shape *s)
|
||||
{
|
||||
if (! s->is_box ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape is not a box")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape is not a box")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -724,17 +724,17 @@ static unsigned int shape_layer_index (const db::Shape *s)
|
|||
{
|
||||
db::Shapes *shapes = s->shapes ();
|
||||
if (! shapes) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a shape container")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a shape container")));
|
||||
}
|
||||
|
||||
db::Cell *cell = shapes->cell ();
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a cell")));
|
||||
}
|
||||
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a layout")));
|
||||
}
|
||||
|
||||
for (db::Layout::layer_iterator l = layout->begin_layers (); l != layout->end_layers (); ++l) {
|
||||
|
|
@ -743,28 +743,28 @@ static unsigned int shape_layer_index (const db::Shape *s)
|
|||
}
|
||||
}
|
||||
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot identify layer of shape")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot identify layer of shape")));
|
||||
}
|
||||
|
||||
static void set_shape_layer_index (db::Shape *s, unsigned int layer)
|
||||
{
|
||||
db::Shapes *shapes = s->shapes ();
|
||||
if (! shapes) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a shape container")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a shape container")));
|
||||
}
|
||||
|
||||
db::Cell *cell = shapes->cell ();
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a cell")));
|
||||
}
|
||||
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a layout")));
|
||||
}
|
||||
|
||||
if (! layout->is_valid_layer (layer)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Layer index does not point to a valid layer")));
|
||||
throw tl::Exception (tl::to_string (tr ("Layer index does not point to a valid layer")));
|
||||
}
|
||||
|
||||
if (& cell->shapes (layer) != shapes) {
|
||||
|
|
@ -778,17 +778,17 @@ static db::LayerProperties shape_layer (const db::Shape *s)
|
|||
{
|
||||
db::Shapes *shapes = s->shapes ();
|
||||
if (! shapes) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a shape container")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a shape container")));
|
||||
}
|
||||
|
||||
db::Cell *cell = shapes->cell ();
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a cell")));
|
||||
}
|
||||
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a layout")));
|
||||
}
|
||||
|
||||
for (db::Layout::layer_iterator l = layout->begin_layers (); l != layout->end_layers (); ++l) {
|
||||
|
|
@ -797,24 +797,24 @@ static db::LayerProperties shape_layer (const db::Shape *s)
|
|||
}
|
||||
}
|
||||
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot identify layer of shape")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot identify layer of shape")));
|
||||
}
|
||||
|
||||
static void set_shape_layer (db::Shape *s, const db::LayerProperties &lp)
|
||||
{
|
||||
db::Shapes *shapes = s->shapes ();
|
||||
if (! shapes) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a shape container")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a shape container")));
|
||||
}
|
||||
|
||||
db::Cell *cell = shapes->cell ();
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a cell")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a cell")));
|
||||
}
|
||||
|
||||
const db::Layout *layout = cell->layout ();
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not belong to a layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not belong to a layout")));
|
||||
}
|
||||
|
||||
for (db::Layout::layer_iterator l = layout->begin_layers (); l != layout->end_layers (); ++l) {
|
||||
|
|
@ -834,7 +834,7 @@ static void set_shape_layer (db::Shape *s, const db::LayerProperties &lp)
|
|||
|
||||
}
|
||||
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Layer info object is not giving a valid layer")));
|
||||
throw tl::Exception (tl::to_string (tr ("Layer info object is not giving a valid layer")));
|
||||
}
|
||||
|
||||
static db::Cell *cell_ptr (db::Shape *s)
|
||||
|
|
@ -847,7 +847,7 @@ static void set_cell_ptr (db::Shape *s, db::Cell *new_cell)
|
|||
{
|
||||
db::Shapes *shapes = shapes_checked (s);
|
||||
if (layout_ptr (s) != new_cell->layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Current and new cell belong to a different layout")));
|
||||
throw tl::Exception (tl::to_string (tr ("Current and new cell belong to a different layout")));
|
||||
}
|
||||
|
||||
unsigned int l = shape_layer_index (s);
|
||||
|
|
@ -881,7 +881,7 @@ static void delete_property (db::Shape *s, const tl::Variant &key)
|
|||
|
||||
db::Layout *layout = layout_ptr (s);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not reside inside a layout - cannot delete properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot delete properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
@ -903,7 +903,7 @@ static void set_property (db::Shape *s, const tl::Variant &key, const tl::Varian
|
|||
|
||||
db::Layout *layout = layout_ptr (s);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not reside inside a layout - cannot set properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot set properties")));
|
||||
}
|
||||
|
||||
db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key);
|
||||
|
|
@ -927,7 +927,7 @@ static tl::Variant get_property (const db::Shape *s, const tl::Variant &key)
|
|||
|
||||
const db::Layout *layout = layout_ptr_const (s);
|
||||
if (! layout) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Shape does not reside inside a layout - cannot retrieve properties")));
|
||||
throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot retrieve properties")));
|
||||
}
|
||||
|
||||
std::pair<bool, db::property_names_id_type> nid = layout->properties_repository ().get_id_of_name (key);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace gsi
|
|||
static double shapes_dbu (const db::Shapes *shapes)
|
||||
{
|
||||
if (! shapes->layout ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("The shapes do not reside inside a layout - cannot obtain database unit")));
|
||||
throw tl::Exception (tl::to_string (tr ("The shapes do not reside inside a layout - cannot obtain database unit")));
|
||||
}
|
||||
return shapes->layout ()->dbu ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@
|
|||
|
||||
#include "gsiDecl.h"
|
||||
#include "dbTechnology.h"
|
||||
#include "tlXMLWriter.h"
|
||||
#include "tlXMLParser.h"
|
||||
|
||||
#if defined(HAVE_XML)
|
||||
# include "tlXMLWriter.h"
|
||||
# include "tlXMLParser.h"
|
||||
#endif
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -59,6 +62,7 @@ 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 ();
|
||||
|
|
@ -90,6 +94,7 @@ 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)
|
||||
{
|
||||
|
|
@ -275,6 +280,7 @@ 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"
|
||||
|
|
@ -298,6 +304,7 @@ 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"
|
||||
) +
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static gsi::Class<EmptyClass> default_cls ("tl", "EmptyClass", gsi::Methods ());
|
|||
const ClassBase *fallback_cls_decl (const std::type_info &ti)
|
||||
{
|
||||
// This is the main purpose of this function: print the missing class
|
||||
tl::warn << tl::to_string (QObject::tr ("Unable to find GSI class binding for: ")) << ti.name ();
|
||||
tl::warn << tl::to_string (tr ("Unable to find GSI class binding for: ")) << ti.name ();
|
||||
return &default_cls;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ void _push_ptr_vector_of (SerialArgs &to, const ArgType &a, tl::Heap &heap, cons
|
|||
template <class X>
|
||||
void *_create (tl::false_tag)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be created here")));
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be created here")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -444,7 +444,7 @@ void *_create (tl::true_tag)
|
|||
template <class X>
|
||||
void *_clone (tl::false_tag, const void * /*other*/)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be copied here")));
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be copied here")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ void *_clone (tl::true_tag, const void *other)
|
|||
template <class X>
|
||||
void _assign (tl::false_tag /*has_copy_ctor*/, void *, const void *)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Object cannot be copied here")));
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be copied here")));
|
||||
}
|
||||
|
||||
template <class X>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@
|
|||
#include "tlLog.h"
|
||||
#include "tlAssert.h"
|
||||
|
||||
#include <QMetaMethod>
|
||||
#include <QMetaObject>
|
||||
|
||||
#include <cstdio>
|
||||
#include <set>
|
||||
|
||||
|
|
@ -192,7 +189,7 @@ ClassBase::create_obj_from (const ClassBase *from, void *obj) const
|
|||
for (method_iterator m = begin_constructors (); m != end_constructors (); ++m) {
|
||||
if (is_constructor_of (this, *m, from)) {
|
||||
if (ctor) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("There are multiple conversion constructors available to convert object of type %s to type %s")), from->name (), name ());
|
||||
throw tl::Exception (tl::to_string (tr ("There are multiple conversion constructors available to convert object of type %s to type %s")), from->name (), name ());
|
||||
}
|
||||
ctor = *m;
|
||||
}
|
||||
|
|
@ -242,7 +239,7 @@ static SpecialMethod *
|
|||
sm_default_ctor (const char *name, const gsi::ClassBase *cls)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Creates a new object of this class\n")),
|
||||
tl::to_string (tr ("@brief Creates a new object of this class\n")),
|
||||
false, // non-const
|
||||
true, // static
|
||||
MethodBase::DefaultCtor);
|
||||
|
|
@ -261,8 +258,8 @@ static SpecialMethod *
|
|||
sm_destroy (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Explicitly destroys the object\nExplicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception.\n"
|
||||
"If the object is not owned by the script, this method will do nothing.")),
|
||||
tl::to_string (tr ("@brief Explicitly destroys the object\nExplicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception.\n"
|
||||
"If the object is not owned by the script, this method will do nothing.")),
|
||||
false, // non-const
|
||||
false, // non-static
|
||||
MethodBase::Destroy);
|
||||
|
|
@ -274,9 +271,9 @@ static SpecialMethod *
|
|||
sm_create (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Ensures the C++ object is created\n"
|
||||
"Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. "
|
||||
"Usually C++ objects are created on demand and not necessarily when the script object is created.")),
|
||||
tl::to_string (tr ("@brief Ensures the C++ object is created\n"
|
||||
"Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. "
|
||||
"Usually C++ objects are created on demand and not necessarily when the script object is created.")),
|
||||
false, // non-const
|
||||
false, // non-static
|
||||
MethodBase::Create);
|
||||
|
|
@ -288,13 +285,13 @@ static SpecialMethod *
|
|||
sm_keep (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Marks the object as no longer owned by the script side.\n"
|
||||
"Calling this method will make this object no longer owned by the script's memory management. "
|
||||
"Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. "
|
||||
"Technically speaking, this method will turn the script's reference into a weak reference. "
|
||||
"After the script engine decides to delete the reference, the object itself will still exist. "
|
||||
"If the object is not managed otherwise, memory leaks will occur.\n\n"
|
||||
"Usually it's not required to call this method. It has been introduced in version 0.24.")),
|
||||
tl::to_string (tr ("@brief Marks the object as no longer owned by the script side.\n"
|
||||
"Calling this method will make this object no longer owned by the script's memory management. "
|
||||
"Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. "
|
||||
"Technically speaking, this method will turn the script's reference into a weak reference. "
|
||||
"After the script engine decides to delete the reference, the object itself will still exist. "
|
||||
"If the object is not managed otherwise, memory leaks will occur.\n\n"
|
||||
"Usually it's not required to call this method. It has been introduced in version 0.24.")),
|
||||
false, // non-const
|
||||
false, // non-static
|
||||
MethodBase::Keep);
|
||||
|
|
@ -306,11 +303,11 @@ static SpecialMethod *
|
|||
sm_release (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Marks the object as managed by the script side.\n"
|
||||
"After calling this method on an object, the script side will be responsible for the management of the object. "
|
||||
"This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. "
|
||||
"If necessary, the script side may delete the object if the script's reference is no longer required.\n\n"
|
||||
"Usually it's not required to call this method. It has been introduced in version 0.24.")),
|
||||
tl::to_string (tr ("@brief Marks the object as managed by the script side.\n"
|
||||
"After calling this method on an object, the script side will be responsible for the management of the object. "
|
||||
"This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. "
|
||||
"If necessary, the script side may delete the object if the script's reference is no longer required.\n\n"
|
||||
"Usually it's not required to call this method. It has been introduced in version 0.24.")),
|
||||
false, // non-const
|
||||
false, // non-static
|
||||
MethodBase::Release);
|
||||
|
|
@ -322,8 +319,8 @@ static SpecialMethod *
|
|||
sm_is_const (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Returns a value indicating whether the reference is a const reference\nThis method returns true, if self is a const reference.\n"
|
||||
"In that case, only const methods may be called on self.")),
|
||||
tl::to_string (tr ("@brief Returns a value indicating whether the reference is a const reference\nThis method returns true, if self is a const reference.\n"
|
||||
"In that case, only const methods may be called on self.")),
|
||||
true, // const
|
||||
false, // non-static
|
||||
MethodBase::IsConst);
|
||||
|
|
@ -339,8 +336,8 @@ static SpecialMethod *
|
|||
sm_destroyed (const char *name)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Returns a value indicating whether the object was already destroyed\nThis method returns true, if the object was destroyed, either explicitly or by the C++ side.\n"
|
||||
"The latter may happen, if the object is owned by a C++ object which got destroyed itself.")),
|
||||
tl::to_string (tr ("@brief Returns a value indicating whether the object was already destroyed\nThis method returns true, if the object was destroyed, either explicitly or by the C++ side.\n"
|
||||
"The latter may happen, if the object is owned by a C++ object which got destroyed itself.")),
|
||||
true, // const
|
||||
false, // non-static
|
||||
MethodBase::Destroyed);
|
||||
|
|
@ -356,7 +353,7 @@ static SpecialMethod *
|
|||
sm_dup (const char *name, const gsi::ClassBase *cls)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Creates a copy of self\n")),
|
||||
tl::to_string (tr ("@brief Creates a copy of self\n")),
|
||||
true, // const
|
||||
false, // non-static
|
||||
MethodBase::Dup);
|
||||
|
|
@ -375,7 +372,7 @@ static SpecialMethod *
|
|||
sm_assign (const char *name, const gsi::ClassBase *cls)
|
||||
{
|
||||
SpecialMethod *sm = new SpecialMethod (name,
|
||||
tl::to_string (QObject::tr ("@brief Assigns another object to self\n@args other")),
|
||||
tl::to_string (tr ("@brief Assigns another object to self\n@args other")),
|
||||
false, // non-const
|
||||
false, // non-static
|
||||
MethodBase::Assign);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
#include "gsiDecl.h"
|
||||
#include "tlString.h"
|
||||
|
||||
#include <QFlags>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QFlags>
|
||||
#endif
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -329,6 +331,8 @@ private:
|
|||
EnumSpecs<E> m_specs;
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
template <class E>
|
||||
class QFlagsClass;
|
||||
|
||||
|
|
@ -571,6 +575,8 @@ private:
|
|||
gsi::ClassExt<E> m_enum_ext;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@
|
|||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
@ -481,7 +478,7 @@ struct writer
|
|||
if (arg->is_nil () && atype.type () != gsi::T_var) {
|
||||
|
||||
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 if (atype.is_ptr ()) {
|
||||
aa->write<R *> ((R *)0);
|
||||
} else {
|
||||
|
|
@ -571,7 +568,7 @@ struct writer<VectorType>
|
|||
{
|
||||
if (arg->is_nil ()) {
|
||||
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);
|
||||
}
|
||||
|
|
@ -592,7 +589,7 @@ struct writer<MapType>
|
|||
{
|
||||
if (arg->is_nil ()) {
|
||||
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);
|
||||
}
|
||||
|
|
@ -629,7 +626,7 @@ struct writer<gsi::ObjectType>
|
|||
if (arg->is_nil ()) {
|
||||
|
||||
if (atype.is_ref () || atype.is_cref ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot pass nil to reference parameters")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot pass nil to reference parameters")));
|
||||
}
|
||||
|
||||
aa->write<void *> ((void *) 0);
|
||||
|
|
@ -637,15 +634,15 @@ struct writer<gsi::ObjectType>
|
|||
} else {
|
||||
|
||||
if (! arg->is_user ()) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
const tl::VariantUserClassBase *cls = arg->user_cls ();
|
||||
if (!cls) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
if (cls->is_const () && (atype.is_ref () || atype.is_ptr ())) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Cannot pass a const reference of class %s to a non-const reference or pointer parameter")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Cannot pass a const reference of class %s to a non-const reference or pointer parameter")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
if (cls->gsi_cls ()->is_derived_from (atype.cls ())) {
|
||||
|
|
@ -666,7 +663,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)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -674,15 +671,15 @@ struct writer<gsi::ObjectType>
|
|||
} else {
|
||||
|
||||
if (! arg->is_user ()) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
const tl::VariantUserClassBase *cls = arg->user_cls ();
|
||||
if (!cls) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
if (cls->is_const () && (atype.is_ref () || atype.is_ptr ())) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Cannot pass a const reference of class %s to a non-const reference or pointer parameter")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Cannot pass a const reference of class %s to a non-const reference or pointer parameter")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
if (cls->gsi_cls ()->is_derived_from (atype.cls ())) {
|
||||
|
|
@ -698,7 +695,7 @@ struct writer<gsi::ObjectType>
|
|||
aa->write<void *> (atype.cls ()->create_obj_from (cls->gsi_cls (), get_object (*arg)));
|
||||
|
||||
} else {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unexpected object type (expected argument of class %s)")), atype.cls ()->name ()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1061,7 +1058,7 @@ public:
|
|||
void execute (const tl::ExpressionParserContext & /*context*/, tl::Variant &out, const std::vector<tl::Variant> &args) const
|
||||
{
|
||||
if (! args.empty ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Class '%s' is not a function - use 'new' to create a new object")), mp_var_cls->name ());
|
||||
throw tl::Exception (tl::to_string (tr ("Class '%s' is not a function - use 'new' to create a new object")), mp_var_cls->name ());
|
||||
}
|
||||
out = tl::Variant ((void *) 0, mp_var_cls, false);
|
||||
}
|
||||
|
|
@ -1235,7 +1232,7 @@ VariantUserClassImpl::execute (const tl::ExpressionParserContext &context, tl::V
|
|||
if (mp_object_cls == 0 && method == "is_a") {
|
||||
|
||||
if (args.size () != 1) {
|
||||
throw tl::EvalError (tl::to_string (QObject::tr ("'is_a' method requires exactly one argument")), context);
|
||||
throw tl::EvalError (tl::to_string (tr ("'is_a' method requires exactly one argument")), context);
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
|
@ -1273,7 +1270,7 @@ VariantUserClassImpl::execute (const tl::ExpressionParserContext &context, tl::V
|
|||
} else if (mp_object_cls == 0 && method == "dup") {
|
||||
|
||||
if (args.size () != 0) {
|
||||
throw tl::EvalError (tl::to_string (QObject::tr ("'dup' method does not allow arguments")), context);
|
||||
throw tl::EvalError (tl::to_string (tr ("'dup' method does not allow arguments")), context);
|
||||
}
|
||||
|
||||
void *obj = mp_cls->create ();
|
||||
|
|
@ -1338,7 +1335,7 @@ special_method_impl (gsi::MethodBase::special_method_type smt, tl::Variant &self
|
|||
} else if (smt == gsi::MethodBase::Assign) {
|
||||
tl_assert (args.size () == 1);
|
||||
if (!args.front ().is_user () || self.user_cls () != args.front ().user_cls ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Source and target object must be of the same type for assignment")));
|
||||
throw tl::Exception (tl::to_string (tr ("Source and target object must be of the same type for assignment")));
|
||||
}
|
||||
self.user_assign (args.front ());
|
||||
} else if (smt == gsi::MethodBase::Dup) {
|
||||
|
|
@ -1380,7 +1377,7 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
|
|||
}
|
||||
|
||||
if (cls == 0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown method")) + " '" + method + "' of class '" + clsact->name () + "'");
|
||||
throw tl::Exception (tl::to_string (tr ("Unknown method")) + " '" + method + "' of class '" + clsact->name () + "'");
|
||||
}
|
||||
|
||||
const gsi::MethodBase *meth = 0;
|
||||
|
|
@ -1389,7 +1386,7 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
|
|||
for (ExpressionMethodTableEntry::method_iterator m = mt->begin (mid); m != mt->end (mid); ++m) {
|
||||
|
||||
if ((*m)->is_signal()) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Signals are not supported inside expressions (event %s)")), method.c_str ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Signals are not supported inside expressions (event %s)")), method.c_str ()));
|
||||
} else if ((*m)->is_callback()) {
|
||||
// ignore callbacks
|
||||
} else if ((*m)->compatible_with_num_args (args.size ())) {
|
||||
|
|
@ -1414,7 +1411,7 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
|
|||
nargs_s += tl::to_string (*na);
|
||||
}
|
||||
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Invalid number of arguments for method %s, class %s (got %d, expected %s)")), method.c_str (), mp_cls->name (), int (args.size ()), nargs_s));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Invalid number of arguments for method %s, class %s (got %d, expected %s)")), method.c_str (), mp_cls->name (), int (args.size ()), nargs_s));
|
||||
}
|
||||
|
||||
// more than one candidate -> refine by checking the arguments
|
||||
|
|
@ -1481,21 +1478,21 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
|
|||
}
|
||||
|
||||
if (! meth) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("No method with matching arguments for method %s, class %s")), method.c_str (), mp_cls->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("No method with matching arguments for method %s, class %s")), method.c_str (), mp_cls->name ()));
|
||||
}
|
||||
|
||||
if (candidates > 1) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Ambiguous overload variants for method %s, class %s - multiple method declarations match arguments")), method.c_str (), mp_cls->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Ambiguous overload variants for method %s, class %s - multiple method declarations match arguments")), method.c_str (), mp_cls->name ()));
|
||||
}
|
||||
|
||||
if (m_is_const && ! meth->is_const ()) {
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Cannot call non-const method %s, class %s on a const reference")), method.c_str (), mp_cls->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Cannot call non-const method %s, class %s on a const reference")), method.c_str (), mp_cls->name ()));
|
||||
}
|
||||
|
||||
if (meth->is_signal ()) {
|
||||
|
||||
// TODO: events not supported yet
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Signals not supported yet (method %s, class %s)")), method.c_str (), mp_cls->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Signals not supported yet (method %s, class %s)")), method.c_str (), mp_cls->name ()));
|
||||
|
||||
} else if (meth->smt () != gsi::MethodBase::None) {
|
||||
|
||||
|
|
@ -1518,7 +1515,7 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
|
|||
|
||||
if (meth->ret_type ().is_iter ()) {
|
||||
// TODO: iterators not supported yet
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Iterators not supported yet (method %s, class %s)")), method.c_str (), mp_cls->name ()));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Iterators not supported yet (method %s, class %s)")), method.c_str (), mp_cls->name ()));
|
||||
} else {
|
||||
out = tl::Variant ();
|
||||
gsi::do_on_type<reader> () (meth->ret_type ().type (), &out, &retlist, meth->ret_type (), &heap);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ struct NoArgumentsAllowedException
|
|||
: public tl::Exception
|
||||
{
|
||||
NoArgumentsAllowedException ()
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Method does not allow arguments")))
|
||||
: tl::Exception (tl::to_string (tr ("Method does not allow arguments")))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ struct NeedsArgumentsException
|
|||
: public tl::Exception
|
||||
{
|
||||
NeedsArgumentsException (unsigned int got, unsigned int want)
|
||||
: tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Method requires %d arguments, got %d")), want, got))
|
||||
: tl::Exception (tl::sprintf (tl::to_string (tr ("Method requires %d arguments, got %d")), want, got))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ struct IncompatibleReturnTypeException
|
|||
: public tl::Exception
|
||||
{
|
||||
IncompatibleReturnTypeException (const ArgType &got, const ArgType &want)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Incompatible return types: got '")) + got.to_string () + tl::to_string (QObject::tr ("', want '")) + want.to_string () + "'")
|
||||
: tl::Exception (tl::to_string (tr ("Incompatible return types: got '")) + got.to_string () + tl::to_string (tr ("', want '")) + want.to_string () + "'")
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,14 +64,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;
|
||||
|
|
@ -203,7 +203,7 @@ 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 {
|
||||
// delayed creation of a detached C++ object ..
|
||||
set(m_cls_decl->create (), true, false, true);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -78,7 +79,7 @@ struct GSI_PUBLIC ArglistUnderflowException
|
|||
: public tl::Exception
|
||||
{
|
||||
ArglistUnderflowException ()
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Too few arguments or no return value supplied")))
|
||||
: tl::Exception (tl::to_string (tr ("Too few arguments or no return value supplied")))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ struct GSI_PUBLIC NilPointerToReference
|
|||
: public tl::Exception
|
||||
{
|
||||
NilPointerToReference ()
|
||||
: tl::Exception (tl::to_string (QObject::tr ("nil object passed to a reference")))
|
||||
: tl::Exception (tl::to_string (tr ("nil object passed to a reference")))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -655,6 +656,8 @@ class GSI_PUBLIC_TEMPLATE StringAdaptorImpl
|
|||
{
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
/**
|
||||
* @brief Specialization for QByteArray
|
||||
*/
|
||||
|
|
@ -871,6 +874,8 @@ private:
|
|||
mutable QByteArray m_s_utf8;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Specialization for std::string
|
||||
*/
|
||||
|
|
@ -1108,6 +1113,8 @@ class GSI_PUBLIC_TEMPLATE VariantAdaptorImpl
|
|||
{
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
/**
|
||||
* @brief Specialization for QVariant
|
||||
*/
|
||||
|
|
@ -1178,6 +1185,8 @@ private:
|
|||
QVariant m_v;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Specialization for tl::Variant
|
||||
*/
|
||||
|
|
@ -1407,6 +1416,8 @@ void push_vector (std::set<X> &v, const X &x)
|
|||
v.insert (x);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
template <class X>
|
||||
void push_vector (QVector<X> &v, const X &x)
|
||||
{
|
||||
|
|
@ -1430,6 +1441,8 @@ void push_vector (QSet<X> &v, const X &x)
|
|||
v.insert (x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Implementation of the generic adaptor for a specific container
|
||||
*/
|
||||
|
|
@ -1651,6 +1664,8 @@ struct map_access
|
|||
}
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
/**
|
||||
* @brief Specialization for QMap
|
||||
*/
|
||||
|
|
@ -1705,6 +1720,8 @@ struct map_access<QHash<X, Y> >
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Implementation of the generic iterator adaptor for a specific container
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
# undef access
|
||||
#endif
|
||||
|
||||
#include <QMetaMethod>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QMetaMethod>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A signal exposure framework
|
||||
|
|
@ -229,6 +231,8 @@ public:
|
|||
// ---------------------------------------------------------------------------------------
|
||||
// Adaptors for Qt signals
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
/**
|
||||
* @brief A base class for Qt signals
|
||||
* This object will act as a connector for Qt signals: when a signal is bound, this adaptor
|
||||
|
|
@ -687,6 +691,8 @@ inline Methods qt_signal (const char *signal, const std::string &name,
|
|||
->def_arg (s1)->def_arg (s2)->def_arg (s3)->def_arg (s4)->def_arg (s5)->def_arg (s6)->def_arg (s7)->def_arg (s8)->def_arg (s9));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Adaptors for tl::event
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <set>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
#include <QString>
|
||||
#include <QStringRef>
|
||||
#include <QVariant>
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -422,11 +424,13 @@ template <> struct type_traits<__int128> : generic_type_trait
|
|||
template <> struct type_traits<double> : generic_type_traits<double_tag, double, T_double> { };
|
||||
template <> struct type_traits<float> : generic_type_traits<float_tag, float, T_float> { };
|
||||
template <> struct type_traits<std::string> : generic_type_traits<string_tag, StringAdaptor, T_string> { };
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<QString> : generic_type_traits<string_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QStringRef> : generic_type_traits<string_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QByteArray> : generic_type_traits<string_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<tl::Variant> : generic_type_traits<var_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<QVariant> : generic_type_traits<var_tag, VariantAdaptor, T_var> { };
|
||||
#endif
|
||||
template <> struct type_traits<tl::Variant> : generic_type_traits<var_tag, VariantAdaptor, T_var> { };
|
||||
|
||||
template <> struct type_traits<void *> : generic_type_traits<vptr_tag, void *, T_void_ptr> { };
|
||||
template <> struct type_traits<const void *> : generic_type_traits<vptr_tag, void *, T_void_ptr> { };
|
||||
|
|
@ -452,11 +456,13 @@ template <> struct type_traits<const __int128 &> : generic_type_trait
|
|||
template <> struct type_traits<const double &> : generic_type_traits<double_cref_tag, double, T_double> { };
|
||||
template <> struct type_traits<const float &> : generic_type_traits<float_cref_tag, float, T_float> { };
|
||||
template <> struct type_traits<const std::string &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<const QString &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const QStringRef &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const QByteArray &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const tl::Variant &> : generic_type_traits<var_cref_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const QVariant &> : generic_type_traits<var_cref_tag, VariantAdaptor, T_var> { };
|
||||
#endif
|
||||
template <> struct type_traits<const tl::Variant &> : generic_type_traits<var_cref_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const char * const &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const unsigned char * const &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const signed char * const &> : generic_type_traits<string_cref_tag, StringAdaptor, T_string> { };
|
||||
|
|
@ -479,11 +485,13 @@ template <> struct type_traits<__int128 &> : generic_type_trait
|
|||
template <> struct type_traits<double &> : generic_type_traits<double_ref_tag, double, T_double> { };
|
||||
template <> struct type_traits<float &> : generic_type_traits<float_ref_tag, float, T_float> { };
|
||||
template <> struct type_traits<std::string &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<QString &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QStringRef &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QByteArray &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<tl::Variant &> : generic_type_traits<var_ref_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<QVariant &> : generic_type_traits<var_ref_tag, VariantAdaptor, T_var> { };
|
||||
#endif
|
||||
template <> struct type_traits<tl::Variant &> : generic_type_traits<var_ref_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const char * &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const unsigned char * &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const signed char * &> : generic_type_traits<string_ref_tag, StringAdaptor, T_string> { };
|
||||
|
|
@ -507,11 +515,13 @@ template <> struct type_traits<const __int128 *> : generic_type_trait
|
|||
template <> struct type_traits<const double *> : generic_type_traits<double_cptr_tag, double, T_double> { };
|
||||
template <> struct type_traits<const float *> : generic_type_traits<float_cptr_tag, float, T_float> { };
|
||||
template <> struct type_traits<const std::string *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<const QString *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const QStringRef *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const QByteArray *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const tl::Variant *> : generic_type_traits<var_cptr_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const QVariant *> : generic_type_traits<var_cptr_tag, VariantAdaptor, T_var> { };
|
||||
#endif
|
||||
template <> struct type_traits<const tl::Variant *> : generic_type_traits<var_cptr_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const char * const *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const unsigned char * const *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const signed char * const *> : generic_type_traits<string_cptr_tag, StringAdaptor, T_string> { };
|
||||
|
|
@ -535,11 +545,13 @@ template <> struct type_traits<__int128 *> : generic_type_trait
|
|||
template <> struct type_traits<double *> : generic_type_traits<double_ptr_tag, double, T_double> { };
|
||||
template <> struct type_traits<float *> : generic_type_traits<float_ptr_tag, float, T_float> { };
|
||||
template <> struct type_traits<std::string *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<QString *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QStringRef *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<QByteArray *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<tl::Variant *> : generic_type_traits<var_ptr_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<QVariant *> : generic_type_traits<var_ptr_tag, VariantAdaptor, T_var> { };
|
||||
#endif
|
||||
template <> struct type_traits<tl::Variant *> : generic_type_traits<var_ptr_tag, VariantAdaptor, T_var> { };
|
||||
template <> struct type_traits<const char * *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const unsigned char * *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
template <> struct type_traits<const signed char * *> : generic_type_traits<string_ptr_tag, StringAdaptor, T_string> { };
|
||||
|
|
@ -615,6 +627,8 @@ struct type_traits<X * &>
|
|||
static const ClassBase *cls_decl () { return gsi::cls_decl<X> (); }
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
template <>
|
||||
struct type_traits<QStringList>
|
||||
: generic_type_traits<vector_tag, VectorAdaptor, T_vector>
|
||||
|
|
@ -755,6 +769,88 @@ struct type_traits< QVector<X> * >
|
|||
typedef X inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> >
|
||||
: generic_type_traits<map_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QHash<X, Y> & >
|
||||
: generic_type_traits<map_cref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> & >
|
||||
: generic_type_traits<map_ref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QHash<X, Y> * >
|
||||
: generic_type_traits<map_cptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> * >
|
||||
: generic_type_traits<map_ptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> >
|
||||
: generic_type_traits<map_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QMap<X, Y> & >
|
||||
: generic_type_traits<map_cref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> & >
|
||||
: generic_type_traits<map_ref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QMap<X, Y> * >
|
||||
: generic_type_traits<map_cptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> * >
|
||||
: generic_type_traits<map_ptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <class X>
|
||||
struct type_traits< std::set<X> >
|
||||
: generic_type_traits<vector_tag, VectorAdaptor, T_vector>
|
||||
|
|
@ -853,86 +949,6 @@ struct type_traits< std::list<X> * >
|
|||
typedef X inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> >
|
||||
: generic_type_traits<map_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QHash<X, Y> & >
|
||||
: generic_type_traits<map_cref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> & >
|
||||
: generic_type_traits<map_ref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QHash<X, Y> * >
|
||||
: generic_type_traits<map_cptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QHash<X, Y> * >
|
||||
: generic_type_traits<map_ptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> >
|
||||
: generic_type_traits<map_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QMap<X, Y> & >
|
||||
: generic_type_traits<map_cref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> & >
|
||||
: generic_type_traits<map_ref_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< const QMap<X, Y> * >
|
||||
: generic_type_traits<map_cptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< QMap<X, Y> * >
|
||||
: generic_type_traits<map_ptr_tag, MapAdaptor, T_map>
|
||||
{
|
||||
typedef X inner_k_type;
|
||||
typedef Y inner_type;
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
struct type_traits< std::map<X, Y> >
|
||||
: generic_type_traits<map_tag, MapAdaptor, T_map>
|
||||
|
|
@ -1696,7 +1712,7 @@ struct GSI_PUBLIC IncompatibleTypeException
|
|||
: public tl::Exception
|
||||
{
|
||||
IncompatibleTypeException (const ArgType &got, const ArgType &want)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Incompatible types: got '")) + got.to_string () + tl::to_string (QObject::tr ("', want '")) + want.to_string () + "'")
|
||||
: tl::Exception (tl::to_string (tr ("Incompatible types: got '")) + got.to_string () + tl::to_string (tr ("', want '")) + want.to_string () + "'")
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ X::X ()
|
|||
}
|
||||
|
||||
X::X (const char *x)
|
||||
: m_s (QString::fromUtf8(x))
|
||||
: m_s (x)
|
||||
{
|
||||
++s_xinst;
|
||||
}
|
||||
|
|
@ -467,24 +467,24 @@ std::vector<X *> X::vx_ptr ()
|
|||
return r;
|
||||
}
|
||||
|
||||
QString X::cls_name () const
|
||||
std::string X::cls_name () const
|
||||
{
|
||||
return QString::fromUtf8 ("X");
|
||||
return "X";
|
||||
}
|
||||
|
||||
QString X::s () const
|
||||
std::string X::s () const
|
||||
{
|
||||
return m_s;
|
||||
}
|
||||
|
||||
void X::set_s (const QString &s)
|
||||
void X::set_s (const std::string &s)
|
||||
{
|
||||
m_s = s;
|
||||
}
|
||||
|
||||
void X::set_si (int v)
|
||||
{
|
||||
m_s = QString::number (v + 1);
|
||||
m_s = tl::to_string (v + 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -594,9 +594,9 @@ std::vector<Y *> Y::vy_ptr()
|
|||
return r;
|
||||
}
|
||||
|
||||
QString Y::cls_name() const
|
||||
std::string Y::cls_name() const
|
||||
{
|
||||
return QString::fromUtf8 ("Y");
|
||||
return "Y";
|
||||
}
|
||||
|
||||
int Y::i () const
|
||||
|
|
@ -619,9 +619,9 @@ YY::YY (const char *x)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QString YY::cls_name() const
|
||||
std::string YY::cls_name() const
|
||||
{
|
||||
return QString::fromUtf8 ("YY");
|
||||
return "YY";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -700,6 +700,8 @@ std::string Z_P::f_with_yy (const std::string &s)
|
|||
// ----------------------------------------------------------------
|
||||
// Implementation of SQ
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
SQ::SQ ()
|
||||
: m_tag (0)
|
||||
{
|
||||
|
|
@ -726,6 +728,8 @@ void SQ::trigger_s2 (const QString &s)
|
|||
emit s2 (s, this);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Implementation of SE
|
||||
|
||||
|
|
@ -750,7 +754,7 @@ void SE::trigger_s1 (int x)
|
|||
s1 (x);
|
||||
}
|
||||
|
||||
void SE::trigger_s2 (const QString &s)
|
||||
void SE::trigger_s2 (const std::string &s)
|
||||
{
|
||||
s2 (s, this);
|
||||
}
|
||||
|
|
@ -764,7 +768,9 @@ static gsi::Enum<Enum> decl_enum ("", "Enum",
|
|||
gsi::enum_const ("c", Enum_c)
|
||||
);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
static gsi::QFlagsClass<Enum> decl_qflags_enum ("", "Enums");
|
||||
#endif
|
||||
|
||||
static gsi::Class<A> decl_a ("", "A",
|
||||
gsi::constructor ("new_a|new", &a_ctor) +
|
||||
|
|
@ -781,6 +787,7 @@ static gsi::Class<A> decl_a ("", "A",
|
|||
gsi::method ("set_ecref", &A::set_ecref) +
|
||||
gsi::method ("mod_eptr", &A::mod_eptr) +
|
||||
gsi::method ("mod_eref", &A::mod_eref) +
|
||||
#if defined(HAVE_QT)
|
||||
gsi::method ("get_ef", &A::get_ef) +
|
||||
gsi::method ("get_efptr", &A::get_efptr) +
|
||||
gsi::method ("get_efcptr", &A::get_efcptr) +
|
||||
|
|
@ -793,6 +800,7 @@ static gsi::Class<A> decl_a ("", "A",
|
|||
gsi::method ("set_efcref", &A::set_efcref) +
|
||||
gsi::method ("mod_efptr", &A::mod_efptr) +
|
||||
gsi::method ("mod_efref", &A::mod_efref) +
|
||||
#endif
|
||||
gsi::method ("push_ev", &A::push_ev) +
|
||||
gsi::method ("ev", &A::ev) +
|
||||
gsi::method ("af=", &A::set_af) +
|
||||
|
|
@ -805,15 +813,19 @@ static gsi::Class<A> decl_a ("", "A",
|
|||
gsi::method ("a1c", &A::a1c) +
|
||||
gsi::method ("a2", &A::a2) +
|
||||
gsi::method ("a3", &A::a3) +
|
||||
#if defined(HAVE_QT)
|
||||
gsi::method ("a3_qba", &A::a3_qba) +
|
||||
gsi::method ("a3_qstr", &A::a3_qstr) +
|
||||
gsi::method ("a3_qstrref", &A::a3_qstrref) +
|
||||
#endif
|
||||
gsi::method ("a4", &A::a4) +
|
||||
gsi::method ("a5|n=", &A::a5) +
|
||||
gsi::method ("a10_d", &A::a10_d) +
|
||||
#if defined(HAVE_QT)
|
||||
gsi::method ("a10_d_qba", &A::a10_d_qba) +
|
||||
gsi::method ("a10_d_qstr", &A::a10_d_qstr) +
|
||||
gsi::method ("a10_d_qstrref", &A::a10_d_qstrref) +
|
||||
#endif
|
||||
gsi::method ("*a10_prot", &A::a10_d) +
|
||||
gsi::method ("a10_f", &A::a10_f) +
|
||||
gsi::method ("a10_fptr", &A::a10_fptr) +
|
||||
|
|
@ -1006,7 +1018,9 @@ static gsi::Class<B> decl_b ("", "B",
|
|||
gsi::method ("set_ls", &B::set_ls) +
|
||||
gsi::method ("push_ss", &B::push_ss) +
|
||||
gsi::method ("ss", &B::ss) +
|
||||
gsi::method ("set_ss", &B::set_ss) +
|
||||
gsi::method ("set_ss", &B::set_ss)
|
||||
#if defined(HAVE_QT)
|
||||
+
|
||||
gsi::method ("push_qls", &B::push_qls) +
|
||||
gsi::method ("qls", &B::qls) +
|
||||
gsi::method ("set_qls", &B::set_qls) +
|
||||
|
|
@ -1028,6 +1042,7 @@ static gsi::Class<B> decl_b ("", "B",
|
|||
gsi::method ("insert_qhash_is", &B::insert_qhash_is) +
|
||||
gsi::method ("qhash_is", &B::qhash_is) +
|
||||
gsi::method ("set_qhash_is", &B::set_qhash_is)
|
||||
#endif
|
||||
);
|
||||
|
||||
// extending B
|
||||
|
|
@ -1153,6 +1168,7 @@ gsi::Class<Z_P> decl_z ("", "Z",
|
|||
gsi::method ("set_x_keep", &Z_P::set_x_keep)
|
||||
);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
gsi::Class<SQ> decl_sq ("", "SQ",
|
||||
gsi::method ("trigger_s0", &SQ::trigger_s0) +
|
||||
gsi::method ("trigger_s1", &SQ::trigger_s1) +
|
||||
|
|
@ -1163,6 +1179,7 @@ gsi::Class<SQ> decl_sq ("", "SQ",
|
|||
gsi::qt_signal<int> ("s1(int)", "s1") +
|
||||
gsi::qt_signal<const QString &, SQ *> ("s2(const QString &, SQ *)", "s2")
|
||||
);
|
||||
#endif
|
||||
|
||||
gsi::Class<SE> decl_se ("", "SE",
|
||||
gsi::method ("trigger_s0", &SE::trigger_s0) +
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@
|
|||
#include "tlVariant.h"
|
||||
#include "tlString.h"
|
||||
|
||||
#include <QObject>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QObject>
|
||||
#endif
|
||||
|
||||
namespace gsi_test
|
||||
{
|
||||
|
|
@ -113,6 +115,7 @@ struct A
|
|||
int a3 (const std::string &x) {
|
||||
return x.size ();
|
||||
}
|
||||
#if defined(HAVE_QT)
|
||||
int a3_qstr (const QString &x) {
|
||||
return x.size ();
|
||||
}
|
||||
|
|
@ -122,6 +125,7 @@ struct A
|
|||
int a3_qba (const QByteArray &x) {
|
||||
return x.size ();
|
||||
}
|
||||
#endif
|
||||
double a4 (const std::vector<double> &d) {
|
||||
m_d = d;
|
||||
return d.back ();
|
||||
|
|
@ -152,9 +156,11 @@ struct A
|
|||
int a9b (bool f) const { return f ? 5 : -5; }
|
||||
|
||||
std::string a10_d (double f) { return tl::to_string (f); }
|
||||
#if defined(HAVE_QT)
|
||||
QByteArray a10_d_qba (double f) { return tl::to_qstring (tl::to_string (f)).toUtf8 (); }
|
||||
QString a10_d_qstr (double f) { return tl::to_qstring (tl::to_string (f)); }
|
||||
QStringRef a10_d_qstrref (double f) { m_s = tl::to_qstring (tl::to_string (f)); return QStringRef (&m_s); }
|
||||
#endif
|
||||
std::string a10_f (float f) { return tl::to_string(f); }
|
||||
std::string a10_fptr (float *f) { if (f) { *f += 5; return tl::to_string(*f); } else { return "nil"; } }
|
||||
std::string a10_dptr (double *f) { if (f) { *f += 6; return tl::to_string(*f); } else { return "nil"; } }
|
||||
|
|
@ -212,6 +218,7 @@ struct A
|
|||
void push_ev (Enum e) { ee.push_back (e); }
|
||||
const std::vector<Enum> &ev () const { return ee; }
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
QFlags<Enum> get_ef () const { return ef; }
|
||||
QFlags<Enum> *get_efptr () { return int (ef) == 0 ? 0 : &ef; }
|
||||
const QFlags<Enum> *get_efcptr () const { return int (ef) == 0 ? 0 : &ef; }
|
||||
|
|
@ -224,6 +231,7 @@ struct A
|
|||
void set_efcref (const QFlags<Enum> &_ef) { ef = _ef; }
|
||||
void mod_efptr (QFlags<Enum> *_ef, Enum ee) { if (_ef) *_ef |= ee; }
|
||||
void mod_efref (QFlags<Enum> &_ef, Enum ee) { _ef |= ee; }
|
||||
#endif
|
||||
|
||||
const char *a_vp1 (void *s) { return (const char *)s; }
|
||||
void *a_vp2 () { return (void *)"abc"; }
|
||||
|
|
@ -238,9 +246,13 @@ struct A
|
|||
int n;
|
||||
bool f;
|
||||
Enum e;
|
||||
#if defined(HAVE_QT)
|
||||
QFlags<Enum> ef;
|
||||
#endif
|
||||
std::vector<Enum> ee;
|
||||
#if defined(HAVE_QT)
|
||||
QString m_s;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -774,6 +786,7 @@ struct B
|
|||
std::set<std::string> ss () { return m_ss; }
|
||||
void set_ss (std::set<std::string> v) { m_ss = v; }
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
static void push_qls (QList<QString> &m, const QString &v) { m.push_back (v); }
|
||||
QList<QString> qls () { return m_qls; }
|
||||
void set_qls (QList<QString> v) { m_qls = v; }
|
||||
|
|
@ -801,6 +814,7 @@ struct B
|
|||
static void insert_qhash_is (QHash<int, QString> &m, int k, const QString &v) { m.insert (k, v); }
|
||||
QHash<int, QString> qhash_is () { return m_qhash_is; }
|
||||
void set_qhash_is (QHash<int, QString> v) { m_qhash_is = v; }
|
||||
#endif
|
||||
|
||||
std::string m;
|
||||
A a;
|
||||
|
|
@ -819,6 +833,7 @@ struct B
|
|||
std::vector<std::vector<std::string> > m_vvs;
|
||||
std::list<std::string> m_ls;
|
||||
std::set<std::string> m_ss;
|
||||
#if defined_HAVE_QT
|
||||
QList<QString> m_qls;
|
||||
QList<QVariant> m_qlv;
|
||||
QStringList m_qsl;
|
||||
|
|
@ -826,6 +841,7 @@ struct B
|
|||
QSet<QString> m_qss;
|
||||
QMap<int, QString> m_qmap_is;
|
||||
QHash<int, QString> m_qhash_is;
|
||||
#endif
|
||||
|
||||
static B *b_inst;
|
||||
};
|
||||
|
|
@ -950,13 +966,13 @@ public:
|
|||
static std::vector<const X *> vx_cptr ();
|
||||
static std::vector<X *> vx_ptr ();
|
||||
|
||||
virtual QString cls_name () const;
|
||||
QString s () const;
|
||||
void set_s (const QString &s);
|
||||
virtual std::string cls_name () const;
|
||||
std::string s () const;
|
||||
void set_s (const std::string &s);
|
||||
void set_si (int v);
|
||||
|
||||
protected:
|
||||
QString m_s;
|
||||
std::string m_s;
|
||||
|
||||
private:
|
||||
static std::auto_ptr<X> sp_a, sp_b;
|
||||
|
|
@ -984,7 +1000,7 @@ public:
|
|||
static std::vector<const Y *> vy_cptr ();
|
||||
static std::vector<Y *> vy0_ptr ();
|
||||
static std::vector<Y *> vy_ptr ();
|
||||
virtual QString cls_name () const;
|
||||
virtual std::string cls_name () const;
|
||||
int i () const;
|
||||
|
||||
private:
|
||||
|
|
@ -1018,7 +1034,7 @@ class YY : public Y
|
|||
public:
|
||||
YY ();
|
||||
YY (const char *x);
|
||||
virtual QString cls_name() const;
|
||||
virtual std::string cls_name() const;
|
||||
};
|
||||
|
||||
class Z
|
||||
|
|
@ -1097,6 +1113,7 @@ public:
|
|||
gsi::Callback f_cb;
|
||||
};
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
class SQ
|
||||
: public QObject
|
||||
{
|
||||
|
|
@ -1122,6 +1139,7 @@ signals:
|
|||
private:
|
||||
int m_tag;
|
||||
};
|
||||
#endif
|
||||
|
||||
class SE
|
||||
: public tl::Object
|
||||
|
|
@ -1131,7 +1149,7 @@ public:
|
|||
|
||||
void trigger_s0 ();
|
||||
void trigger_s1 (int x);
|
||||
void trigger_s2 (const QString &s);
|
||||
void trigger_s2 (const std::string &s);
|
||||
|
||||
void set_tag (int x);
|
||||
int tag () const
|
||||
|
|
@ -1142,7 +1160,7 @@ public:
|
|||
public:
|
||||
tl::event<> s0;
|
||||
tl::event<int> s1;
|
||||
tl::event<const QString &, SE *> s2;
|
||||
tl::event<const std::string &, SE *> s2;
|
||||
|
||||
private:
|
||||
int m_tag;
|
||||
|
|
@ -1155,9 +1173,11 @@ namespace tl
|
|||
template <> struct type_traits<gsi_test::A_NC> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<gsi_test::SQ> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -68,16 +68,26 @@ QMAKE_CXXFLAGS_WARN_ON += \
|
|||
-Wno-deprecated-declarations \
|
||||
-Wno-reserved-user-defined-literal \
|
||||
|
||||
QT += network xml sql
|
||||
equals(HAVE_QT, "0") {
|
||||
|
||||
QT =
|
||||
|
||||
equals(HAVE_QT5, "1") {
|
||||
QT += designer printsupport
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
QT += multimedia multimediawidgets xmlpatterns svg gui
|
||||
}
|
||||
} else {
|
||||
# questionable: use uitools instead?
|
||||
CONFIG += designer
|
||||
|
||||
DEFINES += HAVE_QT
|
||||
DEFINES += HAVE_XML
|
||||
QT += network xml sql
|
||||
|
||||
equals(HAVE_QT5, "1") {
|
||||
QT += designer printsupport
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
QT += multimedia multimediawidgets xmlpatterns svg gui
|
||||
}
|
||||
} else {
|
||||
# questionable: use uitools instead?
|
||||
CONFIG += designer
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# only support the required symbols for shared object load performance
|
||||
|
|
|
|||
|
|
@ -784,6 +784,7 @@ Class<rdb::Item> decl_RdbItem ("rdb", "RdbItem",
|
|||
"@args tags\n"
|
||||
"@param tags A comma-separated list of tags\n"
|
||||
) +
|
||||
#if defined(HAVE_QT)
|
||||
gsi::method ("image_str", &rdb::Item::image_str,
|
||||
"@brief Gets the image associated with this item as a string\n"
|
||||
"@return A base64-encoded image file (usually in PNG format)\n"
|
||||
|
|
@ -793,6 +794,7 @@ Class<rdb::Item> decl_RdbItem ("rdb", "RdbItem",
|
|||
"@args image\n"
|
||||
"@param image A base64-encoded image file (preferably in PNG format)\n"
|
||||
) +
|
||||
#endif
|
||||
/* Not supported yet:
|
||||
gsi::method ("multiplicity", &rdb::Item::multiplicity,
|
||||
"@brief Gets the item's multiplicity\n"
|
||||
|
|
@ -1061,10 +1063,10 @@ void create_items_from_edge_pair_array (rdb::Database *db, rdb::id_type cell_id,
|
|||
static rdb::Item *create_item (rdb::Database *db, rdb::id_type cell_id, rdb::id_type cat_id)
|
||||
{
|
||||
if (! db->cell_by_id (cell_id)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cell ID: %1").arg (cell_id)));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Not a valid cell ID: %d")), cell_id));
|
||||
}
|
||||
if (! db->category_by_id (cat_id)) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid category ID: %1").arg (cat_id)));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Not a valid category ID: %d")), cat_id));
|
||||
}
|
||||
return db->create_item (cell_id, cat_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,11 @@
|
|||
#include "dbText.h"
|
||||
#include "dbShape.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QByteArray>
|
||||
#include <QBuffer>
|
||||
#include <QImage>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QByteArray>
|
||||
# include <QBuffer>
|
||||
# include <QImage>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
|
@ -247,7 +248,7 @@ ValueBase::create_from_string (tl::Extractor &ex)
|
|||
return new Value <double> (v);
|
||||
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid value string at '...%s'")), ex.skip ());
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid value string at '...%s'")), ex.skip ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -542,7 +543,7 @@ Reference::set_parent_cell_qname (const std::string &qname)
|
|||
tl_assert (mp_database != 0);
|
||||
const Cell *cell = mp_database->cell_by_qname (qname);
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("%s is not a valid cell name or name/variant combination")), qname);
|
||||
throw tl::Exception (tl::to_string (tr ("%s is not a valid cell name or name/variant combination")), qname);
|
||||
}
|
||||
m_parent_cell_id = cell->id ();
|
||||
}
|
||||
|
|
@ -783,26 +784,26 @@ Tags::has_tag (const std::string &name, bool user_tag) const
|
|||
// Item implementation
|
||||
|
||||
Item::Item (Items *items)
|
||||
: m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (items->database ()), mp_image (0)
|
||||
: m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (items->database ())
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
Item::Item ()
|
||||
: m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (0), mp_image (0)
|
||||
: m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
Item::Item (const Item &d)
|
||||
: tl::Object (d), m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (d.mp_database), mp_image (0)
|
||||
: tl::Object (d), m_cell_id (0), m_category_id (0), m_multiplicity (1), m_visited (false), mp_database (d.mp_database)
|
||||
{
|
||||
operator= (d);
|
||||
}
|
||||
|
||||
Item::~Item ()
|
||||
{
|
||||
set_image (0);
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
Item &Item::operator= (const Item &d)
|
||||
|
|
@ -815,13 +816,14 @@ Item &Item::operator= (const Item &d)
|
|||
m_multiplicity = d.m_multiplicity;
|
||||
m_tag_ids = d.m_tag_ids;
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
if (mp_image) {
|
||||
delete mp_image;
|
||||
mp_image = 0;
|
||||
mp_image.reset (0);
|
||||
}
|
||||
if (d.mp_image) {
|
||||
mp_image = new QImage (*d.mp_image);
|
||||
if (d.mp_image.get ()) {
|
||||
mp_image.reset (new QImage (*d.mp_image));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
|
@ -871,7 +873,7 @@ Item::set_cell_qname (const std::string &qname)
|
|||
tl_assert (mp_database != 0);
|
||||
const Cell *cell = mp_database->cell_by_qname (qname);
|
||||
if (! cell) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("%s is not a valid cell name or name/variant combination")), qname);
|
||||
throw tl::Exception (tl::to_string (tr ("%s is not a valid cell name or name/variant combination")), qname);
|
||||
}
|
||||
m_cell_id = cell->id ();
|
||||
}
|
||||
|
|
@ -891,7 +893,7 @@ Item::set_category_name (const std::string &path)
|
|||
tl_assert (mp_database != 0);
|
||||
const Category *category = mp_database->categories ().category_by_name (path.c_str ());
|
||||
if (! category) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("%s is not a valid category path")), path);
|
||||
throw tl::Exception (tl::to_string (tr ("%s is not a valid category path")), path);
|
||||
}
|
||||
m_category_id = category->id ();
|
||||
}
|
||||
|
|
@ -942,22 +944,17 @@ Item::set_tag_str (const std::string &tags)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
void
|
||||
Item::set_image (QImage *image)
|
||||
{
|
||||
if (mp_image) {
|
||||
delete mp_image;
|
||||
mp_image = 0;
|
||||
}
|
||||
if (image) {
|
||||
mp_image = image;
|
||||
}
|
||||
mp_image.reset (image);
|
||||
}
|
||||
|
||||
std::string
|
||||
Item::image_str () const
|
||||
{
|
||||
if (! mp_image) {
|
||||
if (! mp_image.get ()) {
|
||||
return std::string ();
|
||||
} else {
|
||||
|
||||
|
|
@ -989,6 +986,7 @@ Item::set_image_str (const std::string &s)
|
|||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Database implementation
|
||||
|
|
@ -1318,12 +1316,14 @@ Database::remove_item_tag (const Item *item, id_type tag)
|
|||
const_cast <Item *> (item)->remove_tag (tag);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
void
|
||||
Database::set_item_image (const Item *item, QImage *image)
|
||||
{
|
||||
set_modified ();
|
||||
const_cast <Item *> (item)->set_image (image);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Database::set_item_multiplicity (const Item *item, size_t n)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@
|
|||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
class QImage;
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -928,6 +930,7 @@ public:
|
|||
*/
|
||||
void set_tag_str (const std::string &tags);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
/**
|
||||
* @brief Get the image object attached to this item
|
||||
*
|
||||
|
|
@ -957,6 +960,7 @@ public:
|
|||
* If the image string is not valid, the image will also be cleared.
|
||||
*/
|
||||
void set_image_str (const std::string &s);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the database reference
|
||||
|
|
@ -985,7 +989,9 @@ private:
|
|||
bool m_visited;
|
||||
std::vector <bool> m_tag_ids;
|
||||
Database *mp_database;
|
||||
QImage *mp_image;
|
||||
#if defined(HAVE_QT)
|
||||
std::auto_ptr<QImage> mp_image;
|
||||
#endif
|
||||
|
||||
Item ();
|
||||
|
||||
|
|
@ -2207,10 +2213,12 @@ public:
|
|||
*/
|
||||
void remove_item_tag (const Item *item, id_type tag);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
/**
|
||||
* @brief Set the image of an item
|
||||
*/
|
||||
void set_item_image (const Item *item, QImage *image);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set the multiplicity of an item
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <QXmlInputSource>
|
||||
|
||||
namespace rdb
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class RVEReaderException
|
|||
{
|
||||
public:
|
||||
RVEReaderException (const std::string &msg, size_t line)
|
||||
: ReaderException (tl::sprintf (tl::to_string (QObject::tr ("%s (line=%lu)")), msg, line))
|
||||
: ReaderException (tl::sprintf (tl::to_string (tr ("%s (line=%lu)")), msg, line))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -53,9 +53,9 @@ class RVEReader
|
|||
public:
|
||||
RVEReader (tl::InputStream &stream)
|
||||
: m_input_stream (stream),
|
||||
m_progress (tl::to_string (QObject::tr ("Reading RVE DB")), 10000)
|
||||
m_progress (tl::to_string (tr ("Reading RVE DB")), 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);
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ public:
|
|||
ex.read (res);
|
||||
|
||||
if (res < 0.001 || res > 1e6) {
|
||||
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid resolution value: %g")), res));
|
||||
error (tl::sprintf (tl::to_string (tr ("Invalid resolution value: %g")), res));
|
||||
}
|
||||
|
||||
dbu = 1.0 / res;
|
||||
|
|
@ -128,7 +128,7 @@ public:
|
|||
cat_name.clear ();
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Unexpected end of file")));
|
||||
error (tl::to_string (tr ("Unexpected end of file")));
|
||||
}
|
||||
|
||||
ex = tl::Extractor (m_input_stream.get_line ().c_str ());
|
||||
|
|
@ -143,7 +143,7 @@ public:
|
|||
for (size_t i = 0; i < n3; ++i) {
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Unexpected end of file")));
|
||||
error (tl::to_string (tr ("Unexpected end of file")));
|
||||
}
|
||||
|
||||
std::string l = m_input_stream.get_line ();
|
||||
|
|
@ -179,7 +179,7 @@ public:
|
|||
// TODO: add waiver string somehow ...
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
warn (tl::to_string (QObject::tr ("Unexpected end of file before the specified number of shapes was read - stopping.")));
|
||||
warn (tl::to_string (tr ("Unexpected end of file before the specified number of shapes was read - stopping.")));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ public:
|
|||
ex = tl::Extractor (s.c_str ());
|
||||
const char *start = ex.skip ();
|
||||
if (! *start) {
|
||||
warn (tl::to_string (QObject::tr ("Unexpected end of file before the specified number of shapes was read - stopping.")));
|
||||
warn (tl::to_string (tr ("Unexpected end of file before the specified number of shapes was read - stopping.")));
|
||||
} else {
|
||||
const char *end = start + strlen (start);
|
||||
while (end > start && isspace (end [-1])) {
|
||||
|
|
@ -214,7 +214,7 @@ public:
|
|||
--end;
|
||||
}
|
||||
cat_name = std::string (start, end - start);
|
||||
warn (tl::to_string (QObject::tr ("Obviously reaching end of shapes list before the specified number of shapes was read - parsing next category.")));
|
||||
warn (tl::to_string (tr ("Obviously reaching end of shapes list before the specified number of shapes was read - parsing next category.")));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ public:
|
|||
while (true) {
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Unexpected end of file")));
|
||||
error (tl::to_string (tr ("Unexpected end of file")));
|
||||
}
|
||||
|
||||
ex = tl::Extractor (m_input_stream.get_line ().c_str ());
|
||||
|
|
@ -341,7 +341,7 @@ public:
|
|||
if (point > 0) {
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Unexpected end of file")));
|
||||
error (tl::to_string (tr ("Unexpected end of file")));
|
||||
}
|
||||
|
||||
ex = tl::Extractor (m_input_stream.get_line ().c_str ());
|
||||
|
|
@ -369,7 +369,7 @@ public:
|
|||
if (point > 0) {
|
||||
|
||||
if (m_input_stream.at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Unexpected end of file")));
|
||||
error (tl::to_string (tr ("Unexpected end of file")));
|
||||
}
|
||||
|
||||
ex = tl::Extractor (m_input_stream.get_line ().c_str ());
|
||||
|
|
@ -400,7 +400,7 @@ public:
|
|||
}
|
||||
|
||||
} else {
|
||||
error (tl::sprintf (tl::to_string (QObject::tr ("Invalid shape type: %c")), shape_type));
|
||||
error (tl::sprintf (tl::to_string (tr ("Invalid shape type: %c")), shape_type));
|
||||
}
|
||||
|
||||
Item *item = db.create_item (cell->id (), cath->id ());
|
||||
|
|
@ -427,7 +427,7 @@ private:
|
|||
|
||||
void warn (const std::string &msg)
|
||||
{
|
||||
tl::warn << tl::sprintf (tl::to_string (QObject::tr ("%s (line=%lu)")), msg, m_input_stream.line_number ());
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("%s (line=%lu)")), msg, m_input_stream.line_number ());
|
||||
}
|
||||
|
||||
void error (const std::string &msg)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ Reader::Reader (tl::InputStream &stream)
|
|||
}
|
||||
|
||||
if (! mp_actual_reader) {
|
||||
throw rdb::ReaderException (tl::to_string (QObject::tr ("Marker database has unknown format")));
|
||||
throw rdb::ReaderException (tl::to_string (tr ("Marker database has unknown format")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ SOURCES = \
|
|||
tlAssert.cc \
|
||||
tlClassRegistry.cc \
|
||||
tlDataMapping.cc \
|
||||
tlDeferredExecution.cc \
|
||||
tlDeflate.cc \
|
||||
tlException.cc \
|
||||
tlExceptions.cc \
|
||||
|
|
@ -38,27 +37,21 @@ SOURCES = \
|
|||
tlStaticObjects.cc \
|
||||
tlStream.cc \
|
||||
tlString.cc \
|
||||
tlThreadedWorkers.cc \
|
||||
tlTimer.cc \
|
||||
tlVariant.cc \
|
||||
tlXMLParser.cc \
|
||||
tlXMLWriter.cc \
|
||||
tlFileSystemWatcher.cc \
|
||||
tlFileUtils.cc \
|
||||
tlWebDAV.cc \
|
||||
tlArch.cc \
|
||||
tlCommandLineParser.cc \
|
||||
tlUnitTest.cc \
|
||||
tlInt128Support.cc \
|
||||
tlHttpStreamCurl.cc \
|
||||
tlHttpStreamQt.cc
|
||||
tlThreadedWorkers.cc \
|
||||
tlThreads.cc
|
||||
|
||||
HEADERS = \
|
||||
tlAlgorithm.h \
|
||||
tlAssert.h \
|
||||
tlClassRegistry.h \
|
||||
tlDataMapping.h \
|
||||
tlDeferredExecution.h \
|
||||
tlDeflate.h \
|
||||
tlException.h \
|
||||
tlExceptions.h \
|
||||
|
|
@ -82,28 +75,65 @@ HEADERS = \
|
|||
tlStaticObjects.h \
|
||||
tlStream.h \
|
||||
tlString.h \
|
||||
tlThreadedWorkers.h \
|
||||
tlTimer.h \
|
||||
tlTypeTraits.h \
|
||||
tlUtils.h \
|
||||
tlVariant.h \
|
||||
tlVariantUserClasses.h \
|
||||
tlVector.h \
|
||||
tlXMLParser.h \
|
||||
tlXMLWriter.h \
|
||||
tlFileSystemWatcher.h \
|
||||
tlCommon.h \
|
||||
tlMath.h \
|
||||
tlCpp.h \
|
||||
tlFileUtils.h \
|
||||
tlWebDAV.h \
|
||||
tlArch.h \
|
||||
tlCommandLineParser.h \
|
||||
tlUnitTest.h \
|
||||
tlInt128Support.h \
|
||||
tlHttpStreamCurl.h \
|
||||
tlDefs.h \
|
||||
tlThreadedWorkers.h \
|
||||
tlThreads.h
|
||||
|
||||
equals(HAVE_CURL, "1") {
|
||||
|
||||
SOURCES += \
|
||||
tlHttpStreamCurl.cc \
|
||||
|
||||
} else {
|
||||
|
||||
equals(HAVE_QT, "0") {
|
||||
# no HTTP stream available
|
||||
} else {
|
||||
|
||||
SOURCES += \
|
||||
tlHttpStreamQt.cc \
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
equals(HAVE_QT, "0") {
|
||||
|
||||
# nothing
|
||||
|
||||
} else {
|
||||
|
||||
HEADERS += \
|
||||
tlWebDAV.h \
|
||||
tlDeferredExecution.h \
|
||||
tlXMLParser.h \
|
||||
tlXMLWriter.h \
|
||||
tlFileSystemWatcher.h \
|
||||
tlHttpStreamQt.h \
|
||||
tlDefs.h
|
||||
|
||||
SOURCES += \
|
||||
tlWebDAV.cc \
|
||||
tlDeferredExecution.cc \
|
||||
tlXMLParser.cc \
|
||||
tlXMLWriter.cc \
|
||||
tlFileSystemWatcher.cc \
|
||||
|
||||
}
|
||||
|
||||
INCLUDEPATH =
|
||||
DEPENDPATH =
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
#include "tlLog.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -463,7 +462,7 @@ CommandLineOptions::produce_version ()
|
|||
void
|
||||
CommandLineOptions::parse (int argc, char *argv[])
|
||||
{
|
||||
m_program_name = tl::to_string (QFileInfo (QString::fromLocal8Bit (argv [0])).fileName ());
|
||||
m_program_name = tl::filename (tl::to_string_from_local (argv [0]));
|
||||
|
||||
std::vector<ArgBase *> plain_args;
|
||||
std::map<std::string, ArgBase *> arg_by_short_option, arg_by_long_option;
|
||||
|
|
@ -493,7 +492,7 @@ CommandLineOptions::parse (int argc, char *argv[])
|
|||
|
||||
ArgBase *arg = 0;
|
||||
|
||||
std::string arg_as_utf8 = tl::to_string (QString::fromLocal8Bit (argv [i]));
|
||||
std::string arg_as_utf8 = tl::to_string_from_local (argv [i]);
|
||||
tl::Extractor ex (arg_as_utf8.c_str ());
|
||||
|
||||
if (ex.test ("--")) {
|
||||
|
|
@ -502,7 +501,7 @@ CommandLineOptions::parse (int argc, char *argv[])
|
|||
ex.read_word (n, "_-");
|
||||
std::map<std::string, ArgBase *>::const_iterator a = arg_by_long_option.find (n);
|
||||
if (a == arg_by_long_option.end ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown command line option --%1 (use -h for help)").arg (tl::to_qstring (n))));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unknown command line option --%1 (use -h for help)")), n));
|
||||
}
|
||||
arg = a->second;
|
||||
|
||||
|
|
@ -512,14 +511,14 @@ CommandLineOptions::parse (int argc, char *argv[])
|
|||
ex.read_word (n);
|
||||
std::map<std::string, ArgBase *>::const_iterator a = arg_by_short_option.find (n);
|
||||
if (a == arg_by_short_option.end ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown command line option --%1 (use -h for help)").arg (tl::to_qstring (n))));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unknown command line option --%1 (use -h for help)")), n));
|
||||
}
|
||||
arg = a->second;
|
||||
|
||||
} else {
|
||||
|
||||
if (next_plain_arg == plain_args.end ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown command line component %1 - no further plain argument expected (use -h for help)").arg (tl::to_qstring (arg_as_utf8))));
|
||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("Unknown command line component %1 - no further plain argument expected (use -h for help)")), arg_as_utf8));
|
||||
}
|
||||
|
||||
arg = *next_plain_arg;
|
||||
|
|
@ -544,10 +543,10 @@ CommandLineOptions::parse (int argc, char *argv[])
|
|||
ex.expect_end ();
|
||||
++i;
|
||||
if (i == argc) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Value missing")));
|
||||
throw tl::Exception (tl::to_string (tr ("Value missing")));
|
||||
}
|
||||
|
||||
std::string arg_as_utf8 = tl::to_string (QString::fromLocal8Bit (argv [i]));
|
||||
std::string arg_as_utf8 = tl::to_string_from_local (argv [i]);
|
||||
tl::Extractor ex_value (arg_as_utf8);
|
||||
arg->take_value (ex_value);
|
||||
|
||||
|
|
@ -589,7 +588,7 @@ CommandLineOptions::parse (int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (next_plain_arg != plain_args.end () && !(*next_plain_arg)->option ().optional) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Additional arguments required (use -h for help)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Additional arguments required (use -h for help)")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
#include "tlCommon.h"
|
||||
#include "tlLog.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#include "tlDeferredExecution.h"
|
||||
#include "tlAssert.h"
|
||||
#include "tlLog.h"
|
||||
|
|
@ -159,4 +158,3 @@ DeferredMethodScheduler::do_execute ()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef HDR_tlDeferredExecution
|
||||
#define HDR_tlDeferredExecution
|
||||
|
||||
#if !defined(HAVE_QT)
|
||||
# error tl::DeferredExecution not available without Qt
|
||||
#endif
|
||||
|
||||
#include "tlCommon.h"
|
||||
#include "tlObject.h"
|
||||
|
||||
|
|
@ -268,7 +270,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ InflateFilter::get (size_t n)
|
|||
|
||||
while ((m_b_insert + sizeof (m_buffer) - m_b_read) % sizeof (m_buffer) < n) {
|
||||
if (! process ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unexpected end of file (DEFLATE implementation)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Unexpected end of file (DEFLATE implementation)")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ InflateFilter::process ()
|
|||
}
|
||||
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid compression type: %d")), t);
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid compression type: %d")), t);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public:
|
|||
m_mask = 0;
|
||||
const char *c = mp_input->get (1, true /*bypass_deflate*/);
|
||||
if (c == 0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unexpected end of file (DEFLATE implementation)")));
|
||||
throw tl::Exception (tl::to_string (tr ("Unexpected end of file (DEFLATE implementation)")));
|
||||
}
|
||||
return *c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ struct TL_PUBLIC CancelException
|
|||
: public Exception
|
||||
{
|
||||
CancelException ()
|
||||
: Exception (tl::to_string (QObject::tr ("Operation cancelled")))
|
||||
: Exception (tl::to_string (tr ("Operation cancelled")))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ struct TL_PUBLIC InternalException
|
|||
: public Exception
|
||||
{
|
||||
InternalException (const char *file, int line, const char *cond)
|
||||
: Exception (tl::to_string (QObject::tr ("Internal error: %s:%d %s was not true")).c_str (), file, line, cond)
|
||||
: Exception (tl::to_string (tr ("Internal error: %s:%d %s was not true")).c_str (), file, line, cond)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
|
|
@ -54,9 +52,9 @@ void handle_exception_silent (const tl::Exception &ex)
|
|||
if (script_error) {
|
||||
if (script_error->line () > 0) {
|
||||
tl::error << script_error->sourcefile () << ":" << script_error->line () << ": "
|
||||
<< script_error->msg () << tl::to_string (QObject::tr (" (class ")) << script_error->cls () << ")";
|
||||
<< script_error->msg () << tl::to_string (tr (" (class ")) << script_error->cls () << ")";
|
||||
} else {
|
||||
tl::error << script_error->msg () << tl::to_string (QObject::tr (" (class ")) << script_error->cls () << ")";
|
||||
tl::error << script_error->msg () << tl::to_string (tr (" (class ")) << script_error->cls () << ")";
|
||||
}
|
||||
} else {
|
||||
tl::error << ex.msg ();
|
||||
|
|
@ -98,7 +96,7 @@ void handle_exception_ui (const std::exception &ex, QWidget *parent)
|
|||
|
||||
void handle_exception_silent ()
|
||||
{
|
||||
tl::error << tl::to_string (QObject::tr ("An unspecific error occured"));
|
||||
tl::error << tl::to_string (tr ("An unspecific error occured"));
|
||||
}
|
||||
|
||||
void handle_exception ()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "tlInternational.h"
|
||||
#include "tlString.h"
|
||||
#include "tlGlobPattern.h"
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
|
@ -35,9 +36,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
// Suggestions for further functions:
|
||||
// - provide date/time function
|
||||
// - file functions: (drive), combine, split_path
|
||||
|
|
@ -53,7 +51,7 @@ static std::locale c_locale ("C");
|
|||
// Implementation of EvalError
|
||||
|
||||
EvalError::EvalError (const std::string &what, const ExpressionParserContext &context)
|
||||
: tl::Exception (what + tl::to_string (QObject::tr (" at ")) + context.where ())
|
||||
: tl::Exception (what + tl::to_string (tr (" at ")) + context.where ())
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -62,7 +60,7 @@ EvalError::EvalError (const std::string &what, const ExpressionParserContext &co
|
|||
// Implementation of NoMethodError
|
||||
|
||||
NoMethodError::NoMethodError (const std::string &cls_name, const std::string &method, const ExpressionParserContext &context)
|
||||
: EvalError (tl::sprintf (tl::to_string (QObject::tr ("'%s' is not a valid method name for objects of class '%s'")), method, cls_name), context)
|
||||
: EvalError (tl::sprintf (tl::to_string (tr ("'%s' is not a valid method name for objects of class '%s'")), method, cls_name), context)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -99,7 +97,7 @@ ExpressionParserContext::where () const
|
|||
size_t len = strlen (text);
|
||||
|
||||
if (pos >= len) {
|
||||
return tl::to_string (QObject::tr ("end of text"));
|
||||
return tl::to_string (tr ("end of text"));
|
||||
} else {
|
||||
|
||||
int line = 1;
|
||||
|
|
@ -116,9 +114,9 @@ ExpressionParserContext::where () const
|
|||
std::ostringstream os;
|
||||
|
||||
if (line == 1) {
|
||||
os << tl::to_string (QObject::tr ("position")) << " " << pos;
|
||||
os << tl::to_string (tr ("position")) << " " << pos;
|
||||
} else {
|
||||
os << tl::to_string (QObject::tr ("line")) << " " << line << ", " << tl::to_string (QObject::tr ("position")) << " " << col;
|
||||
os << tl::to_string (tr ("line")) << " " << line << ", " << tl::to_string (tr ("position")) << " " << col;
|
||||
}
|
||||
|
||||
os << " (";
|
||||
|
|
@ -138,7 +136,7 @@ ExpressionParserContext::where () const
|
|||
}
|
||||
|
||||
} else {
|
||||
return std::string (tl::to_string (QObject::tr ("[unspecified location]")));
|
||||
return std::string (tl::to_string (tr ("[unspecified location]")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,14 +150,14 @@ static double to_double (const ExpressionParserContext &context, const tl::Varia
|
|||
} else if (v.is_list ()) {
|
||||
return v.get_list ().size ();
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Double precision floating point value expected")), context);
|
||||
throw EvalError (tl::to_string (tr ("Double precision floating point value expected")), context);
|
||||
}
|
||||
}
|
||||
|
||||
static double to_double (const ExpressionParserContext &context, const std::vector <tl::Variant> &v)
|
||||
{
|
||||
if (v.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Function expects a single numeric argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("Function expects a single numeric argument")), context);
|
||||
}
|
||||
|
||||
return to_double (context, v [0]);
|
||||
|
|
@ -172,7 +170,7 @@ static long to_long (const ExpressionParserContext &context, const tl::Variant &
|
|||
} else if (v.is_list ()) {
|
||||
return long (v.get_list ().size ());
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Integer value expected")), context);
|
||||
throw EvalError (tl::to_string (tr ("Integer value expected")), context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +181,7 @@ static unsigned long to_ulong (const ExpressionParserContext &context, const tl:
|
|||
} else if (v.is_list ()) {
|
||||
return (unsigned long) (v.get_list ().size ());
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unsigned integer value expected")), context);
|
||||
throw EvalError (tl::to_string (tr ("Unsigned integer value expected")), context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +192,7 @@ static long long to_longlong (const ExpressionParserContext &context, const tl::
|
|||
} else if (v.is_list ()) {
|
||||
return long (v.get_list ().size ());
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Integer value expected")), context);
|
||||
throw EvalError (tl::to_string (tr ("Integer value expected")), context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +203,7 @@ static unsigned long long to_ulonglong (const ExpressionParserContext &context,
|
|||
} else if (v.is_list ()) {
|
||||
return (unsigned long long) (v.get_list ().size ());
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unsigned integer value expected")), context);
|
||||
throw EvalError (tl::to_string (tr ("Unsigned integer value expected")), context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +309,7 @@ public:
|
|||
if (method == "push") {
|
||||
|
||||
if (args.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'push' method expects one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'push' method expects one argument")), context);
|
||||
}
|
||||
|
||||
object.push (args [0]);
|
||||
|
|
@ -320,13 +318,13 @@ public:
|
|||
} else if (method == "size") {
|
||||
|
||||
if (args.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'size' method does not accept an argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'size' method does not accept an argument")), context);
|
||||
}
|
||||
|
||||
out = object.size ();
|
||||
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unknown method")) + " '" + method + "' for list", context);
|
||||
throw EvalError (tl::to_string (tr ("Unknown method")) + " '" + method + "' for list", context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -348,7 +346,7 @@ public:
|
|||
if (method == "insert") {
|
||||
|
||||
if (args.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'insert' method expects two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'insert' method expects two arguments")), context);
|
||||
}
|
||||
|
||||
object.insert (args [0], args [1]);
|
||||
|
|
@ -357,7 +355,7 @@ public:
|
|||
} else if (method == "size") {
|
||||
|
||||
if (args.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'size' method does not accept an argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'size' method does not accept an argument")), context);
|
||||
}
|
||||
|
||||
out = object.array_size ();
|
||||
|
|
@ -365,7 +363,7 @@ public:
|
|||
} else if (method == "keys") {
|
||||
|
||||
if (args.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'keys' method does not accept an argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'keys' method does not accept an argument")), context);
|
||||
}
|
||||
|
||||
out.set_list (object.array_size ());
|
||||
|
|
@ -376,7 +374,7 @@ public:
|
|||
} else if (method == "values") {
|
||||
|
||||
if (args.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'keys' method does not accept an argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'keys' method does not accept an argument")), context);
|
||||
}
|
||||
|
||||
out.set_list (object.array_size ());
|
||||
|
|
@ -385,7 +383,7 @@ public:
|
|||
}
|
||||
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unknown method")) + " '" + method + "' for array", context);
|
||||
throw EvalError (tl::to_string (tr ("Unknown method")) + " '" + method + "' for array", context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -470,7 +468,7 @@ public:
|
|||
m_c[1]->execute (a);
|
||||
|
||||
if (! v.lvalue ()) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Assignment needs a lvalue")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Assignment needs a lvalue")), m_context);
|
||||
}
|
||||
a.swap (*v.lvalue ());
|
||||
}
|
||||
|
|
@ -511,7 +509,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -561,7 +559,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -611,7 +609,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -661,7 +659,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -711,7 +709,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -761,7 +759,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -811,7 +809,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -908,7 +906,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1079,7 +1077,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1135,7 +1133,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1191,7 +1189,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1253,7 +1251,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1313,7 +1311,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1326,7 +1324,7 @@ public:
|
|||
|
||||
long x = to_long (m_context, *b);
|
||||
if (x < 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Numeric argument of '*' operator with string must be positive")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Numeric argument of '*' operator with string must be positive")), m_context);
|
||||
}
|
||||
|
||||
std::string s;
|
||||
|
|
@ -1341,7 +1339,7 @@ public:
|
|||
|
||||
long x = to_long (m_context, *v);
|
||||
if (x < 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Numeric argument of '*' operator with string must be positive")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Numeric argument of '*' operator with string must be positive")), m_context);
|
||||
}
|
||||
|
||||
std::string s;
|
||||
|
|
@ -1403,7 +1401,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1415,37 +1413,37 @@ public:
|
|||
} else if (v->is_double () || b->is_double ()) {
|
||||
double d = to_double (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_double (m_context, *v) / d));
|
||||
} else if (v->is_ulonglong () || b->is_ulonglong ()) {
|
||||
unsigned long long d = to_ulonglong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_ulonglong (m_context, *v) / d));
|
||||
} else if (v->is_longlong () || b->is_longlong ()) {
|
||||
long long d = to_longlong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_longlong (m_context, *v) / d));
|
||||
} else if (v->is_ulong () || b->is_ulong ()) {
|
||||
unsigned long d = to_ulong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_ulong (m_context, *v) / d));
|
||||
} else if (v->is_long () || b->is_long ()) {
|
||||
long d = to_long (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_long (m_context, *v) / d));
|
||||
} else {
|
||||
double d = to_double (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Division by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Division by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_double (m_context, *v) / d));
|
||||
}
|
||||
|
|
@ -1487,7 +1485,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1499,25 +1497,25 @@ public:
|
|||
} else if (v->is_ulonglong () || b->is_ulonglong ()) {
|
||||
unsigned long long d = to_ulonglong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Modulo by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Modulo by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_ulonglong (m_context, *v) % d));
|
||||
} else if (v->is_longlong () || b->is_longlong ()) {
|
||||
long long d = to_longlong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Modulo by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Modulo by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_longlong (m_context, *v) % d));
|
||||
} else if (v->is_ulong () || b->is_ulong ()) {
|
||||
unsigned long d = to_ulong (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Modulo by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Modulo by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_ulong (m_context, *v) % d));
|
||||
} else {
|
||||
long d = to_long (m_context, *b);
|
||||
if (d == 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Modulo by zero")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Modulo by zero")), m_context);
|
||||
}
|
||||
v.set (tl::Variant (to_long (m_context, *v) % d));
|
||||
}
|
||||
|
|
@ -1559,7 +1557,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1615,7 +1613,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1671,7 +1669,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1727,7 +1725,7 @@ public:
|
|||
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1739,7 +1737,7 @@ public:
|
|||
} else if (v->is_list ()) {
|
||||
|
||||
if (! e->can_convert_to_ulong ()) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Invalid index for [] operator")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Invalid index for [] operator")), m_context);
|
||||
}
|
||||
unsigned long i = e->to_ulong ();
|
||||
if (i >= (unsigned long) v->size ()) {
|
||||
|
|
@ -1769,7 +1767,7 @@ public:
|
|||
}
|
||||
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("[] operator expects a list or an array")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("[] operator expects a list or an array")), m_context);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1804,11 +1802,11 @@ public:
|
|||
|
||||
if (v->is_user ()) {
|
||||
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unary minus not implemented for objects")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Unary minus not implemented for objects")), m_context);
|
||||
/*
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -1861,11 +1859,11 @@ public:
|
|||
|
||||
if (v->is_user ()) {
|
||||
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unary tilde not implemented for objects")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Unary tilde not implemented for objects")), m_context);
|
||||
/*
|
||||
const EvalClass *c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
throw EvalError (tl::to_string (tr ("Not a valid object for a method call (not an object)")), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -2041,10 +2039,10 @@ public:
|
|||
} else if (v->is_user ()) {
|
||||
c = v->user_cls () ? v->user_cls ()->eval_cls () : 0;
|
||||
if (! c) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (not an object) - value is %1").arg (tl::to_qstring (v->to_parsable_string ()))), m_context);
|
||||
throw EvalError (tl::sprintf (tl::to_string (tr ("Not a valid object for a method call (not an object) - value is %s")), v->to_parsable_string ()), m_context);
|
||||
}
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Not a valid object for a method call (wrong type) - value is %1").arg (tl::to_qstring (v->to_parsable_string ()))), m_context);
|
||||
throw EvalError (tl::sprintf (tl::to_string (tr ("Not a valid object for a method call (wrong type) - value is %1")), v->to_parsable_string ()), m_context);
|
||||
}
|
||||
|
||||
tl::Variant o;
|
||||
|
|
@ -2358,7 +2356,7 @@ static void
|
|||
abs_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &v)
|
||||
{
|
||||
if (v.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'abs' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'abs' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
if (v[0].is_long ()) {
|
||||
|
|
@ -2444,7 +2442,7 @@ static void
|
|||
pow_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'pow' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'pow' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
out = pow (to_double (context, vv [0]), to_double (context, vv [1]));
|
||||
|
|
@ -2454,7 +2452,7 @@ static void
|
|||
atan2_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'atan2' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'atan2' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
out = atan2 (to_double (context, vv [0]), to_double (context, vv [1]));
|
||||
|
|
@ -2464,7 +2462,7 @@ static void
|
|||
to_f_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_f' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_f' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_double ();
|
||||
|
|
@ -2474,7 +2472,7 @@ static void
|
|||
to_s_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_s' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_s' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_string ();
|
||||
|
|
@ -2484,7 +2482,7 @@ static void
|
|||
to_i_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_i' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_i' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_long ();
|
||||
|
|
@ -2494,7 +2492,7 @@ static void
|
|||
to_ui_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_ui' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_ui' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_ulong ();
|
||||
|
|
@ -2504,7 +2502,7 @@ static void
|
|||
to_l_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_l' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_l' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_longlong ();
|
||||
|
|
@ -2514,7 +2512,7 @@ static void
|
|||
to_ul_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'to_ul' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'to_ul' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].to_ulonglong ();
|
||||
|
|
@ -2524,7 +2522,7 @@ static void
|
|||
is_string_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'is_string' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'is_string' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv[0].is_a_string ();
|
||||
|
|
@ -2534,7 +2532,7 @@ static void
|
|||
is_numeric_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'is_numeric' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'is_numeric' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].can_convert_to_double ();
|
||||
|
|
@ -2544,7 +2542,7 @@ static void
|
|||
is_array_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'is_array' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'is_array' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].is_list ();
|
||||
|
|
@ -2554,7 +2552,7 @@ static void
|
|||
is_nil_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'is_nil' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'is_nil' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = vv [0].is_nil ();
|
||||
|
|
@ -2564,7 +2562,7 @@ static void
|
|||
gsub_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 3) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'gsub' function expects exactly three arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'gsub' function expects exactly three arguments")), context);
|
||||
}
|
||||
|
||||
std::string s (vv [0].to_string ());
|
||||
|
|
@ -2589,7 +2587,7 @@ static void
|
|||
sub_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 3) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'sub' function expects exactly three arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'sub' function expects exactly three arguments")), context);
|
||||
}
|
||||
|
||||
std::string s (vv [0].to_string ());
|
||||
|
|
@ -2617,7 +2615,7 @@ static void
|
|||
find_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'find' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'find' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
std::string s (vv [0].to_string ());
|
||||
|
|
@ -2635,7 +2633,7 @@ static void
|
|||
rfind_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'rfind' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'rfind' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
std::string s (vv [0].to_string ());
|
||||
|
|
@ -2653,7 +2651,7 @@ static void
|
|||
len_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'len' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'len' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
if (vv [0].is_list ()) {
|
||||
|
|
@ -2667,7 +2665,7 @@ static void
|
|||
substr_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 3 && vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'substr' function expects two or three arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'substr' function expects two or three arguments")), context);
|
||||
}
|
||||
|
||||
std::string s (vv [0].to_string ());
|
||||
|
|
@ -2701,11 +2699,11 @@ static void
|
|||
join_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'join' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'join' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
if (! vv[0].is_list ()) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("First argument of 'join' function must be a list")), context);
|
||||
throw EvalError (tl::to_string (tr ("First argument of 'join' function must be a list")), context);
|
||||
}
|
||||
|
||||
std::ostringstream r;
|
||||
|
|
@ -2729,11 +2727,11 @@ static void
|
|||
item_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'item' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'item' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
if (! vv[0].is_list ()) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("First argument of 'item' function must be a list")), context);
|
||||
throw EvalError (tl::to_string (tr ("First argument of 'item' function must be a list")), context);
|
||||
}
|
||||
|
||||
long index = to_long (context, vv [1]);
|
||||
|
|
@ -2748,7 +2746,7 @@ static void
|
|||
split_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'split' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'split' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
out = tl::Variant::empty_list ();
|
||||
|
|
@ -2767,7 +2765,7 @@ static void
|
|||
true_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'true' function must not have arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'true' function must not have arguments")), context);
|
||||
}
|
||||
|
||||
out = true;
|
||||
|
|
@ -2777,7 +2775,7 @@ static void
|
|||
false_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'false' function must not have arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'false' function must not have arguments")), context);
|
||||
}
|
||||
|
||||
out = false;
|
||||
|
|
@ -2787,7 +2785,7 @@ static void
|
|||
nil_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 0) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'nil' function must not have arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'nil' function must not have arguments")), context);
|
||||
}
|
||||
|
||||
out = tl::Variant ();
|
||||
|
|
@ -2797,7 +2795,7 @@ static void
|
|||
env_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'env' function expects exactly two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'env' function expects exactly two arguments")), context);
|
||||
}
|
||||
|
||||
const char *env = getenv (vv [0].to_string ());
|
||||
|
|
@ -2812,7 +2810,7 @@ static void
|
|||
error_f (const ExpressionParserContext &context, tl::Variant &, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'error' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'error' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
throw tl::Exception (vv [0].to_string ());
|
||||
|
|
@ -2822,87 +2820,87 @@ static void
|
|||
absolute_file_path_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'absolute_file_path' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'absolute_file_path' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).absoluteFilePath ();
|
||||
out = tl::absolute_file_path (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
absolute_path_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'absolute_path' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'absolute_path' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).absolutePath ();
|
||||
out = tl::absolute_path (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
path_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'path' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'path' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).path ();
|
||||
out = tl::dirname (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
basename_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'basename' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'basename' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).baseName ();
|
||||
out = tl::basename (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
extension_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'extension' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'extension' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).completeSuffix ();
|
||||
out = tl::extension (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
file_exists_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'file_exists' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'file_exists' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).exists ();
|
||||
out = tl::file_exists (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
is_dir_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'is_dir' function expects exactly one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'is_dir' function expects exactly one argument")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (vv [0].to_qstring ()).isDir ();
|
||||
out = tl::is_dir (vv [0].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
combine_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () != 2) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'combine' function expects two arguments")), context);
|
||||
throw EvalError (tl::to_string (tr ("'combine' function expects two arguments")), context);
|
||||
}
|
||||
|
||||
out = QFileInfo (QDir (vv [0].to_qstring ()), vv [1].to_qstring ()).filePath ();
|
||||
out = tl::combine_path (vv [0].to_string (), vv [1].to_string ());
|
||||
}
|
||||
|
||||
static void
|
||||
sprintf_f (const ExpressionParserContext &context, tl::Variant &out, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () < 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'sprintf' function expects at least one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'sprintf' function expects at least one argument")), context);
|
||||
}
|
||||
|
||||
out = tl::sprintf (vv[0].to_string (), vv, 1);
|
||||
|
|
@ -2912,7 +2910,7 @@ static void
|
|||
printf_f (const ExpressionParserContext &context, tl::Variant &, const std::vector <tl::Variant> &vv)
|
||||
{
|
||||
if (vv.size () < 1) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("'printf' function expects at least one argument")), context);
|
||||
throw EvalError (tl::to_string (tr ("'printf' function expects at least one argument")), context);
|
||||
}
|
||||
|
||||
std::cout << tl::sprintf (vv[0].to_string (), vv, 1);
|
||||
|
|
@ -3240,7 +3238,7 @@ Eval::eval_if (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n)
|
|||
std::auto_ptr<ExpressionNode> b, c;
|
||||
eval_if (ex, b);
|
||||
if (! ex.test (":")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected ':'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected ':'")), ex);
|
||||
}
|
||||
eval_if (ex, c);
|
||||
n.reset (new IfExpressionNode (ex1, n.release (), b.release (), c.release ()));
|
||||
|
|
@ -3556,7 +3554,7 @@ Eval::eval_suffix (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
if (ex.test (")")) {
|
||||
break;
|
||||
} else if (! ex.test (",")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected closing bracket ')'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected closing bracket ')'")), ex);
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
|
@ -3625,7 +3623,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
|
||||
eval_top (ex, n);
|
||||
if (! ex.test (")")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected closing bracket ')'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected closing bracket ')'")), ex);
|
||||
}
|
||||
|
||||
} else if (ex.test ("[")) {
|
||||
|
|
@ -3643,7 +3641,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
if (ex.test ("]")) {
|
||||
break;
|
||||
} else if (! ex.test (",")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected closing bracket ']'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected closing bracket ']'")), ex);
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
|
@ -3664,7 +3662,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else if (ctx_handler ()) {
|
||||
n.reset (new ContextEvaluationNode (ex1, ctx_handler (), n.release (), true /*double bracket*/));
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("<<..>> expression not available in this context")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("<<..>> expression not available in this context")), ex1);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -3677,7 +3675,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else if (ctx_handler ()) {
|
||||
n.reset (new ConstantExpressionNode (ex1, ctx_handler ()->eval_double_bracket (s)));
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("<<..>> expression not available in this context")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("<<..>> expression not available in this context")), ex1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3696,7 +3694,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else if (ctx_handler ()) {
|
||||
n.reset (new ContextEvaluationNode (ex1, ctx_handler (), n.release (), false /*single bracket*/));
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("<<..>> expression not available in this context")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("<<..>> expression not available in this context")), ex1);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -3709,7 +3707,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else if (ctx_handler ()) {
|
||||
n.reset (new ConstantExpressionNode (ex1, ctx_handler ()->eval_bracket (s)));
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("<..> expression not available in this context")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("<..> expression not available in this context")), ex1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3745,7 +3743,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
if (ex.test ("}")) {
|
||||
break;
|
||||
} else if (! ex.test (",")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected closing bracket ']'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected closing bracket ']'")), ex);
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
|
@ -3758,7 +3756,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
while (! ex.at_end ()) {
|
||||
if (isdigit (*ex) || (tolower (*ex) <= 'f' && tolower (*ex) >= 'a')) {
|
||||
if ((x * 16) / 16 != x) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Hexadecimal number overflow")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("Hexadecimal number overflow")), ex1);
|
||||
}
|
||||
x *= 16;
|
||||
if (isdigit (*ex)) {
|
||||
|
|
@ -3836,7 +3834,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else {
|
||||
|
||||
if (dbu_units && ! ctx_handler ()) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Length or area value with unit requires a layout context")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("Length or area value with unit requires a layout context")), ex1);
|
||||
}
|
||||
|
||||
if (dbu_units) {
|
||||
|
|
@ -3844,7 +3842,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
double gg = g;
|
||||
g = floor (0.5 + g);
|
||||
if (fabs (g) < 1e12 && fabs (g - gg) > 1e-3) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Value is not a multiple of the database unit")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("Value is not a multiple of the database unit")), ex1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3898,7 +3896,7 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
if (ex.test (")")) {
|
||||
break;
|
||||
} else if (! ex.test (",")) {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected closing bracket ')'")), ex);
|
||||
throw EvalError (tl::to_string (tr ("Expected closing bracket ')'")), ex);
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
|
@ -3914,11 +3912,11 @@ Eval::eval_atomic (ExpressionParserContext &ex, std::auto_ptr<ExpressionNode> &n
|
|||
} else if (m_sloppy) {
|
||||
n.reset (new ConstantExpressionNode (ex1, tl::Variant ()));
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Unknown variable or function")) + " '" + t + "'", ex1);
|
||||
throw EvalError (tl::to_string (tr ("Unknown variable or function")) + " '" + t + "'", ex1);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw EvalError (tl::to_string (QObject::tr ("Expected constant, function or bracket expression")), ex1);
|
||||
throw EvalError (tl::to_string (tr ("Expected constant, function or bracket expression")), ex1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#include "tlFileSystemWatcher.h"
|
||||
#include "tlString.h"
|
||||
#include "tlTimer.h"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
#ifndef HDR_tlFileSystemWatcher
|
||||
#define HDR_tlFileSystemWatcher
|
||||
|
||||
#if !defined(HAVE_QT)
|
||||
# error tl::FileSystemWatcher not available
|
||||
#endif
|
||||
|
||||
#include "tlEvents.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
|
|||
|
|
@ -24,36 +24,176 @@
|
|||
#include "tlLog.h"
|
||||
#include "tlInternational.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <cctype>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
bool
|
||||
is_parent_path (const QString &parent, const QString &path)
|
||||
#if defined(_WIN32)
|
||||
static bool is_drive (const std::string &part)
|
||||
{
|
||||
QFileInfo parent_info (parent);
|
||||
if (! parent_info.exists ()) {
|
||||
return (part.size () == 2 && isletter (part[0]) && part[1] == ':');
|
||||
}
|
||||
#else
|
||||
static bool is_drive (const std::string &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static std::string trimmed_part (const std::string &part)
|
||||
{
|
||||
const char *cp = part.c_str ();
|
||||
|
||||
#if defined(_WIN32)
|
||||
while (*cp && *cp != '\\' && *cp != '/') {
|
||||
++cp;
|
||||
}
|
||||
#else
|
||||
while (*cp && *cp != '/') {
|
||||
++cp;
|
||||
}
|
||||
#endif
|
||||
|
||||
return std::string (part, 0, cp - part.c_str ());
|
||||
}
|
||||
|
||||
static bool is_part_with_separator (const std::string &part)
|
||||
{
|
||||
const char *cp = part.c_str ();
|
||||
#if defined(_WIN32)
|
||||
return (*cp == '\\' || *cp == '/');
|
||||
#else
|
||||
return (*cp == '/');
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<std::string> split_path (const std::string &p)
|
||||
{
|
||||
std::vector<std::string> parts;
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
const char *cp = p.c_str ();
|
||||
if (*cp && isletter (*cp) && cp[1] == ':') {
|
||||
|
||||
// drive name
|
||||
parts.push_back (std::string ());
|
||||
parts.back () += toupper (*cp);
|
||||
parts.back () += ":";
|
||||
|
||||
cp += 2;
|
||||
|
||||
} else if ((*cp == '\\' && cp[1] == '\\') || (*cp == '/' && cp[1] == '/')) {
|
||||
|
||||
// UNC server name
|
||||
const char *cp0 = cp;
|
||||
cp += 2;
|
||||
while (*cp && *cp != '\\' && *cp != '/') {
|
||||
++cp;
|
||||
}
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
|
||||
}
|
||||
|
||||
while (*cp) {
|
||||
|
||||
const char *cp0 = cp;
|
||||
bool any = false;
|
||||
while (*cp && (!any || (*cp != '\\' && *cp != '/'))) {
|
||||
if (*cp != '\\' && *cp != '/') {
|
||||
any = true;
|
||||
}
|
||||
++cp;
|
||||
}
|
||||
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const char *cp = p.c_str ();
|
||||
while (*cp) {
|
||||
|
||||
const char *cp0 = cp;
|
||||
bool any = false;
|
||||
while (*cp && (!any || *cp != '/')) {
|
||||
if (*cp != '/') {
|
||||
any = true;
|
||||
}
|
||||
// backslash escape
|
||||
if (*cp == '\\' && cp[1]) {
|
||||
++cp;
|
||||
}
|
||||
++cp;
|
||||
}
|
||||
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
static std::vector<std::string> split_filename (const std::string &fn)
|
||||
{
|
||||
std::vector<std::string> parts;
|
||||
|
||||
const char *cp = fn.c_str ();
|
||||
|
||||
while (*cp) {
|
||||
|
||||
const char *cp0 = cp;
|
||||
++cp;
|
||||
while (*cp && *cp != '.') {
|
||||
// backslash escaping (ineffective on Windows because that is a path separator)
|
||||
if (*cp == '\\' && cp[1]) {
|
||||
++cp;
|
||||
}
|
||||
++cp;
|
||||
}
|
||||
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
if (*cp) {
|
||||
++cp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
bool
|
||||
is_parent_path (const std::string &parent, const std::string &path)
|
||||
{
|
||||
if (! file_exists (parent)) {
|
||||
// If the parent path does not exist, we always return false. This cannot be a parent.
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo path_info (path);
|
||||
std::vector<std::string> parts = split_path (absolute_file_path (path));
|
||||
|
||||
while (parent_info != path_info) {
|
||||
if (path_info.isRoot ()) {
|
||||
return false;
|
||||
while (! parts.empty () && ! (parts.size () == 1 && is_drive (parts[0]))) {
|
||||
if (is_same_file (parent, tl::join (parts, ""))) {
|
||||
return true;
|
||||
} else {
|
||||
parts.pop_back ();
|
||||
}
|
||||
path_info = path_info.path ();
|
||||
}
|
||||
|
||||
return true;
|
||||
// We did not find a match - now maybe the parent is root
|
||||
return (is_same_file (parent, tl::combine_path (tl::join (parts, ""), "")));
|
||||
}
|
||||
|
||||
bool
|
||||
rm_dir_recursive (const QString &path)
|
||||
bool rm_dir_recursive (const std::string &path)
|
||||
{
|
||||
#if 0 // @@@
|
||||
QDir dir (path);
|
||||
|
||||
QStringList entries = dir.entryList (QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
|
|
@ -65,7 +205,7 @@ rm_dir_recursive (const QString &path)
|
|||
}
|
||||
} else if (fi.isFile ()) {
|
||||
if (! dir.remove (*e)) {
|
||||
tl::error << QObject::tr ("Unable to remove file: %1").arg (dir.absoluteFilePath (*e));
|
||||
tl::error << tr ("Unable to remove file: %1").arg (dir.absoluteFilePath (*e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,17 +214,20 @@ rm_dir_recursive (const QString &path)
|
|||
QString name = dir.dirName ();
|
||||
if (dir.cdUp ()) {
|
||||
if (! dir.rmdir (name)) {
|
||||
tl::error << QObject::tr ("Unable to remove directory: %1").arg (dir.absoluteFilePath (name));
|
||||
tl::error << tr ("Unable to remove directory: %1").arg (dir.absoluteFilePath (name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
cp_dir_recursive (const QString &source, const QString &target)
|
||||
cp_dir_recursive (const std::string &source, const std::string &target)
|
||||
{
|
||||
#if 0 // @@@
|
||||
QDir dir (source);
|
||||
QDir dir_target (target);
|
||||
|
||||
|
|
@ -99,11 +242,11 @@ cp_dir_recursive (const QString &source, const QString &target)
|
|||
// Copy subdirectory
|
||||
if (! fi_target.exists ()) {
|
||||
if (! dir_target.mkdir (*e)) {
|
||||
tl::error << QObject::tr ("Unable to create target directory: %1").arg (dir_target.absoluteFilePath (*e));
|
||||
tl::error << tr ("Unable to create target directory: %1").arg (dir_target.absoluteFilePath (*e));
|
||||
return false;
|
||||
}
|
||||
} else if (! fi_target.isDir ()) {
|
||||
tl::error << QObject::tr ("Unable to create target directory (is a file already): %1").arg (dir_target.absoluteFilePath (*e));
|
||||
tl::error << tr ("Unable to create target directory (is a file already): %1").arg (dir_target.absoluteFilePath (*e));
|
||||
return false;
|
||||
}
|
||||
if (! cp_dir_recursive (fi.filePath (), fi_target.filePath ())) {
|
||||
|
|
@ -117,11 +260,11 @@ cp_dir_recursive (const QString &source, const QString &target)
|
|||
QFile file_target (fi_target.filePath ());
|
||||
|
||||
if (! file.open (QIODevice::ReadOnly)) {
|
||||
tl::error << QObject::tr ("Unable to open source file for reading: %1").arg (fi.filePath ());
|
||||
tl::error << tr ("Unable to open source file for reading: %1").arg (fi.filePath ());
|
||||
return false;
|
||||
}
|
||||
if (! file_target.open (QIODevice::WriteOnly)) {
|
||||
tl::error << QObject::tr ("Unable to open target file for writing: %1").arg (fi_target.filePath ());
|
||||
tl::error << tr ("Unable to open target file for writing: %1").arg (fi_target.filePath ());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +282,227 @@ cp_dir_recursive (const QString &source, const QString &target)
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mkpath (const std::string &path)
|
||||
{
|
||||
// @@@
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string absolute_path (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> parts = split_path (absolute_file_path (s));
|
||||
if (parts.size () > 0) {
|
||||
parts.pop_back ();
|
||||
}
|
||||
|
||||
return tl::join (parts, "");
|
||||
}
|
||||
|
||||
std::string current_dir ()
|
||||
{
|
||||
char *cwd;
|
||||
#if defined(_WIN32)
|
||||
cwd = _getcwd (NULL, 0);
|
||||
#else
|
||||
cwd = getcwd (NULL, 0);
|
||||
#endif
|
||||
|
||||
if (cwd == NULL) {
|
||||
return std::string ();
|
||||
} else {
|
||||
std::string cwds (cwd);
|
||||
free (cwd);
|
||||
return cwds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static std::pair<std::string, bool> absolute_path_of_existing (const std::string &s)
|
||||
{
|
||||
char *fp;
|
||||
#if defined (_WIN32)
|
||||
fp = _fullpath (NULL, s.c_str (), 0);
|
||||
#else
|
||||
fp = realpath (s.c_str (), NULL);
|
||||
#endif
|
||||
|
||||
if (fp == NULL) {
|
||||
return std::make_pair (std::string (), false);
|
||||
} else {
|
||||
std::string fps (fp);
|
||||
free (fp);
|
||||
return std::make_pair (fps, true);
|
||||
}
|
||||
}
|
||||
|
||||
std::string absolute_file_path (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> parts = split_path (s);
|
||||
if (parts.empty ()) {
|
||||
return current_dir ();
|
||||
}
|
||||
|
||||
std::pair<std::string, bool> known_part;
|
||||
std::vector<std::string> unknown_parts;
|
||||
|
||||
while (! parts.empty () && ! (parts.size () == 1 && is_drive (parts[0]))) {
|
||||
known_part = absolute_path_of_existing (tl::join (parts, ""));
|
||||
if (! known_part.second) {
|
||||
unknown_parts.push_back (parts.back ());
|
||||
parts.pop_back ();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::reverse (unknown_parts.begin (), unknown_parts.end ());
|
||||
|
||||
if (! known_part.second) {
|
||||
|
||||
// the top-level component is unknown. This can mean:
|
||||
// 1.) the path is already absolute, but the top-level entry does not exist
|
||||
// 2.) the path is relative, but the entry does not exist
|
||||
|
||||
tl_assert (! unknown_parts.empty ());
|
||||
if (is_part_with_separator (unknown_parts.front ())) {
|
||||
|
||||
// case 1: return the full path as absolute
|
||||
return s;
|
||||
|
||||
} else if (parts.size () == 1 && is_drive (parts[0])) {
|
||||
|
||||
// case 2 (for Windows): try to root on drive's working dir
|
||||
known_part = absolute_path_of_existing (parts[0]);
|
||||
if (! known_part.second) {
|
||||
// drive is not known ... return the original path as fallback
|
||||
return s;
|
||||
} else {
|
||||
return combine_path (known_part.first, tl::join (unknown_parts, ""));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// case 2 (for *nix): try to root on current working dir
|
||||
return combine_path (current_dir (), tl::join (unknown_parts, ""));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
return combine_path (known_part.first, tl::join (unknown_parts, ""));
|
||||
}
|
||||
}
|
||||
|
||||
std::string dirname (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> parts = split_path (s);
|
||||
if (parts.size () > 0) {
|
||||
parts.pop_back ();
|
||||
}
|
||||
|
||||
return tl::join (parts, "");
|
||||
}
|
||||
|
||||
std::string filename (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> parts = split_path (s);
|
||||
if (parts.size () > 0) {
|
||||
return trimmed_part (parts.back ());
|
||||
} else {
|
||||
return std::string ();
|
||||
}
|
||||
}
|
||||
|
||||
std::string basename (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> fnp = split_filename (filename (s));
|
||||
if (fnp.size () > 0) {
|
||||
return fnp.front ();
|
||||
} else {
|
||||
return std::string ();
|
||||
}
|
||||
}
|
||||
|
||||
std::string extension (const std::string &s)
|
||||
{
|
||||
std::vector<std::string> fnp = split_filename (filename (s));
|
||||
if (fnp.size () > 0) {
|
||||
fnp.erase (fnp.begin ());
|
||||
}
|
||||
return tl::join (fnp, ".");
|
||||
}
|
||||
|
||||
bool file_exists (const std::string &p)
|
||||
{
|
||||
struct stat st;
|
||||
return stat (p.c_str (), &st) == 0;
|
||||
}
|
||||
|
||||
bool is_dir (const std::string &p)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat (p.c_str (), &st) != 0) {
|
||||
return false;
|
||||
} else {
|
||||
return !S_ISREG (st.st_mode);
|
||||
}
|
||||
}
|
||||
|
||||
std::string combine_path (const std::string &p1, const std::string &p2)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return p1 + "\\" + p2;
|
||||
#else
|
||||
return p1 + "/" + p2;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is_same_file (const std::string &a, const std::string &b)
|
||||
{
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
HANDLE h1 = ::CreateFile (a.c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE h2 = ::CreateFile (b.c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE) {
|
||||
BY_HANDLE_FILE_INFORMATION fi1, fi2;
|
||||
if (::GetFileInformationByHandle(h1, &fi1) && ::GetFileInformationByHandle(h2, &fi2)) {
|
||||
result = fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber &&
|
||||
fi1.nFileIndexHigh == fi2.nFileIndexHigh &&
|
||||
fi1.nFileIndexLow == fi2.nFileIndexLow;
|
||||
}
|
||||
}
|
||||
|
||||
if (h1 != INVALID_HANDLE_VALUE) {
|
||||
::CloseHandle(h1);
|
||||
}
|
||||
|
||||
if (h2 != INVALID_HANDLE_VALUE) {
|
||||
::CloseHandle(h2);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
#else
|
||||
|
||||
struct stat sta, stb;
|
||||
if (stat (a.c_str (), &sta) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (stat (b.c_str (), &stb) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return sta.st_dev == stb.st_dev && sta.st_ino == stb.st_ino;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,55 +25,102 @@
|
|||
|
||||
#include "tlCommon.h"
|
||||
#include "tlString.h"
|
||||
#include <QString>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Returns a value indicating whether the parent path is a parent directory of the path
|
||||
*/
|
||||
bool TL_PUBLIC is_parent_path (const QString &parent, const QString &path);
|
||||
|
||||
/**
|
||||
* @brief Returns a value indicating whether the parent path is a parent directory of the path (version with std::string)
|
||||
*/
|
||||
inline bool is_parent_path (const std::string &parent, const std::string &path)
|
||||
{
|
||||
return is_parent_path (tl::to_qstring (parent), tl::to_qstring (path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Recursively remove the given directory, the files from that directory and all sub-directories
|
||||
* @return True, if successful. false otherwise.
|
||||
*/
|
||||
bool TL_PUBLIC rm_dir_recursive (const QString &path);
|
||||
bool TL_PUBLIC is_parent_path (const std::string &parent, const std::string &path);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
inline bool rm_dir_recursive (const std::string &path)
|
||||
{
|
||||
return rm_dir_recursive (tl::to_qstring (path));
|
||||
}
|
||||
bool TL_PUBLIC rm_dir_recursive (const std::string &path);
|
||||
|
||||
/**
|
||||
* @brief Recursively copies a given directory to a target directory
|
||||
* Both target and source directories need to exist. New directories are created in the target
|
||||
* directory if required.
|
||||
* @brief Creates the given path as far it does not exist yet
|
||||
* @return True, if successful. false otherwise.
|
||||
*/
|
||||
bool TL_PUBLIC cp_dir_recursive (const QString &source, const QString &target);
|
||||
bool TL_PUBLIC mkpath (const std::string &path);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
inline bool cp_dir_recursive (const std::string &source, const std::string &target)
|
||||
{
|
||||
return cp_dir_recursive (tl::to_qstring (source), tl::to_qstring (target));
|
||||
}
|
||||
bool TL_PUBLIC cp_dir_recursive (const std::string &source, const std::string &target);
|
||||
|
||||
/**
|
||||
* @brief Gets the absolute path for a given file path
|
||||
* This will deliver the directory of the file as absolute path.
|
||||
*/
|
||||
std::string TL_PUBLIC absolute_path (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Gets the absolute file path for a given file path
|
||||
* This will deliver the directory and the file part as absolute path.
|
||||
*/
|
||||
std::string TL_PUBLIC absolute_file_path (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Gets the directory name for a given file path
|
||||
*/
|
||||
std::string TL_PUBLIC dirname (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Gets the filename for a given file path (file name without directory part)
|
||||
*/
|
||||
std::string TL_PUBLIC filename (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Gets the basename for a given file path (file name without any extensions)
|
||||
* This will strip all extensions (i.e. "archive.tar.gz" will become "archive").
|
||||
*/
|
||||
std::string TL_PUBLIC basename (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Gets the complete extension for a given file path
|
||||
*/
|
||||
std::string TL_PUBLIC extension (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the given path exists
|
||||
* If the path is a directory, file_exists will return true, if the directory exists.
|
||||
*/
|
||||
bool TL_PUBLIC file_exists (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the given path is a directory
|
||||
*/
|
||||
bool TL_PUBLIC is_dir (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the given path is the same directory of file than the other one
|
||||
*/
|
||||
bool TL_PUBLIC is_same_file (const std::string &a, const std::string &b);
|
||||
|
||||
/**
|
||||
* @brief Combines the two path components into one path
|
||||
*/
|
||||
std::string TL_PUBLIC combine_path (const std::string &p1, const std::string &p2);
|
||||
|
||||
/**
|
||||
* @brief Gets the current directory
|
||||
*/
|
||||
std::string TL_PUBLIC current_dir ();
|
||||
|
||||
/**
|
||||
* @brief This function splits the path into it's components
|
||||
* On Windows, the first component may be the drive prefix ("C:") or
|
||||
* UNC server name ("\\server").
|
||||
* The components will keep their path separator, so joining the
|
||||
* parts will render the original path. A trailing empty element is
|
||||
* added if the path terminates with a separator (like "C:\" or "/home/user/").
|
||||
* The idea is that the last element is the file name part.
|
||||
*/
|
||||
static std::vector<std::string> split_path (const std::string &p);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,14 @@
|
|||
#ifndef HDR_tlHttpStream
|
||||
#define HDR_tlHttpStream
|
||||
|
||||
#include "tlHttpStreamCurl.h"
|
||||
#include "tlHttpStreamQt.h"
|
||||
#if defined(HAVE_CURL)
|
||||
# include "tlHttpStreamCurl.h"
|
||||
#elif defined(HAVE_QT)
|
||||
# include "tlHttpStreamQt.h"
|
||||
#endif
|
||||
|
||||
#include "tlObject.h"
|
||||
#include "tlException.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -55,7 +59,7 @@ class TL_PUBLIC HttpErrorException
|
|||
{
|
||||
public:
|
||||
HttpErrorException (const std::string &f, int en, const std::string &url)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Error %d: %s, fetching %s")), en, f, url)
|
||||
: tl::Exception (tl::to_string (tr ("Error %d: %s, fetching %s")), en, f, url)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CURL)
|
||||
|
||||
#include "tlHttpStream.h"
|
||||
#include "tlHttpStreamCurl.h"
|
||||
#include "tlLog.h"
|
||||
|
|
@ -1231,5 +1229,3 @@ InputHttpStream::set_credential_provider (HttpCredentialProvider *cp)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
#ifndef HDR_tlHttpStreamCurl
|
||||
#define HDR_tlHttpStreamCurl
|
||||
|
||||
#if defined(HAVE_CURL)
|
||||
|
||||
#include "tlStream.h"
|
||||
#include "tlEvents.h"
|
||||
#include "tlObject.h"
|
||||
|
|
@ -165,5 +163,3 @@ private:
|
|||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_CURL)
|
||||
|
||||
#include "tlHttpStream.h"
|
||||
#include "tlLog.h"
|
||||
#include "tlStaticObjects.h"
|
||||
|
|
@ -300,5 +298,3 @@ InputHttpStream::filename () const
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
#ifndef HDR_tlHttpStreamQt
|
||||
#define HDR_tlHttpStreamQt
|
||||
|
||||
#if !defined(HAVE_CURL)
|
||||
|
||||
#include "tlStream.h"
|
||||
#include "tlEvents.h"
|
||||
|
||||
|
|
@ -191,5 +189,3 @@ private:
|
|||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,19 +24,23 @@
|
|||
#include "tlInternational.h"
|
||||
#include "tlString.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QTextCodec>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#ifndef _WIN32
|
||||
# include <langinfo.h>
|
||||
#if !defined(_WIN32)
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
QTextCodec *ms_system_codec = 0;
|
||||
|
||||
QString to_qstring (const std::string &s)
|
||||
|
|
@ -49,7 +53,7 @@ std::string to_string (const QString &s)
|
|||
return std::string (s.toUtf8 ().constData ());
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32)
|
||||
std::string system_to_string (const std::string &s)
|
||||
{
|
||||
if (! ms_system_codec) {
|
||||
|
|
@ -92,5 +96,21 @@ void initialize_codecs ()
|
|||
std::cerr.imbue (c_locale);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
std::string system_to_string (const std::string &s)
|
||||
{
|
||||
// TODO: this fallback implementation assumes the system encoding is UTF-8
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string string_to_system (const std::string &s)
|
||||
{
|
||||
// TODO: this fallback implementation assumes the system encoding is UTF-8
|
||||
return std::string (s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,29 @@
|
|||
#include "tlCommon.h"
|
||||
|
||||
#include <string>
|
||||
#include <QString>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
# include <QString>
|
||||
// provides QObject for QObject::tr
|
||||
#include <QObject>
|
||||
# include <QObject>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Generic tr function for non-Qt and Qt builds
|
||||
*/
|
||||
#if defined(HAVE_QT)
|
||||
QString tr (const char *s)
|
||||
{
|
||||
return QObject::tr (s);
|
||||
}
|
||||
#else
|
||||
std::string tr (const char *s);
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
/**
|
||||
* @brief Convert a UTF8 std::string to a QString
|
||||
*/
|
||||
|
|
@ -44,6 +59,15 @@ TL_PUBLIC QString to_qstring (const std::string &s);
|
|||
* @brief Convert a QString to a UTF8 std::string
|
||||
*/
|
||||
TL_PUBLIC std::string to_string (const QString &s);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dummy conversion for convenience and as non-Qt replacement for to_string (const QString &)
|
||||
*/
|
||||
inline const std::string &to_string (const std::string &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ verbosity ()
|
|||
// Channel implementation
|
||||
|
||||
Channel::Channel ()
|
||||
: m_lock (), m_no_endl (false), m_active (false)
|
||||
: m_no_endl (false), m_active (false)
|
||||
{
|
||||
// .. nothing else ..
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@
|
|||
#include "tlCommon.h"
|
||||
|
||||
#include "tlString.h"
|
||||
#include "tlThreads.h"
|
||||
#include "tlObjectCollection.h"
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
|
|
@ -138,7 +137,7 @@ protected:
|
|||
virtual void end () = 0;
|
||||
virtual void begin () = 0;
|
||||
|
||||
QMutex m_lock;
|
||||
tl::Mutex m_lock;
|
||||
|
||||
private:
|
||||
friend class ChannelProxy;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "tlObject.h"
|
||||
|
||||
#include <QMutexLocker>
|
||||
#include <memory>
|
||||
|
||||
namespace tl
|
||||
|
|
@ -181,27 +180,27 @@ namespace {
|
|||
GlobalLockInitializer ()
|
||||
{
|
||||
if (! sp_lock) {
|
||||
sp_lock = new QMutex ();
|
||||
sp_lock = new tl::Mutex ();
|
||||
}
|
||||
}
|
||||
|
||||
QMutex &gl ()
|
||||
tl::Mutex &gl ()
|
||||
{
|
||||
return *sp_lock;
|
||||
}
|
||||
|
||||
private:
|
||||
static QMutex *sp_lock;
|
||||
static tl::Mutex *sp_lock;
|
||||
};
|
||||
|
||||
QMutex *GlobalLockInitializer::sp_lock = 0;
|
||||
tl::Mutex *GlobalLockInitializer::sp_lock = 0;
|
||||
|
||||
// This ensures the instance is created in the initialization code
|
||||
static GlobalLockInitializer s_gl_init;
|
||||
|
||||
}
|
||||
|
||||
QMutex &WeakOrSharedPtr::lock ()
|
||||
tl::Mutex &WeakOrSharedPtr::lock ()
|
||||
{
|
||||
// NOTE: to ensure proper function in static initialization code we cannot simply use
|
||||
// a static QMutex instance - this may not be initialized. This is not entirely thread
|
||||
|
|
@ -224,7 +223,7 @@ const Object *WeakOrSharedPtr::get () const
|
|||
|
||||
void WeakOrSharedPtr::reset_object ()
|
||||
{
|
||||
QMutexLocker locker (&lock ());
|
||||
tl::MutexLocker locker (&lock ());
|
||||
|
||||
if (mp_t) {
|
||||
mp_t->unregister_ptr (this);
|
||||
|
|
@ -242,7 +241,7 @@ void WeakOrSharedPtr::reset (Object *t, bool is_shared, bool is_event)
|
|||
Object *to_delete = 0;
|
||||
|
||||
{
|
||||
QMutexLocker locker (&lock ());
|
||||
tl::MutexLocker locker (&lock ());
|
||||
|
||||
if (mp_t) {
|
||||
Object *told = mp_t;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
#include "tlCommon.h"
|
||||
|
||||
#include "tlAssert.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include "tlThreads.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
|
@ -232,7 +230,7 @@ private:
|
|||
Object *mp_t;
|
||||
bool m_is_shared : 1;
|
||||
bool m_is_event : 1;
|
||||
static QMutex &lock ();
|
||||
static tl::Mutex &lock ();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#include "tlObject.h"
|
||||
#include "tlEvents.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include "tlThreads.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
|
@ -435,11 +434,11 @@ public:
|
|||
|
||||
private:
|
||||
friend class holder_type;
|
||||
QMutex m_lock;
|
||||
tl::Mutex m_lock;
|
||||
|
||||
void remove_element (holder_type *h)
|
||||
{
|
||||
QMutexLocker locker (&m_lock);
|
||||
tl::MutexLocker locker (&m_lock);
|
||||
tl_assert (! empty ());
|
||||
m_about_to_change ();
|
||||
erase (h);
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
#include "tlProgress.h"
|
||||
#include "tlString.h"
|
||||
#include "tlAssert.h"
|
||||
|
||||
#include <QThreadStorage>
|
||||
#include <QThread>
|
||||
#include "tlThreads.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -65,7 +63,7 @@ ProgressAdaptor::prev ()
|
|||
|
||||
// Hint: we don't want the QThreadStorage take ownership over the object. Hence we don't
|
||||
// store a pointer but a pointer to a pointer.
|
||||
static QThreadStorage<ProgressAdaptor **> s_thread_data;
|
||||
static tl::ThreadStorage<ProgressAdaptor **> s_thread_data;
|
||||
|
||||
Progress::Progress (const std::string &desc, size_t yield_interval)
|
||||
: m_desc (desc), m_title (desc),
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ ScriptError::basic_msg () const
|
|||
{
|
||||
std::string m = tl::Exception::msg ();
|
||||
if (! m_context.empty ()) {
|
||||
m += tl::to_string (QObject::tr (" in ")) + m_context;
|
||||
m += tl::to_string (tr (" in ")) + m_context;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -36,12 +37,14 @@
|
|||
#include "tlHttpStream.h"
|
||||
#include "tlDeflate.h"
|
||||
#include "tlAssert.h"
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
#include "tlException.h"
|
||||
#include "tlString.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#if defined(HAVE_QT)
|
||||
# include <QUrl>
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -54,7 +57,7 @@ class FileWriteErrorException
|
|||
{
|
||||
public:
|
||||
FileWriteErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Write error on file: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Write error on file: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -63,7 +66,7 @@ class FileReadErrorException
|
|||
{
|
||||
public:
|
||||
FileReadErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Read error on file: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Read error on file: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +75,7 @@ class ZLibWriteErrorException
|
|||
{
|
||||
public:
|
||||
ZLibWriteErrorException (const std::string &f, const char *em)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Write error on file in decompression library: %s (message=%s)")), f, em)
|
||||
: tl::Exception (tl::to_string (tr ("Write error on file in decompression library: %s (message=%s)")), f, em)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ class ZLibReadErrorException
|
|||
{
|
||||
public:
|
||||
ZLibReadErrorException (const std::string &f, const char *em)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Read error on file in decompression library: %s (message=%s)")), f, em)
|
||||
: tl::Exception (tl::to_string (tr ("Read error on file in decompression library: %s (message=%s)")), f, em)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -90,7 +93,7 @@ class FileOpenErrorException
|
|||
{
|
||||
public:
|
||||
FileOpenErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Unable to open file: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Unable to open file: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -99,7 +102,7 @@ class FilePOpenErrorException
|
|||
{
|
||||
public:
|
||||
FilePOpenErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Unable to get input from command through pipe: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Unable to get input from command through pipe: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -108,7 +111,7 @@ class FilePReadErrorException
|
|||
{
|
||||
public:
|
||||
FilePReadErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Read error on pipe from command: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Read error on pipe from command: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -117,7 +120,7 @@ class FilePWriteErrorException
|
|||
{
|
||||
public:
|
||||
FilePWriteErrorException (const std::string &f, int en)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Write error on pipe from command: %s (errno=%d)")), f, en)
|
||||
: tl::Exception (tl::to_string (tr ("Write error on pipe from command: %s (errno=%d)")), f, en)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -327,16 +330,24 @@ InputStream::InputStream (const std::string &abstract_path)
|
|||
mp_buffer = new char [m_bcap];
|
||||
|
||||
tl::Extractor ex (abstract_path.c_str ());
|
||||
#if defined(HAVE_CURL) || defined(HAVE_QT)
|
||||
if (ex.test ("http:") || ex.test ("https:")) {
|
||||
mp_delegate = new InputHttpStream (abstract_path);
|
||||
#ifndef _WIN32 // not available on Windows
|
||||
} else if (ex.test ("pipe:")) {
|
||||
mp_delegate = new InputPipe (ex.get ());
|
||||
} else
|
||||
#endif
|
||||
} else if (ex.test ("file:")) {
|
||||
#if !defined (_WIN32) // not available on Windows
|
||||
if (ex.test ("pipe:")) {
|
||||
mp_delegate = new InputPipe (ex.get ());
|
||||
} else
|
||||
#endif
|
||||
#if defined(HAVE_QT)
|
||||
// TODO: provide a substitute for QUrl
|
||||
if (ex.test ("file:")) {
|
||||
QUrl url (tl::to_qstring (abstract_path));
|
||||
mp_delegate = new InputZLibFile (tl::to_string (url.toLocalFile ()));
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
mp_delegate = new InputZLibFile (abstract_path);
|
||||
}
|
||||
|
||||
|
|
@ -350,15 +361,18 @@ std::string InputStream::absolute_path (const std::string &abstract_path)
|
|||
tl::Extractor ex (abstract_path.c_str ());
|
||||
if (ex.test ("http:") || ex.test ("https:")) {
|
||||
return abstract_path;
|
||||
#ifndef _WIN32 // not available on Windows
|
||||
#if !defined(_WIN32) // not available on Windows
|
||||
} else if (ex.test ("pipe:")) {
|
||||
return abstract_path;
|
||||
#endif
|
||||
#if defined(HAVE_QT)
|
||||
// TODO: provide a substitute for QUrl
|
||||
} else if (ex.test ("file:")) {
|
||||
QUrl url (tl::to_qstring (abstract_path));
|
||||
return tl::to_string (QFileInfo (url.toLocalFile ()).absoluteFilePath ());
|
||||
#endif
|
||||
} else {
|
||||
return tl::to_string (QFileInfo (tl::to_qstring (abstract_path)).absoluteFilePath ());
|
||||
return tl::absolute_file_path (abstract_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -698,13 +712,13 @@ InputFile::reset ()
|
|||
std::string
|
||||
InputFile::absolute_path () const
|
||||
{
|
||||
return tl::to_string (QFileInfo (tl::to_qstring (m_source)).absoluteFilePath ());
|
||||
return tl::absolute_file_path (m_source);
|
||||
}
|
||||
|
||||
std::string
|
||||
InputFile::filename () const
|
||||
{
|
||||
return tl::to_string (QFileInfo (tl::to_qstring (m_source)).fileName ());
|
||||
return tl::filename (m_source);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
@ -771,13 +785,13 @@ InputZLibFile::reset ()
|
|||
std::string
|
||||
InputZLibFile::absolute_path () const
|
||||
{
|
||||
return tl::to_string (QFileInfo (tl::to_qstring (m_source)).absoluteFilePath ());
|
||||
return tl::absolute_file_path (m_source);
|
||||
}
|
||||
|
||||
std::string
|
||||
InputZLibFile::filename () const
|
||||
{
|
||||
return tl::to_string (QFileInfo (tl::to_qstring (m_source)).fileName ());
|
||||
return tl::filename (m_source);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
|
@ -964,7 +978,7 @@ OutputStream::OutputStream (const std::string &abstract_path, OutputStreamMode o
|
|||
|
||||
tl::Extractor ex (abstract_path.c_str ());
|
||||
if (ex.test ("http:") || ex.test ("https:")) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Cannot write to http:, https: or pipe: URL's")));
|
||||
throw tl::Exception (tl::to_string (tr ("Cannot write to http:, https: or pipe: URL's")));
|
||||
#ifndef _WIN32 // not available on Windows
|
||||
} else if (ex.test ("pipe:")) {
|
||||
mp_delegate = new OutputPipe (ex.get ());
|
||||
|
|
@ -1213,7 +1227,7 @@ InputPipe::read (char *b, size_t n)
|
|||
void
|
||||
InputPipe::reset ()
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("'reset' is not supported on pipeline input files")));
|
||||
throw tl::Exception (tl::to_string (tr ("'reset' is not supported on pipeline input files")));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
@ -1267,19 +1281,19 @@ InputPipe::~InputPipe ()
|
|||
size_t
|
||||
InputPipe::read (char * /*b*/, size_t /*n*/)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("pipeline input files not available on Windows")));
|
||||
throw tl::Exception (tl::to_string (tr ("pipeline input files not available on Windows")));
|
||||
}
|
||||
|
||||
void
|
||||
InputPipe::reset ()
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("pipeline input files not available on Windows")));
|
||||
throw tl::Exception (tl::to_string (tr ("pipeline input files not available on Windows")));
|
||||
}
|
||||
|
||||
void
|
||||
InputPipe::close ()
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("pipeline input files not available on Windows")));
|
||||
throw tl::Exception (tl::to_string (tr ("pipeline input files not available on Windows")));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
@ -1298,7 +1312,7 @@ OutputPipe::~OutputPipe ()
|
|||
void
|
||||
OutputPipe::write (const char * /*b*/, size_t /*n*/)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("pipeline input files not available on Windows")));
|
||||
throw tl::Exception (tl::to_string (tr ("pipeline input files not available on Windows")));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <limits>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <cwctype>
|
||||
|
||||
#include "tlString.h"
|
||||
#include "tlExpression.h"
|
||||
|
|
@ -36,6 +37,81 @@
|
|||
|
||||
static std::locale c_locale ("C");
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Conversion of UTF8 to wchar_t
|
||||
|
||||
static std::vector<wchar_t> utf8_to_wchar (const std::string &s)
|
||||
{
|
||||
std::vector<wchar_t> ws;
|
||||
|
||||
const char *cpe = s.c_str () + s.size ();
|
||||
for (const char *cp = s.c_str (); cp < cpe; ) {
|
||||
|
||||
uint32_t c32 = (unsigned char) *cp++;
|
||||
if (c32 >= 0xf0 && cp + 2 < cpe) {
|
||||
c32 = (c32 << 18) | ((uint32_t (cp [0]) & 0x3f) << 12) | ((uint32_t (cp [1]) & 0x3f) << 6) | (uint32_t (cp [2]) & 0x3f);
|
||||
cp += 3;
|
||||
} else if (c32 >= 0xe0 && cp + 1 < cpe) {
|
||||
c32 = (c32 << 12) | ((uint32_t (cp [0]) & 0x3f) << 6) | (uint32_t (cp [1]) & 0x3f);
|
||||
cp += 2;
|
||||
} else if (c32 >= 0xc0 && cp < cpe) {
|
||||
c32 = (c32 << 6) | (uint32_t (*cp) & 0x3f);
|
||||
++cp;
|
||||
}
|
||||
|
||||
if (c32 >= 0x10000) {
|
||||
c32 -= 0x10000;
|
||||
ws.push_back (wchar_t (0xd800 + (c32 >> 10)));
|
||||
ws.push_back (wchar_t (0xdc00 + (c32 & 0x3ff)));
|
||||
} else {
|
||||
ws.push_back (wchar_t (c32));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
static std::string wchar_to_utf8 (const std::vector<wchar_t> &ws)
|
||||
{
|
||||
std::string s;
|
||||
|
||||
for (std::vector<wchar_t>::const_iterator c = ws.begin (); c != ws.end (); ++c) {
|
||||
|
||||
uint32_t c32 = *c;
|
||||
if (c32 >= 0xd800 && c + 1 < ws.end ()) {
|
||||
++c;
|
||||
c32 = (c32 & 0x3ff) << 10;
|
||||
c32 |= uint32_t (*c) & 0x3ff;
|
||||
}
|
||||
|
||||
if (c32 >= 0x10000) {
|
||||
|
||||
s.push_back (0xf0 | ((c32 >> 18) & 0x7));
|
||||
s.push_back (0x80 | ((c32 >> 12) & 0x3f));
|
||||
s.push_back (0x80 | ((c32 >> 6) & 0x3f));
|
||||
s.push_back (0x80 | (c32 & 0x3f));
|
||||
|
||||
} else if (c32 >= 0x800) {
|
||||
|
||||
s.push_back (0xf0 | ((c32 >> 12) & 0xf));
|
||||
s.push_back (0x80 | ((c32 >> 6) & 0x3f));
|
||||
s.push_back (0x80 | (c32 & 0x3f));
|
||||
|
||||
} else if (c32 >= 0x80) {
|
||||
|
||||
s.push_back (0xf0 | ((c32 >> 6) & 0xc));
|
||||
s.push_back (0x80 | (c32 & 0x3f));
|
||||
|
||||
} else {
|
||||
s.push_back (char (c32));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Utility: a strtod version that is independent of the locale
|
||||
|
||||
|
|
@ -64,12 +140,44 @@ std::string tl::db_to_string (double d)
|
|||
|
||||
std::string tl::to_upper_case (const std::string &s)
|
||||
{
|
||||
return tl::to_string (tl::to_qstring (s).toUpper ());
|
||||
std::vector<wchar_t> ws = utf8_to_wchar (s);
|
||||
for (std::vector<wchar_t>::iterator c = ws.begin (); c != ws.end (); ++c) {
|
||||
*c = towupper (*c);
|
||||
}
|
||||
return wchar_to_utf8 (ws);
|
||||
}
|
||||
|
||||
std::string tl::to_lower_case (const std::string &s)
|
||||
{
|
||||
return tl::to_string (tl::to_qstring (s).toLower ());
|
||||
std::vector<wchar_t> ws = utf8_to_wchar (s);
|
||||
for (std::vector<wchar_t>::iterator c = ws.begin (); c != ws.end (); ++c) {
|
||||
*c = towlower (*c);
|
||||
}
|
||||
return wchar_to_utf8 (ws);
|
||||
}
|
||||
|
||||
std::string to_string_from_local (const char *cp)
|
||||
{
|
||||
mbstate_t state;
|
||||
memset ((void *) &state, 0, sizeof (mbstate_t));
|
||||
|
||||
std::vector<wchar_t> ws;
|
||||
|
||||
size_t max = strlen (cp);
|
||||
|
||||
while (max > 0) {
|
||||
wchar_t wc;
|
||||
// NOTE: mbrtowc uses the current LOCALE, hence "local"
|
||||
int length = mbrtowc (&wc, cp, max, &state);
|
||||
if (length < 1) {
|
||||
break;
|
||||
}
|
||||
ws.push_back (wc);
|
||||
cp += length;
|
||||
max -= length;
|
||||
}
|
||||
|
||||
return wchar_to_utf8 (ws);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -575,7 +683,7 @@ tl::from_string (const std::string &s, double &v) throw (tl::Exception)
|
|||
++cp;
|
||||
}
|
||||
if (! *cp) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Got empty string where a real number was expected")));
|
||||
throw tl::Exception (tl::to_string (tr ("Got empty string where a real number was expected")));
|
||||
}
|
||||
const char *cp_end = cp;
|
||||
v = local_strtod (cp, cp_end);
|
||||
|
|
@ -596,14 +704,14 @@ convert_string_to_int (const std::string &s, T &v) throw (tl::Exception)
|
|||
// HACK: this should be some real string-to-int conversion
|
||||
tl::from_string (s, x);
|
||||
if (x < std::numeric_limits <T>::min ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Range underflow: ")) + s);
|
||||
throw tl::Exception (tl::to_string (tr ("Range underflow: ")) + s);
|
||||
}
|
||||
if (x > std::numeric_limits <T>::max ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Range overflow: ")) + s);
|
||||
throw tl::Exception (tl::to_string (tr ("Range overflow: ")) + s);
|
||||
}
|
||||
v = T (x);
|
||||
if (x != v) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Number cannot be represented precisely: ")) + s);
|
||||
throw tl::Exception (tl::to_string (tr ("Number cannot be represented precisely: ")) + s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -656,7 +764,7 @@ tl::from_string (const std::string &s, bool &b) throw (tl::Exception)
|
|||
} else if (t == "0") {
|
||||
b = false;
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid boolean value: ")) + s);
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid boolean value: ")) + s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -727,7 +835,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (unsigned int &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected an unsigned integer value")));
|
||||
error (tl::to_string (tr ("Expected an unsigned integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -736,7 +844,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (unsigned long &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected an unsigned long integer value")));
|
||||
error (tl::to_string (tr ("Expected an unsigned long integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -745,7 +853,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (unsigned long long &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected an unsigned long integer value")));
|
||||
error (tl::to_string (tr ("Expected an unsigned long integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -754,7 +862,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (double &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a real number")));
|
||||
error (tl::to_string (tr ("Expected a real number")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -763,7 +871,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (int &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a integer value")));
|
||||
error (tl::to_string (tr ("Expected a integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -772,7 +880,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (long &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a long integer value")));
|
||||
error (tl::to_string (tr ("Expected a long integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -781,7 +889,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (long long &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a long integer value")));
|
||||
error (tl::to_string (tr ("Expected a long integer value")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -790,7 +898,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (bool &value)
|
||||
{
|
||||
if (! try_read (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a boolean value ('true', 'false')")));
|
||||
error (tl::to_string (tr ("Expected a boolean value ('true', 'false')")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -799,7 +907,7 @@ tl::Extractor &
|
|||
tl::Extractor::read (std::string &value, const char *term)
|
||||
{
|
||||
if (! try_read (value, term)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a string")));
|
||||
error (tl::to_string (tr ("Expected a string")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -808,7 +916,7 @@ tl::Extractor &
|
|||
tl::Extractor::read_word (std::string &value, const char *non_term)
|
||||
{
|
||||
if (! try_read_word (value, non_term)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a word string")));
|
||||
error (tl::to_string (tr ("Expected a word string")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -817,7 +925,7 @@ tl::Extractor &
|
|||
tl::Extractor::read_word_or_quoted (std::string &value, const char *non_term)
|
||||
{
|
||||
if (! try_read_word (value, non_term) && ! try_read_quoted (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a word or quoted string")));
|
||||
error (tl::to_string (tr ("Expected a word or quoted string")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -826,7 +934,7 @@ tl::Extractor &
|
|||
tl::Extractor::read_quoted (std::string &value)
|
||||
{
|
||||
if (! try_read_quoted (value)) {
|
||||
error (tl::to_string (QObject::tr ("Expected a quoted string")));
|
||||
error (tl::to_string (tr ("Expected a quoted string")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -839,7 +947,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on long long integer"));
|
||||
return tl::to_string (tr ("Range overflow on long long integer"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -847,7 +955,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on unsigned long long integer"));
|
||||
return tl::to_string (tr ("Range overflow on unsigned long long integer"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -855,7 +963,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on long integer"));
|
||||
return tl::to_string (tr ("Range overflow on long integer"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -863,7 +971,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on unsigned long integer"));
|
||||
return tl::to_string (tr ("Range overflow on unsigned long integer"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -871,7 +979,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on integer"));
|
||||
return tl::to_string (tr ("Range overflow on integer"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -879,7 +987,7 @@ namespace
|
|||
{
|
||||
std::string operator() () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Range overflow on unsigned integer"));
|
||||
return tl::to_string (tr ("Range overflow on unsigned integer"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1096,7 +1204,7 @@ tl::Extractor &
|
|||
tl::Extractor::expect_end ()
|
||||
{
|
||||
if (! at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Expected end of text")));
|
||||
error (tl::to_string (tr ("Expected end of text")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1105,7 +1213,7 @@ tl::Extractor &
|
|||
tl::Extractor::expect_more ()
|
||||
{
|
||||
if (at_end ()) {
|
||||
error (tl::to_string (QObject::tr ("Expected more text")));
|
||||
error (tl::to_string (tr ("Expected more text")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1114,7 +1222,7 @@ tl::Extractor &
|
|||
tl::Extractor::expect (const char *token)
|
||||
{
|
||||
if (! test (token)) {
|
||||
error (tl::sprintf (tl::to_string (QObject::tr ("Expected '%s'")).c_str (), token));
|
||||
error (tl::sprintf (tl::to_string (tr ("Expected '%s'")).c_str (), token));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1156,9 +1264,9 @@ tl::Extractor::error (const std::string &msg)
|
|||
std::string m (msg);
|
||||
|
||||
if (at_end ()) {
|
||||
m += tl::to_string (QObject::tr (", but text ended"));
|
||||
m += tl::to_string (tr (", but text ended"));
|
||||
} else {
|
||||
m += tl::to_string (QObject::tr (" here: "));
|
||||
m += tl::to_string (tr (" here: "));
|
||||
const char *cp = m_cp;
|
||||
for (unsigned int i = 0; i < 10 && *cp; ++i, ++cp) {
|
||||
m += *cp;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue