mirror of https://github.com/KLayout/klayout.git
Merge pull request #2351 from KLayout/feature/issue-2337
Feature/issue 2337
This commit is contained in:
commit
54973f5813
|
|
@ -8,6 +8,7 @@ DEFINES += MAKE_DB_LIBRARY
|
|||
|
||||
SOURCES = \
|
||||
dbArray.cc \
|
||||
dbBinarySerialize.cc \
|
||||
dbBox.cc \
|
||||
dbBoxConvert.cc \
|
||||
dbBoxScanner.cc \
|
||||
|
|
@ -248,6 +249,7 @@ SOURCES = \
|
|||
|
||||
HEADERS = \
|
||||
dbArray.h \
|
||||
dbBinarySerialize.h \
|
||||
dbBoxConvert.h \
|
||||
dbBox.h \
|
||||
dbBoxScanner.h \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2026 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
||||
// .. nothing yet ..
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,623 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2026 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HDR_dbBinarySerialize
|
||||
#define HDR_dbBinarySerialize
|
||||
|
||||
#include "dbCommon.h"
|
||||
|
||||
#include "dbPoint.h"
|
||||
#include "dbVector.h"
|
||||
#include "dbEdge.h"
|
||||
#include "dbEdgePair.h"
|
||||
#include "dbPolygon.h"
|
||||
#include "dbBox.h"
|
||||
#include "dbPath.h"
|
||||
#include "dbTrans.h"
|
||||
#include "dbText.h"
|
||||
#include "dbObjectWithProperties.h"
|
||||
|
||||
#include "tlBinaryStream.h"
|
||||
#include "tlException.h"
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Stream inserters
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_coord (tl::BinaryOutputStream &s, C c)
|
||||
{
|
||||
return s << c;
|
||||
}
|
||||
|
||||
inline tl::BinaryOutputStream &write_coord (tl::BinaryOutputStream &s, db::Coord c)
|
||||
{
|
||||
// NOTE: for compatibility across different builds we use 64 bit coordinates always
|
||||
return s << (int64_t) c;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_binary (tl::BinaryOutputStream &s, const db::point<C> &pt)
|
||||
{
|
||||
return write_coord (write_coord (s, pt.x ()), pt.y ());
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_binary (tl::BinaryOutputStream &s, const db::vector<C> &v)
|
||||
{
|
||||
return write_coord (write_coord (s, v.x ()), v.y ());
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::point<C> &pt)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
return write_binary (s, pt);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::vector<C> &v)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
return write_binary (s, v);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_binary (tl::BinaryOutputStream &s, const db::edge<C> &e)
|
||||
{
|
||||
write_binary (s, e.p1 ());
|
||||
write_binary (s, e.p2 ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::edge<C> &e)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
return write_binary (s, e);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::box<C> &b)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
write_binary (s, b.p1 ());
|
||||
write_binary (s, b.p2 ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::edge_pair<C> &ep)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
write_binary (s, ep.first ());
|
||||
write_binary (s, ep.second ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_binary (tl::BinaryOutputStream &s, const db::polygon_contour<C> &c)
|
||||
{
|
||||
s << (uint64_t) c.size ();
|
||||
for (auto i = c.begin (); i != c.end (); ++i) {
|
||||
write_binary (s, *i);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::polygon<C> &p)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
s << (uint64_t) (p.holes () + 1);
|
||||
for (size_t h = 0; h < p.holes () + 1; ++h) {
|
||||
write_binary (s, p.contour (h));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::simple_polygon<C> &p)
|
||||
{
|
||||
// NOTE: the format of polygon and simple polygon are compatible
|
||||
s << (uint16_t) 1; // version
|
||||
s << (uint64_t) 1; // number of contours
|
||||
write_binary (s, p.hull ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::unit_trans<C> &)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::disp_trans<C> &t)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
write_binary (s, t.disp ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &write_binary (tl::BinaryOutputStream &s, const db::simple_trans<C> &t)
|
||||
{
|
||||
s << (uint16_t) t.rot ();
|
||||
write_binary (s, t.disp ());
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::simple_trans<C> &t)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
return write_binary (s, t);
|
||||
}
|
||||
|
||||
template<class C, class D, class R>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::complex_trans<C, D, R> &t)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
write_binary (s, t.disp ());
|
||||
return s << (double) t.msin () << (double) t.mcos () << (double) (t.is_mirror () ? -t.mag () : t.mag ());
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::text<C> &t)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
s << t.string ();
|
||||
write_binary (s, t.trans ());
|
||||
write_coord (s, t.size ());
|
||||
return s << (int32_t) t.font () << (int32_t) t.halign () << (int32_t) t.valign ();
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::path<C> &p)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
s << (uint64_t) p.points ();
|
||||
for (auto i = p.begin (); i != p.end (); ++i) {
|
||||
write_binary (s, *i);
|
||||
}
|
||||
write_coord (s, p.width ());
|
||||
write_coord (s, p.bgn_ext ());
|
||||
write_coord (s, p.end_ext ());
|
||||
s << p.round ();
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
tl::BinaryOutputStream &operator<< (tl::BinaryOutputStream &s, const db::object_with_properties<T> &o)
|
||||
{
|
||||
s << (uint16_t) 1; // version
|
||||
|
||||
s << (const T &) o;
|
||||
|
||||
const auto &ps = db::properties (o.properties_id ());
|
||||
|
||||
s << (uint64_t) ps.size ();
|
||||
for (auto i = ps.begin (); i != ps.end (); ++i) {
|
||||
s << db::property_name (i->first) << db::property_value (i->second);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Stream extractors
|
||||
|
||||
class FutureBinarySerializationFormatException
|
||||
: public tl::Exception
|
||||
{
|
||||
public:
|
||||
FutureBinarySerializationFormatException ()
|
||||
: tl::Exception (tl::to_string (tr ("Binary serialization format version is too new for this build")))
|
||||
{ }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_coord (tl::BinaryInputStream &s, C &c)
|
||||
{
|
||||
return s >> c;
|
||||
}
|
||||
|
||||
inline tl::BinaryInputStream &read_coord (tl::BinaryInputStream &s, db::Coord &c)
|
||||
{
|
||||
// NOTE: for compatibility across different builds we use 64 bit coordinates always
|
||||
int64_t cc = 0;
|
||||
s >> cc;
|
||||
c = cc;
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_binary (tl::BinaryInputStream &s, db::point<C> &pt)
|
||||
{
|
||||
C x = 0, y = 0;
|
||||
read_coord (s, x);
|
||||
read_coord (s, y);
|
||||
pt = db::point<C> (x, y);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_binary (tl::BinaryInputStream &s, db::vector<C> &v)
|
||||
{
|
||||
C x = 0, y = 0;
|
||||
read_coord (s, x);
|
||||
read_coord (s, y);
|
||||
v = db::vector<C> (x, y);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::point<C> &pt)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
return read_binary (s, pt);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::vector<C> &v)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
return read_binary (s, v);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_binary (tl::BinaryInputStream &s, db::edge<C> &v)
|
||||
{
|
||||
db::point<C> p1, p2;
|
||||
read_binary (s, p1);
|
||||
read_binary (s, p2);
|
||||
v = db::edge<C> (p1, p2);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::edge<C> &e)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
return read_binary (s, e);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::box<C> &b)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
db::point<C> p1, p2;
|
||||
read_binary (s, p1);
|
||||
read_binary (s, p2);
|
||||
b = db::box<C> (p1, p2);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::edge_pair<C> &ep)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
db::edge<C> e1, e2;
|
||||
read_binary (s, e1);
|
||||
read_binary (s, e2);
|
||||
ep = db::edge_pair<C> (e1, e2);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_binary (tl::BinaryInputStream &s, db::polygon_contour<C> &c, bool hole)
|
||||
{
|
||||
uint64_t n = 0;
|
||||
s >> n;
|
||||
|
||||
std::vector<db::point<C> > pts;
|
||||
pts.reserve (n);
|
||||
while (n-- > 0) {
|
||||
pts.push_back (db::point<C> ());
|
||||
read_binary (s, pts.back ());
|
||||
}
|
||||
|
||||
// NOTE: not normalization or modification is applied
|
||||
c.assign (pts.begin (), pts.end (), hole, false, false, false);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::polygon<C> &p)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
uint64_t n = 0;
|
||||
s >> n;
|
||||
|
||||
p = db::polygon<C> ();
|
||||
if (n > 0) {
|
||||
p.reserve_holes (n - 1);
|
||||
}
|
||||
|
||||
db::polygon_contour<C> ctr;
|
||||
for (uint64_t h = 0; h < n; ++h) {
|
||||
read_binary (s, ctr, h > 0);
|
||||
if (h == 0) {
|
||||
p.assign_hull (ctr);
|
||||
} else {
|
||||
p.insert_hole (ctr);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::simple_polygon<C> &p)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
uint64_t n = 0;
|
||||
s >> n;
|
||||
tl_assert (n == (uint64_t) 1);
|
||||
|
||||
db::polygon_contour<C> ctr;
|
||||
read_binary (s, ctr, false);
|
||||
p.assign_hull (ctr);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::unit_trans<C> &)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::disp_trans<C> &t)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
db::vector<C> d;
|
||||
read_binary (s, d);
|
||||
t = db::disp_trans<C> (d);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &read_binary (tl::BinaryInputStream &s, db::simple_trans<C> &t)
|
||||
{
|
||||
uint16_t r = 0;
|
||||
s >> r;
|
||||
|
||||
db::vector<C> d;
|
||||
read_binary (s, d);
|
||||
|
||||
t = db::simple_trans<C> (r, d);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::simple_trans<C> &t)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
return read_binary (s, t);
|
||||
}
|
||||
|
||||
template<class C, class D, class R>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::complex_trans<C, D, R> &t)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
db::vector<R> d;
|
||||
read_binary (s, d);
|
||||
|
||||
double asin, acos, mag;
|
||||
s >> asin >> acos >> mag;
|
||||
|
||||
t = db::complex_trans<C, D, R> (d, asin, acos, mag);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::text<C> &t)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
std::string txt;
|
||||
s >> txt;
|
||||
|
||||
db::simple_trans<C> tr;
|
||||
read_binary (s, tr);
|
||||
|
||||
C size;
|
||||
read_coord (s, size);
|
||||
|
||||
int32_t font, halign, valign;
|
||||
s >> font >> halign >> valign;
|
||||
|
||||
t = db::text<C> (txt, tr, size, db::Font (font), db::HAlign (halign), db::VAlign (valign));
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::path<C> &p)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
uint64_t n = 0;
|
||||
s >> n;
|
||||
|
||||
std::vector<db::point<C> > pts;
|
||||
pts.reserve (n);
|
||||
while (n-- > 0) {
|
||||
pts.push_back (db::point<C> ());
|
||||
read_binary (s, pts.back ());
|
||||
}
|
||||
|
||||
C width, bgn_ext, end_ext;
|
||||
read_coord (s, width);
|
||||
read_coord (s, bgn_ext);
|
||||
read_coord (s, end_ext);
|
||||
|
||||
bool round;
|
||||
s >> round;
|
||||
|
||||
p = db::path<C> (pts.begin (), pts.end (), width, bgn_ext, end_ext, round);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
tl::BinaryInputStream &operator>> (tl::BinaryInputStream &s, db::object_with_properties<T> &o)
|
||||
{
|
||||
uint16_t fmt = 0;
|
||||
s >> fmt;
|
||||
if (fmt > 1) {
|
||||
throw FutureBinarySerializationFormatException ();
|
||||
}
|
||||
|
||||
s >> (T &) o;
|
||||
|
||||
uint64_t n = 0;
|
||||
s >> n;
|
||||
|
||||
db::PropertiesSet ps;
|
||||
|
||||
while (n-- > 0) {
|
||||
tl::Variant name, value;
|
||||
s >> name >> value;
|
||||
ps.insert (name, value);
|
||||
}
|
||||
|
||||
o.properties_id (db::properties_id (ps));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Converters of objects to a binary string
|
||||
|
||||
template<class T>
|
||||
std::vector<char> to_bytes (const T &t)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
{
|
||||
tl::BinaryOutputStream os (osm);
|
||||
os << t;
|
||||
}
|
||||
return std::vector<char> (osm.data (), osm.data () + osm.size ());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::string to_bytes_str (const T &t)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
{
|
||||
tl::BinaryOutputStream os (osm);
|
||||
os << t;
|
||||
}
|
||||
return std::string (osm.data (), osm.size ());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void from_bytes (const char *data, size_t n, T &t)
|
||||
{
|
||||
tl::InputMemoryStream ism (data, n);
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
bis >> t;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void from_bytes (const std::vector<char> &s, T &t)
|
||||
{
|
||||
tl::InputMemoryStream ism (s.begin ().operator-> (), s.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
bis >> t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -271,7 +271,7 @@ public:
|
|||
{
|
||||
std::string s = Obj::to_string ();
|
||||
s += " props=";
|
||||
s += db::properties (properties_id ()).to_dict_var ().to_string ();
|
||||
s += db::properties (properties_id ()).to_dict_var ().to_parsable_string ();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1625,6 +1625,17 @@ public:
|
|||
m_mag = s.is_mirror () ? -1.0 : 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Native constructor
|
||||
*
|
||||
* This constructor creates the objects from the native parameters (max, acos, asin and displacement)
|
||||
*/
|
||||
complex_trans (const vector<R> &disp, R asin, R acos, R mag)
|
||||
: m_u (disp), m_sin (asin), m_cos (acos), m_mag (mag)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Migration constructor from a simple transformation to a complex transformation
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbBox.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -50,6 +51,18 @@ struct box_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C world ()
|
||||
{
|
||||
return C::world ();
|
||||
|
|
@ -533,6 +546,19 @@ struct box_defs
|
|||
"If a DBU is given, the output units will be micrometers.\n"
|
||||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a box object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this box\n"
|
||||
"\n"
|
||||
"This string can be turned into a box again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbEdge.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -53,6 +54,18 @@ struct edge_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -446,6 +459,19 @@ struct edge_defs
|
|||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates an edge object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this edge\n"
|
||||
"\n"
|
||||
"This string can be turned into an edge again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method ("is_parallel?", &C::parallel, gsi::arg ("e"),
|
||||
"@brief Test for being parallel\n"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "dbEdgePair.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -50,6 +51,18 @@ struct edge_pair_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -167,6 +180,19 @@ struct edge_pair_defs
|
|||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates an edge pair object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this edge pair\n"
|
||||
"\n"
|
||||
"This string can be turned into an edge pair again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method ("bbox", &C::bbox,
|
||||
"@brief Gets the bounding box of the edge pair\n"
|
||||
) +
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbPath.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -59,6 +60,18 @@ struct path_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -284,6 +297,19 @@ struct path_defs
|
|||
method ("to_s", (std::string (C::*) () const) &C::to_string,
|
||||
"@brief Convert to a string\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a path object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this path\n"
|
||||
"\n"
|
||||
"This string can be turned into a path again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method ("simple_polygon", &C::simple_polygon,
|
||||
"@brief Convert the path to a simple polygon\n"
|
||||
"The returned polygon is not guaranteed to be non-selfoverlapping. This may happen if the path overlaps "
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbBox.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -46,6 +47,18 @@ struct point_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -320,6 +333,19 @@ struct point_defs
|
|||
"If a DBU is given, the output units will be micrometers.\n"
|
||||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a point object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this point\n"
|
||||
"\n"
|
||||
"This string can be turned into a point again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "dbHash.h"
|
||||
#include "dbPLCTriangulation.h"
|
||||
#include "dbPLCConvexDecomposition.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -307,6 +308,18 @@ struct simple_polygon_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C;
|
||||
|
|
@ -702,6 +715,19 @@ struct simple_polygon_defs
|
|||
method ("to_s", (std::string (C::*) () const) &C::to_string,
|
||||
"@brief Returns a string representing the polygon\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a polygon object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this polygon\n"
|
||||
"\n"
|
||||
"This string can be turned into a polygon again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("round_corners", &round_corners, gsi::arg ("rinner"), gsi::arg ("router"), gsi::arg ("n"),
|
||||
"@brief Rounds the corners of the polygon\n"
|
||||
"\n"
|
||||
|
|
@ -1298,6 +1324,18 @@ struct polygon_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C;
|
||||
|
|
@ -1854,6 +1892,19 @@ struct polygon_defs
|
|||
method ("to_s", (std::string (C::*) () const) &C::to_string,
|
||||
"@brief Returns a string representing the polygon\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a polygon object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this polygon\n"
|
||||
"\n"
|
||||
"This string can be turned into a polygon again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("round_corners", &round_corners, gsi::arg ("rinner"), gsi::arg ("router"), gsi::arg ("n"),
|
||||
"@brief Rounds the corners of the polygon\n"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -27,12 +27,36 @@
|
|||
#include "tlTypeTraits.h"
|
||||
#include "dbPropertiesRepository.h"
|
||||
#include "dbObjectWithProperties.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
#include "dbTrans.h"
|
||||
#include "dbEdge.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
template <class T>
|
||||
static T *from_string (const std::string &s)
|
||||
{
|
||||
tl::Extractor ex (s);
|
||||
std::unique_ptr<T> t (new T ());
|
||||
ex.read (*t.get ());
|
||||
return t.release ();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static T *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<T> t (new T ());
|
||||
db::from_bytes (s, *t);
|
||||
return t.release ();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static std::vector<char> to_bytes (const T *t)
|
||||
{
|
||||
return db::to_bytes (*t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void delete_property_meth_impl (T *s, const tl::Variant &key)
|
||||
{
|
||||
|
|
@ -250,8 +274,27 @@ static gsi::Methods properties_support_methods ()
|
|||
"If no property with that key does not exist, it will return nil. Using that method is more "
|
||||
"convenient than using the layout object and the properties ID to retrieve the property value. "
|
||||
) +
|
||||
gsi::constructor ("from_s", &from_string<T>, gsi::arg ("s"),
|
||||
"@brief Creates an object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
gsi::method ("to_s", (std::string (T::*) () const) &T::to_string,
|
||||
"@brief Returns a string representing the polygon\n"
|
||||
"@brief Returns a string representing the object\n"
|
||||
) +
|
||||
gsi::constructor ("from_bytes", &from_bytes<T>, gsi::arg ("s"),
|
||||
"@brief Creates an object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
gsi::method_ext ("to_bytes", &to_bytes<T>,
|
||||
"@brief Returns a binary string representing this object\n"
|
||||
"\n"
|
||||
"This string can be turned into an object again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
gsi::method_ext ("properties", &get_properties_meth_impl<T>,
|
||||
"@brief Gets the user properties\n"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbText.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -52,6 +53,18 @@ struct text_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -397,6 +410,19 @@ struct text_defs
|
|||
"If a DBU is given, the output units will be micrometers.\n"
|
||||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a text object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this text object\n"
|
||||
"\n"
|
||||
"This string can be turned into a text object again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "dbPath.h"
|
||||
#include "dbText.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -98,6 +99,18 @@ struct trans_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -518,6 +531,19 @@ struct trans_defs
|
|||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates an object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this object\n"
|
||||
"\n"
|
||||
"This string can be turned into an object again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method ("disp", (const vector_type &(C::*) () const) &C::disp,
|
||||
"@brief Gets to the displacement vector\n"
|
||||
"\n"
|
||||
|
|
@ -736,6 +762,18 @@ struct cplx_trans_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -1139,6 +1177,19 @@ struct cplx_trans_defs
|
|||
"\n"
|
||||
"The lazy and DBU arguments have been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates an object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this object\n"
|
||||
"\n"
|
||||
"This string can be turned into an object again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method ("disp", (displacement_type (C::*)() const) &C::disp,
|
||||
"@brief Gets the displacement\n"
|
||||
) +
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dbVector.h"
|
||||
#include "dbPoint.h"
|
||||
#include "dbHash.h"
|
||||
#include "dbBinarySerialize.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -45,6 +46,18 @@ struct vector_defs
|
|||
return c.release ();
|
||||
}
|
||||
|
||||
static C *from_bytes (const std::vector<char> &s)
|
||||
{
|
||||
std::unique_ptr<C> c (new C ());
|
||||
db::from_bytes (s, *c);
|
||||
return c.release ();
|
||||
}
|
||||
|
||||
static std::vector<char> to_bytes (const C *c)
|
||||
{
|
||||
return db::to_bytes (*c);
|
||||
}
|
||||
|
||||
static C *new_v ()
|
||||
{
|
||||
return new C ();
|
||||
|
|
@ -275,6 +288,19 @@ struct vector_defs
|
|||
"If a DBU is given, the output units will be micrometers.\n"
|
||||
"\n"
|
||||
"The DBU argument has been added in version 0.27.6.\n"
|
||||
) +
|
||||
constructor ("from_bytes", &from_bytes, gsi::arg ("s"),
|
||||
"@brief Creates a vector object from a binary serialization\n"
|
||||
"Creates the object from a binary representation (as returned by \\to_bytes)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
) +
|
||||
method_ext ("to_bytes", &to_bytes,
|
||||
"@brief Returns a binary string representing this vector\n"
|
||||
"\n"
|
||||
"This string can be turned into a vector again by using \\from_bytes\n. "
|
||||
"\n"
|
||||
"This method has been added in version 0.30.9.\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ TEST(1)
|
|||
|
||||
db::PolygonWithProperties pwp (db::Polygon (db::Box (0, 0, 100, 200)), db::properties_id (ps));
|
||||
|
||||
EXPECT_EQ (pwp.to_string (), "(0,0;0,200;100,200;100,0) props={1=>one,key=>42}");
|
||||
EXPECT_EQ (pwp.to_string (), "(0,0;0,200;100,200;100,0) props={#1=>'one','key'=>##42}");
|
||||
|
||||
db::PolygonWithProperties pwp2;
|
||||
|
||||
|
|
@ -43,11 +43,11 @@ TEST(1)
|
|||
|
||||
EXPECT_EQ (ex.try_read (pwp2), false);
|
||||
|
||||
s = " (0,0;0,200;100,200;100,0) props= {1 => \"one\", key => 42} ";
|
||||
s = " (0,0;0,200;100,200;100,0) props= {#1 => \"one\", 'key' => ##42} ";
|
||||
ex = tl::Extractor (s.c_str ());
|
||||
|
||||
EXPECT_EQ (ex.try_read (pwp2), true);
|
||||
EXPECT_EQ (pwp2.to_string (), "(0,0;0,200;100,200;100,0) props={1=>one,key=>42}");
|
||||
EXPECT_EQ (pwp2.to_string (), "(0,0;0,200;100,200;100,0) props={#1=>'one','key'=>##42}");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,5 +84,5 @@ TEST(1_RegionToEdgesProcessor)
|
|||
|
||||
result.clear ();
|
||||
db::PolygonToEdgeProcessor (db::PolygonToEdgeProcessor::StepIn).process (poly, result);
|
||||
EXPECT_EQ (tl::join (result.begin (), result.end (), ";"), "(0,1000;1000,1000) props={net=>17};(2000,2000;2000,1000) props={net=>17}");
|
||||
EXPECT_EQ (tl::join (result.begin (), result.end (), ";"), "(0,1000;1000,1000) props={'net'=>#17};(2000,2000;2000,1000) props={'net'=>#17}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2253,7 +2253,7 @@ TEST(52_PropertiesDeep)
|
|||
EXPECT_EQ (s.at_end (), false);
|
||||
|
||||
// polygons are merged with "maximum" property value
|
||||
EXPECT_EQ (db::PolygonWithProperties (*s, s.prop_id ()).to_string (), "(0,0;0,200;1,200;1,202;10,202;10,220;110,220;110,212;111,212;111,12;101,12;101,2;100,2;100,0) props={id=>42}");
|
||||
EXPECT_EQ (db::PolygonWithProperties (*s, s.prop_id ()).to_string (), "(0,0;0,200;1,200;1,202;10,202;10,220;110,220;110,212;111,212;111,12;101,12;101,2;100,2;100,0) props={'id'=>#42}");
|
||||
++s;
|
||||
|
||||
EXPECT_EQ (s.at_end (), true);
|
||||
|
|
@ -2395,7 +2395,7 @@ TEST(53_PropertiesDeepFromLayout)
|
|||
EXPECT_EQ (s.at_end (), false);
|
||||
|
||||
// polygons are merged with "maximum" property value
|
||||
EXPECT_EQ (db::PolygonWithProperties (*s, s.prop_id ()).to_string (), "(0,0;0,200;1,200;1,202;10,202;10,220;110,220;110,212;111,212;111,12;101,12;101,2;100,2;100,0) props={VALUE=>42}");
|
||||
EXPECT_EQ (db::PolygonWithProperties (*s, s.prop_id ()).to_string (), "(0,0;0,200;1,200;1,202;10,202;10,220;110,220;110,212;111,212;111,12;101,12;101,2;100,2;100,0) props={'VALUE'=>#42}");
|
||||
++s;
|
||||
|
||||
EXPECT_EQ (s.at_end (), true);
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ Bitmap::fill_pattern (int y, int x, const uint32_t *pp, unsigned int stride, uns
|
|||
uint32_t p = *pp;
|
||||
|
||||
int x1 = x + s * 32;
|
||||
if (x1 <= -32 || x1 >= m_width) {
|
||||
if (x1 <= -32 || x1 >= (int)m_width) {
|
||||
continue;
|
||||
} else if (x1 < 0) {
|
||||
p >>= (unsigned int)-x1;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ FORMS =
|
|||
SOURCES = \
|
||||
tlAssert.cc \
|
||||
tlBase64.cc \
|
||||
tlBinaryStream.cc \
|
||||
tlColor.cc \
|
||||
tlClassRegistry.cc \
|
||||
tlCopyOnWrite.cc \
|
||||
|
|
@ -62,6 +63,7 @@ HEADERS = \
|
|||
tlAlgorithm.h \
|
||||
tlAssert.h \
|
||||
tlBase64.h \
|
||||
tlBinaryStream.h \
|
||||
tlColor.h \
|
||||
tlClassRegistry.h \
|
||||
tlCopyOnWrite.h \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,691 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2026 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "tlBinaryStream.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Type codes for Variant serialization
|
||||
// These type codes are intentionally separated from tl::Variant's
|
||||
// type codes to allow a backward-compatible serialization scheme.
|
||||
|
||||
enum VariantTypeCode
|
||||
{
|
||||
var_type_nil = 0,
|
||||
var_type_bool = 1,
|
||||
var_type_char = 2,
|
||||
var_type_schar = 3,
|
||||
var_type_uchar = 4,
|
||||
var_type_short = 5,
|
||||
var_type_ushort = 6,
|
||||
var_type_int = 7,
|
||||
var_type_uint = 8,
|
||||
var_type_long = 9,
|
||||
var_type_ulong = 10,
|
||||
var_type_longlong = 11,
|
||||
var_type_ulonglong = 12,
|
||||
var_type_id = 13,
|
||||
var_type_float = 14,
|
||||
var_type_double = 15,
|
||||
var_type_string = 16,
|
||||
var_type_bytes = 17,
|
||||
var_type_list = 18,
|
||||
var_type_array = 19,
|
||||
|
||||
var_type_other = -1
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
class UnexpectedEndOfFileException
|
||||
: public tl::Exception
|
||||
{
|
||||
public:
|
||||
UnexpectedEndOfFileException (const std::string &f)
|
||||
: tl::Exception (tl::to_string (tr ("Unexpected end of file in: %s")), f)
|
||||
{ }
|
||||
};
|
||||
|
||||
class InvalidVariantTypeCode
|
||||
: public tl::Exception
|
||||
{
|
||||
public:
|
||||
InvalidVariantTypeCode (const std::string &f, int tc)
|
||||
: tl::Exception (tl::to_string (tr ("Invalid variant type code %d in file: %s - maybe file is too new for this build?")), tc, f)
|
||||
{ }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
BinaryInputStream::BinaryInputStream (InputStream &stream)
|
||||
: m_stream (stream)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
BinaryInputStream::reset ()
|
||||
{
|
||||
m_stream.reset ();
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (std::string &v)
|
||||
{
|
||||
uint64_t l = 0;
|
||||
*this >> l;
|
||||
|
||||
v.clear ();
|
||||
v.reserve (l);
|
||||
|
||||
size_t chunk_size = 1024, n = l;
|
||||
while (n > 0) {
|
||||
size_t chunk_len = std::min (n, chunk_size);
|
||||
const char *chunk_data = m_stream.get (chunk_len);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
v.append (chunk_data, chunk_len);
|
||||
n -= chunk_len;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (std::vector<char> &v)
|
||||
{
|
||||
uint64_t l = 0;
|
||||
*this >> l;
|
||||
|
||||
v.clear ();
|
||||
v.reserve (l);
|
||||
|
||||
size_t chunk_size = 1024, n = l;
|
||||
while (n > 0) {
|
||||
size_t chunk_len = std::min (n, chunk_size);
|
||||
const char *chunk_data = m_stream.get (chunk_len);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
v.insert (v.end (), chunk_data, chunk_data + chunk_len);
|
||||
n -= chunk_len;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (double &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (8);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const double *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (float &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (4);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const float *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (bool &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (1);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
v = *chunk_data != 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (uint8_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (1);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
v = (uint8_t) *chunk_data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (int8_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (1);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
v = (int8_t) *chunk_data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (uint16_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (2);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const uint16_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (int16_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (2);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const int16_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (uint32_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (4);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const uint32_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (int32_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (4);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const int32_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (uint64_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (8);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const uint64_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (int64_t &v)
|
||||
{
|
||||
const char *chunk_data = m_stream.get (8);
|
||||
if (! chunk_data) {
|
||||
throw UnexpectedEndOfFileException (source ());
|
||||
}
|
||||
// TODO: for now, we assume that file and memory layout are identical on all platforms
|
||||
v = *reinterpret_cast<const int64_t *> (chunk_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BinaryInputStream &
|
||||
BinaryInputStream::operator>> (tl::Variant &v)
|
||||
{
|
||||
int16_t var_type = -1;
|
||||
*this >> var_type;
|
||||
|
||||
switch (var_type) {
|
||||
case VariantTypeCode::var_type_nil:
|
||||
v = tl::Variant ();
|
||||
break;
|
||||
case VariantTypeCode::var_type_bool:
|
||||
{
|
||||
bool f = false;
|
||||
*this >> f;
|
||||
v = tl::Variant (f);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_char:
|
||||
{
|
||||
uint8_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((char) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_schar:
|
||||
{
|
||||
int8_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((signed char) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_uchar:
|
||||
{
|
||||
uint8_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((unsigned char) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_short:
|
||||
{
|
||||
int16_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((short) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_ushort:
|
||||
{
|
||||
uint16_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((unsigned short) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_int:
|
||||
{
|
||||
int32_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((int) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_uint:
|
||||
{
|
||||
uint32_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((unsigned int) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_long:
|
||||
{
|
||||
int64_t vv = 0;
|
||||
*this >> vv;
|
||||
if (vv >= (int64_t) std::numeric_limits<long>::min () && vv <= (int64_t) std::numeric_limits<long>::max ()) {
|
||||
v = tl::Variant ((long) vv);
|
||||
} else {
|
||||
// Linux to Windows migration
|
||||
v = tl::Variant ((long long) vv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_ulong:
|
||||
{
|
||||
uint64_t vv = 0;
|
||||
*this >> vv;
|
||||
if (vv >= (uint64_t) std::numeric_limits<unsigned long>::min () && vv <= (uint64_t) std::numeric_limits<unsigned long>::max ()) {
|
||||
v = tl::Variant ((unsigned long) vv);
|
||||
} else {
|
||||
// Linux to Windows migration
|
||||
v = tl::Variant ((unsigned long long) vv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case VariantTypeCode::var_type_longlong:
|
||||
{
|
||||
int64_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((long long) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_ulonglong:
|
||||
{
|
||||
uint64_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((unsigned long long) vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_id:
|
||||
{
|
||||
uint64_t vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant ((size_t) vv, true /*as id*/);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_float:
|
||||
{
|
||||
float vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant (vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_double:
|
||||
{
|
||||
double vv = 0;
|
||||
*this >> vv;
|
||||
v = tl::Variant (vv);
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_string:
|
||||
{
|
||||
std::string vv;
|
||||
*this >> vv;
|
||||
v = tl::Variant (std::move (vv));
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_bytes:
|
||||
{
|
||||
std::vector<char> vv;
|
||||
*this >> vv;
|
||||
v = tl::Variant (std::move (vv));
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_list:
|
||||
{
|
||||
uint64_t n = 0;
|
||||
*this >> n;
|
||||
v = tl::Variant::empty_list ();
|
||||
v.reserve (n);
|
||||
while (n-- > 0) {
|
||||
tl::Variant vv;
|
||||
*this >> vv;
|
||||
v.push (std::move (vv));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_array:
|
||||
{
|
||||
uint64_t n = 0;
|
||||
*this >> n;
|
||||
v = tl::Variant::empty_array ();
|
||||
while (n-- > 0) {
|
||||
tl::Variant vk, vv;
|
||||
*this >> vk;
|
||||
*this >> vv;
|
||||
v.insert (std::move (vk), std::move (vv));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VariantTypeCode::var_type_other:
|
||||
{
|
||||
std::string s;
|
||||
*this >> s;
|
||||
tl::Extractor ex (s.c_str ());
|
||||
v = tl::Variant ();
|
||||
ex.read (v);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw InvalidVariantTypeCode (source (), int (var_type));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// BinaryOutputStream implementation
|
||||
|
||||
BinaryOutputStream::BinaryOutputStream (OutputStreamBase &delegate)
|
||||
: OutputStream (delegate, false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
BinaryOutputStream::BinaryOutputStream (OutputStreamBase *delegate)
|
||||
: OutputStream (delegate, false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
BinaryOutputStream::BinaryOutputStream (const std::string &abstract_path, OutputStreamMode om, int keep_backups)
|
||||
: OutputStream (abstract_path, om, false, keep_backups)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (const char *s, size_t n)
|
||||
{
|
||||
// the native format for a string is a length field (uint64_t) and the bytes
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
uint64_t len = uint64_t (n);
|
||||
put_raw ((const char *) &len, 8);
|
||||
put_raw (s, n);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (const std::string &s)
|
||||
{
|
||||
// the native format for a string is a length field (uint64_t) and the bytes
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
uint64_t len = uint64_t (s.size ());
|
||||
put_raw ((const char *) &len, 8);
|
||||
put_raw (s.c_str (), s.size ());
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (double v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 8);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (float v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 4);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (bool v)
|
||||
{
|
||||
char c = v ? 1 : 0;
|
||||
put_raw (&c, 1);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (uint8_t v)
|
||||
{
|
||||
put_raw ((const char *) &v, 1);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (int8_t v)
|
||||
{
|
||||
put_raw ((const char *) &v, 1);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (uint16_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 2);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (int16_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 2);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (uint32_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 4);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (int32_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 4);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (uint64_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 8);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (int64_t v)
|
||||
{
|
||||
// TODO: for now we assume that the memory layout is the same for all platforms
|
||||
put_raw ((const char *) &v, 8);
|
||||
}
|
||||
|
||||
void
|
||||
BinaryOutputStream::put_native (const tl::Variant &v)
|
||||
{
|
||||
switch (v.type_code ()) {
|
||||
case tl::Variant::t_nil:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_nil);
|
||||
break;
|
||||
case tl::Variant::t_bool:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_bool);
|
||||
put_native (v.to_bool ());
|
||||
break;
|
||||
case tl::Variant::t_char:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_char);
|
||||
put_native ((uint8_t) v.to_char ());
|
||||
break;
|
||||
case tl::Variant::t_schar:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_schar);
|
||||
put_native ((int8_t) v.to_schar ());
|
||||
break;
|
||||
case tl::Variant::t_uchar:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_uchar);
|
||||
put_native ((uint8_t) v.to_uchar ());
|
||||
break;
|
||||
case tl::Variant::t_short:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_short);
|
||||
put_native ((int16_t) v.to_short ());
|
||||
break;
|
||||
case tl::Variant::t_ushort:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_ushort);
|
||||
put_native ((uint16_t) v.to_ushort ());
|
||||
break;
|
||||
case tl::Variant::t_int:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_int);
|
||||
put_native ((int32_t) v.to_int ());
|
||||
break;
|
||||
case tl::Variant::t_uint:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_uint);
|
||||
put_native ((uint32_t) v.to_uint ());
|
||||
break;
|
||||
case tl::Variant::t_long:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_long);
|
||||
// NOTE: "long" is always encoded as 64 bit for compatibility of Windows + Linux
|
||||
put_native ((int64_t) v.to_long ());
|
||||
break;
|
||||
case tl::Variant::t_ulong:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_ulong);
|
||||
// NOTE: "ulong" is always encoded as 64 bit for compatibility of Windows + Linux
|
||||
put_native ((uint64_t) v.to_ulong ());
|
||||
break;
|
||||
case tl::Variant::t_longlong:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_longlong);
|
||||
put_native ((int64_t) v.to_longlong ());
|
||||
break;
|
||||
case tl::Variant::t_ulonglong:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_ulonglong);
|
||||
put_native ((uint64_t) v.to_ulonglong ());
|
||||
break;
|
||||
case tl::Variant::t_id:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_id);
|
||||
// NOTE: "id" is always encoded as 64 bit
|
||||
put_native ((uint64_t) v.to_id ());
|
||||
break;
|
||||
case tl::Variant::t_float:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_float);
|
||||
put_native (v.to_float ());
|
||||
break;
|
||||
case tl::Variant::t_double:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_double);
|
||||
put_native (v.to_double ());
|
||||
break;
|
||||
case tl::Variant::t_string:
|
||||
case tl::Variant::t_stdstring:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_string);
|
||||
put_native (v.to_stdstring ());
|
||||
break;
|
||||
case tl::Variant::t_bytearray:
|
||||
#if defined(HAVE_QT)
|
||||
case tl::Variant::t_qstring:
|
||||
case tl::Variant::t_qbytearray:
|
||||
#endif
|
||||
{
|
||||
put_native ((int16_t) VariantTypeCode::var_type_bytes);
|
||||
std::vector<char> bytes = v.to_bytearray ();
|
||||
put_native (bytes.begin ().operator-> (), bytes.size ());
|
||||
}
|
||||
break;
|
||||
case tl::Variant::t_list:
|
||||
{
|
||||
put_native ((int16_t) VariantTypeCode::var_type_list);
|
||||
put_native ((uint64_t) v.size ());
|
||||
for (auto i = v.begin (); i != v.end (); ++i) {
|
||||
put_native (*i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case tl::Variant::t_array:
|
||||
{
|
||||
put_native ((int16_t) VariantTypeCode::var_type_array);
|
||||
put_native ((uint64_t) v.array_size ());
|
||||
for (auto i = v.begin_array (); i != v.end_array (); ++i) {
|
||||
put_native (i->first);
|
||||
put_native (i->second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
put_native ((int16_t) VariantTypeCode::var_type_other);
|
||||
put_native (v.to_parsable_string ());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2026 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HDR_tlBinaryStream
|
||||
#define HDR_tlBinaryStream
|
||||
|
||||
#include "tlCommon.h"
|
||||
#include "tlStream.h"
|
||||
#include "tlVariant.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief An output stream specialized on binary representation
|
||||
*/
|
||||
|
||||
class TL_PUBLIC BinaryOutputStream
|
||||
: public OutputStream
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*
|
||||
* This constructor takes a delegate object.
|
||||
*/
|
||||
BinaryOutputStream (OutputStreamBase &delegate);
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*
|
||||
* This constructor takes a delegate object. The stream will own the delegate.
|
||||
*/
|
||||
BinaryOutputStream (OutputStreamBase *delegate);
|
||||
|
||||
/**
|
||||
* @brief Open an output stream with the given path and stream mode
|
||||
*
|
||||
* This will automatically create a delegate object and delete it later.
|
||||
*/
|
||||
BinaryOutputStream (const std::string &abstract_path, OutputStreamMode om = OM_Auto, int keep_backups = 0);
|
||||
|
||||
/**
|
||||
* @brief << operator: inserts character
|
||||
*/
|
||||
OutputStream &operator<< (char s)
|
||||
{
|
||||
put (&s, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief << operator: inserts a character
|
||||
*/
|
||||
OutputStream &operator<< (unsigned char s)
|
||||
{
|
||||
put ((const char *) &s, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief << operator: inserts a string
|
||||
*
|
||||
* In binary mode, the string is inserted as a length/data
|
||||
* combination. That matches the extraction in BinaryInputStream.
|
||||
*/
|
||||
BinaryOutputStream &operator<< (const char *s)
|
||||
{
|
||||
put_native (s, strlen (s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief << operator: inserts a string
|
||||
*
|
||||
* In binary mode, the string is inserted as a length/data
|
||||
* combination. That matches the extraction in BinaryInputStream.
|
||||
*/
|
||||
BinaryOutputStream &operator<< (const std::string &s)
|
||||
{
|
||||
put_native (s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief << operator: inserts an object supported by "put_native".
|
||||
*/
|
||||
template <class T>
|
||||
BinaryOutputStream &operator<< (const T &t)
|
||||
{
|
||||
put_native (t);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void put_native (const std::string &s);
|
||||
void put_native (const char *s, size_t n);
|
||||
void put_native (double v);
|
||||
void put_native (float v);
|
||||
void put_native (bool v);
|
||||
void put_native (uint8_t v);
|
||||
void put_native (int8_t v);
|
||||
void put_native (uint16_t v);
|
||||
void put_native (int16_t v);
|
||||
void put_native (uint32_t v);
|
||||
void put_native (int32_t v);
|
||||
void put_native (uint64_t v);
|
||||
void put_native (int64_t v);
|
||||
void put_native (const tl::Variant &v);
|
||||
|
||||
void set_as_text (bool f);
|
||||
|
||||
// No copying currently
|
||||
BinaryOutputStream (const BinaryOutputStream &);
|
||||
BinaryOutputStream &operator= (const BinaryOutputStream &);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief A binary input stream
|
||||
*
|
||||
* This class is put in front of a InputStream to retrieve binary primitives from the stream.
|
||||
* The binary format corresponds to binary mode of OutputStream.
|
||||
*/
|
||||
class TL_PUBLIC BinaryInputStream
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*
|
||||
* This constructor takes a delegate object.
|
||||
*/
|
||||
BinaryInputStream (InputStream &stream);
|
||||
|
||||
/**
|
||||
* @brief Gets the raw stream
|
||||
*/
|
||||
InputStream &raw_stream ()
|
||||
{
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the source specification
|
||||
*/
|
||||
std::string source () const
|
||||
{
|
||||
return m_stream.source ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value of a specific type
|
||||
*/
|
||||
BinaryInputStream &operator>> (std::string &v);
|
||||
BinaryInputStream &operator>> (std::vector<char> &v);
|
||||
BinaryInputStream &operator>> (double &v);
|
||||
BinaryInputStream &operator>> (float &v);
|
||||
BinaryInputStream &operator>> (bool &v);
|
||||
BinaryInputStream &operator>> (uint8_t &v);
|
||||
BinaryInputStream &operator>> (int8_t &v);
|
||||
BinaryInputStream &operator>> (uint16_t &v);
|
||||
BinaryInputStream &operator>> (int16_t &v);
|
||||
BinaryInputStream &operator>> (uint32_t &v);
|
||||
BinaryInputStream &operator>> (int32_t &v);
|
||||
BinaryInputStream &operator>> (uint64_t &v);
|
||||
BinaryInputStream &operator>> (int64_t &v);
|
||||
BinaryInputStream &operator>> (tl::Variant &v);
|
||||
|
||||
/**
|
||||
* @brief Resets to the initial position
|
||||
*/
|
||||
void reset ();
|
||||
|
||||
private:
|
||||
InputStream &m_stream;
|
||||
|
||||
// no copying
|
||||
BinaryInputStream (const BinaryInputStream &);
|
||||
BinaryInputStream &operator= (const BinaryInputStream &);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
|||
|
|
@ -730,7 +730,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Get a single line (presumably UTF8 encoded)
|
||||
* @brief Gets a single line (presumably UTF8 encoded)
|
||||
*/
|
||||
const std::string &get_line ();
|
||||
|
||||
|
|
@ -747,7 +747,7 @@ public:
|
|||
std::string read_all (size_t max_count);
|
||||
|
||||
/**
|
||||
* @brief Get a single character
|
||||
* @brief Gets a single character
|
||||
*/
|
||||
char get_char ();
|
||||
|
||||
|
|
@ -757,14 +757,14 @@ public:
|
|||
char peek_char ();
|
||||
|
||||
/**
|
||||
* @brief Skip blanks, newlines etc.
|
||||
* @brief Skips blanks, newlines etc.
|
||||
*
|
||||
* Returns the following character without getting it.
|
||||
*/
|
||||
char skip ();
|
||||
|
||||
/**
|
||||
* @brief Get the source specification
|
||||
* @brief Gets the source specification
|
||||
*/
|
||||
std::string source () const
|
||||
{
|
||||
|
|
@ -772,7 +772,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current line number
|
||||
* @brief Gets the current line number
|
||||
*/
|
||||
size_t line_number ()
|
||||
{
|
||||
|
|
@ -780,7 +780,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Return false, if no more characters can be obtained
|
||||
* @brief Returns false, if no more characters can be obtained
|
||||
*/
|
||||
bool at_end () const
|
||||
{
|
||||
|
|
@ -788,7 +788,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Reset to the initial position
|
||||
* @brief Resets to the initial position
|
||||
*/
|
||||
void reset ();
|
||||
|
||||
|
|
@ -880,9 +880,9 @@ public:
|
|||
/**
|
||||
* @brief Create a string writer
|
||||
*/
|
||||
OutputMemoryStream ()
|
||||
OutputMemoryStream (size_t initial_alloc = 65536)
|
||||
{
|
||||
m_buffer.reserve (65336);
|
||||
m_buffer.reserve (initial_alloc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1312,13 +1312,20 @@ public:
|
|||
void close ();
|
||||
|
||||
/**
|
||||
* @brief This is the outer write method to call
|
||||
* @brief Puts a string into the stream
|
||||
*
|
||||
* This implementation writes data through the
|
||||
* protected write call.
|
||||
* In text mode, this handles line separator conversion.
|
||||
* In binary mode, this method is equivalent to "put_raw".
|
||||
*/
|
||||
void put (const char *b, size_t n);
|
||||
|
||||
/**
|
||||
* @brief Puts the raw bytes into the stream
|
||||
*
|
||||
* This method bypasses the line feed translation.
|
||||
*/
|
||||
void put_raw (const char *b, size_t n);
|
||||
|
||||
/**
|
||||
* @brief Puts a C string (UTF-8) to the output
|
||||
*/
|
||||
|
|
@ -1336,7 +1343,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief << operator
|
||||
* @brief << operator: inserts character
|
||||
*/
|
||||
OutputStream &operator<< (char s)
|
||||
{
|
||||
|
|
@ -1345,7 +1352,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief << operator
|
||||
* @brief << operator: inserts a character
|
||||
*/
|
||||
OutputStream &operator<< (unsigned char s)
|
||||
{
|
||||
|
|
@ -1354,16 +1361,22 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief << operator
|
||||
* @brief << operator: inserts a string
|
||||
*
|
||||
* In binary mode, the string is inserted as a length/data
|
||||
* combination. That matches the extraction in BinaryInputStream.
|
||||
*/
|
||||
OutputStream &operator<< (const char *s)
|
||||
{
|
||||
put (s);
|
||||
put (s, strlen (s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief << operator
|
||||
* @brief << operator: inserts a string
|
||||
*
|
||||
* In binary mode, the string is inserted as a length/data
|
||||
* combination. That matches the extraction in BinaryInputStream.
|
||||
*/
|
||||
OutputStream &operator<< (const std::string &s)
|
||||
{
|
||||
|
|
@ -1372,7 +1385,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief << operator
|
||||
* @brief << operator: inserts an object supported by "put_native".
|
||||
*/
|
||||
template <class T>
|
||||
OutputStream &operator<< (const T &t)
|
||||
|
|
@ -1456,8 +1469,6 @@ private:
|
|||
size_t m_buffer_capacity, m_buffer_pos;
|
||||
std::string m_path;
|
||||
|
||||
void put_raw (const char *b, size_t n);
|
||||
|
||||
// No copying currently
|
||||
OutputStream (const OutputStream &);
|
||||
OutputStream &operator= (const OutputStream &);
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ to_quoted_string (const std::string &s)
|
|||
std::string r;
|
||||
r.reserve (s.size () + 2);
|
||||
r += '\'';
|
||||
for (const char *c = s.c_str (); *c; ++c) {
|
||||
for (auto c = s.begin (); c != s.end (); ++c) {
|
||||
if (*c == '\'' || *c == '\\') {
|
||||
r += '\\';
|
||||
r += *c;
|
||||
|
|
|
|||
|
|
@ -315,6 +315,12 @@ Variant::Variant (const std::vector<char> &ba)
|
|||
m_var.m_bytearray = new std::vector<char> (ba);
|
||||
}
|
||||
|
||||
Variant::Variant (std::vector<char> &&ba)
|
||||
: m_type (t_bytearray), m_string (0)
|
||||
{
|
||||
m_var.m_bytearray = new std::vector<char> (ba);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
Variant::Variant (const QByteArray &qba)
|
||||
|
|
@ -530,7 +536,13 @@ Variant::Variant (const std::string &s)
|
|||
m_var.m_stdstring = new std::string (s);
|
||||
}
|
||||
|
||||
Variant::Variant (const char *s)
|
||||
Variant::Variant (std::string &&s)
|
||||
: m_type (t_stdstring), m_string (0)
|
||||
{
|
||||
m_var.m_stdstring = new std::string (s);
|
||||
}
|
||||
|
||||
Variant::Variant (const char *s)
|
||||
: m_type (s != 0 ? t_string : t_nil)
|
||||
{
|
||||
if (s) {
|
||||
|
|
@ -645,6 +657,12 @@ Variant::Variant (const Variant &v)
|
|||
operator= (v);
|
||||
}
|
||||
|
||||
Variant::Variant (Variant &&v)
|
||||
: m_type (t_nil), m_string (0)
|
||||
{
|
||||
swap (v);
|
||||
}
|
||||
|
||||
Variant::~Variant ()
|
||||
{
|
||||
reset ();
|
||||
|
|
@ -713,6 +731,20 @@ Variant::operator= (const std::string &s)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Variant &
|
||||
Variant::operator= (std::string &&s)
|
||||
{
|
||||
if (m_type == t_stdstring && &s == m_var.m_stdstring) {
|
||||
// we are assigning to ourselves
|
||||
} else {
|
||||
std::string *snew = new std::string (s);
|
||||
reset ();
|
||||
m_type = t_stdstring;
|
||||
m_var.m_stdstring = snew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Variant &
|
||||
Variant::operator= (const std::vector<char> &s)
|
||||
{
|
||||
|
|
@ -727,6 +759,20 @@ Variant::operator= (const std::vector<char> &s)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Variant &
|
||||
Variant::operator= (std::vector<char> &&s)
|
||||
{
|
||||
if (m_type == t_bytearray && &s == m_var.m_bytearray) {
|
||||
// we are assigning to ourselves
|
||||
} else {
|
||||
std::vector<char> *snew = new std::vector<char> (s);
|
||||
reset ();
|
||||
m_type = t_bytearray;
|
||||
m_var.m_bytearray = snew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
Variant &
|
||||
|
|
@ -900,6 +946,13 @@ Variant::operator= (__int128 l)
|
|||
}
|
||||
#endif
|
||||
|
||||
Variant &
|
||||
Variant::operator= (Variant &&v)
|
||||
{
|
||||
swap (v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Variant &
|
||||
Variant::operator= (const Variant &v)
|
||||
{
|
||||
|
|
@ -1958,7 +2011,7 @@ Variant::to_string () const
|
|||
} else if (m_type == t_float) {
|
||||
r = tl::to_string (m_var.m_float, 7);
|
||||
} else if (m_type == t_char) {
|
||||
r = tl::to_string ((int) m_var.m_char);
|
||||
r += m_var.m_char;
|
||||
} else if (m_type == t_schar) {
|
||||
r = tl::to_string ((int) m_var.m_schar);
|
||||
} else if (m_type == t_uchar) {
|
||||
|
|
@ -2602,12 +2655,10 @@ Variant::to_parsable_string () const
|
|||
return "nil";
|
||||
} else if (is_stdstring ()) {
|
||||
return tl::to_quoted_string (*m_var.m_stdstring);
|
||||
#if defined(HAVE_QT)
|
||||
} else if (is_cstring () || is_qstring () || is_qbytearray () || is_bytearray ()) {
|
||||
#else
|
||||
} else if (is_cstring () || is_bytearray ()) {
|
||||
#endif
|
||||
return tl::to_quoted_string (to_string ());
|
||||
} else if (is_a_string ()) {
|
||||
return tl::to_quoted_string (to_stdstring ());
|
||||
} else if (is_a_bytearray ()) {
|
||||
return tl::to_quoted_string (to_stdstring ()) + "b";
|
||||
} else if (is_list ()) {
|
||||
std::string r = "(";
|
||||
for (tl::Variant::const_iterator l = begin (); l != end (); ++l) {
|
||||
|
|
@ -2630,6 +2681,10 @@ Variant::to_parsable_string () const
|
|||
}
|
||||
r += "}";
|
||||
return r;
|
||||
} else if (is_char ()) {
|
||||
std::string s;
|
||||
s += to_char ();
|
||||
return tl::to_quoted_string (s) + "c";
|
||||
} else if (is_id ()) {
|
||||
return "[id" + tl::to_string (m_var.m_id) + "]";
|
||||
} else if (is_user ()) {
|
||||
|
|
@ -3049,7 +3104,15 @@ TL_PUBLIC bool test_extractor_impl (tl::Extractor &ex, tl::Variant &v)
|
|||
|
||||
} else if (ex.try_read_word_or_quoted (s)) {
|
||||
|
||||
v = tl::Variant (s);
|
||||
if (ex.test ("c") || ex.test ("C")) {
|
||||
v = s.empty () ? tl::Variant () : tl::Variant ((char) s.front ());
|
||||
} else if (ex.test ("b") || ex.test ("B")) {
|
||||
std::vector<char> cv (s.begin (), s.end ());
|
||||
v = tl::Variant (std::move (cv));
|
||||
} else {
|
||||
v = tl::Variant (s);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -205,11 +205,21 @@ public:
|
|||
*/
|
||||
Variant (const tl::Variant &d);
|
||||
|
||||
/**
|
||||
* @brief Move ctor
|
||||
*/
|
||||
Variant (tl::Variant &&d);
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with a std::vector<char>
|
||||
*/
|
||||
Variant (const std::vector<char> &s);
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with a std::vector<char> (move semantics)
|
||||
*/
|
||||
Variant (std::vector<char> &&s);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
/**
|
||||
* @brief Initialize the Variant with a QByteArray
|
||||
|
|
@ -234,6 +244,11 @@ public:
|
|||
*/
|
||||
Variant (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with "string" (move semantics)
|
||||
*/
|
||||
Variant (std::string &&s);
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with "string"
|
||||
*/
|
||||
|
|
@ -466,6 +481,15 @@ public:
|
|||
m_var.m_list = new std::vector<tl::Variant> (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with an explicit vector of variants (move semantics)
|
||||
*/
|
||||
Variant (std::vector<tl::Variant> &&list)
|
||||
: m_type (t_list), m_string (0)
|
||||
{
|
||||
m_var.m_list = new std::vector<tl::Variant> (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with an explicit map of variants
|
||||
*/
|
||||
|
|
@ -475,6 +499,15 @@ public:
|
|||
m_var.m_array = new std::map<tl::Variant, tl::Variant> (map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with an explicit map of variants (move semantics)
|
||||
*/
|
||||
Variant (std::map<tl::Variant, tl::Variant> &&map)
|
||||
: m_type (t_array), m_string (0)
|
||||
{
|
||||
m_var.m_array = new std::map<tl::Variant, tl::Variant> (map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the Variant with a list
|
||||
*/
|
||||
|
|
@ -546,6 +579,11 @@ public:
|
|||
*/
|
||||
Variant &operator= (const Variant &v);
|
||||
|
||||
/**
|
||||
* @brief Assignment (move)
|
||||
*/
|
||||
Variant &operator= (Variant &&v);
|
||||
|
||||
/**
|
||||
* @brief Assignment of a string
|
||||
*/
|
||||
|
|
@ -568,11 +606,21 @@ public:
|
|||
*/
|
||||
Variant &operator= (const std::string &v);
|
||||
|
||||
/**
|
||||
* @brief Assignment of a string (move)
|
||||
*/
|
||||
Variant &operator= (std::string &&v);
|
||||
|
||||
/**
|
||||
* @brief Assignment of a STL byte array
|
||||
*/
|
||||
Variant &operator= (const std::vector<char> &v);
|
||||
|
||||
/**
|
||||
* @brief Assignment of a STL byte array (move)
|
||||
*/
|
||||
Variant &operator= (std::vector<char> &&v);
|
||||
|
||||
/**
|
||||
* @brief Assignment of a double
|
||||
*/
|
||||
|
|
@ -1173,6 +1221,15 @@ public:
|
|||
m_var.m_list->push_back (v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a element to the list (move semantics)
|
||||
*/
|
||||
void push (tl::Variant &&v)
|
||||
{
|
||||
tl_assert (m_type == t_list);
|
||||
m_var.m_list->push_back (v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the back element of the list
|
||||
*/
|
||||
|
|
@ -1280,6 +1337,15 @@ public:
|
|||
m_var.m_array->insert (std::make_pair (k, v));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Insert an element into the array (move semantics)
|
||||
*/
|
||||
void insert (tl::Variant &&k, tl::Variant &&v)
|
||||
{
|
||||
tl_assert (m_type == t_array);
|
||||
m_var.m_array->insert (std::make_pair (k, v));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the value for the given key or 0 if the variant is not an array or does not contain the key
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,425 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2026 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "tlBinaryStream.h"
|
||||
#include "tlUnitTest.h"
|
||||
|
||||
std::string s2string (tl::OutputMemoryStream &osm)
|
||||
{
|
||||
std::string res;
|
||||
size_t n = osm.size ();
|
||||
const char *d = osm.data ();
|
||||
for (size_t i = 0; i < n; ++i, ++d) {
|
||||
if (i > 0) {
|
||||
res += ",";
|
||||
}
|
||||
res += tl::sprintf ("0x%02x", int ((unsigned char) *d));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
TEST(BinaryStreams1)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << (double) 0.17;
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0xc3,0xf5,0x28,0x5c,0x8f,0xc2,0xc5,0x3f");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
double x = 0.0;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (tl::to_string (x), "0.17");
|
||||
}
|
||||
|
||||
TEST(BinaryStreams2)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << (float) 0.17;
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x7b,0x14,0x2e,0x3e");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
float x = 0.0;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (tl::to_string (x), "0.17");
|
||||
}
|
||||
|
||||
TEST(BinaryStreams3)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << std::string ("ABC");
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x42,0x43");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
std::string x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, "ABC");
|
||||
}
|
||||
|
||||
TEST(BinaryStreams4)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << "ABC";
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x42,0x43");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
std::string x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, "ABC");
|
||||
}
|
||||
|
||||
TEST(BinaryStreams5)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << uint8_t (17);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x11");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
uint8_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 17);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams6)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << int8_t (17);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x11");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
int8_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 17);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams7)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << uint16_t (1742);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0xce,0x06");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
uint16_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 1742);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams8)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << int16_t (1742);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0xce,0x06");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
int16_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 1742);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams9)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << uint32_t (17420000);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0xe0,0xce,0x09,0x01");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
uint32_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 17420000u);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams10)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << int32_t (17420000);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0xe0,0xce,0x09,0x01");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
int32_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 17420000);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams11)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << uint64_t (174200000000l);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x00,0x0e,0x21,0x8f,0x28,0x00,0x00,0x00");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
uint64_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 174200000000lu);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams12)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << int64_t (174200000000l);
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x00,0x0e,0x21,0x8f,0x28,0x00,0x00,0x00");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
int64_t x;
|
||||
bis >> x;
|
||||
|
||||
EXPECT_EQ (x, 174200000000l);
|
||||
}
|
||||
|
||||
TEST(BinaryStreams13)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << true;
|
||||
os << false;
|
||||
|
||||
os.flush ();
|
||||
EXPECT_EQ (s2string (osm), "0x01,0x00");
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
bool x = false, y = false;
|
||||
bis >> x >> y;
|
||||
|
||||
EXPECT_EQ (x, true);
|
||||
EXPECT_EQ (y, false);
|
||||
}
|
||||
|
||||
TEST(BinaryStreamsCombined)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
os << "ABC" << 17.0 << "XUV" << (int32_t) 42;
|
||||
|
||||
os.flush ();
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
std::string a, c;
|
||||
double b = 0.0;
|
||||
int32_t d = 0;
|
||||
|
||||
bis >> a >> b >> c >> d;
|
||||
|
||||
EXPECT_EQ (a, "ABC");
|
||||
EXPECT_EQ (b, 17.0);
|
||||
EXPECT_EQ (c, "XUV");
|
||||
EXPECT_EQ (d, 42);
|
||||
}
|
||||
|
||||
TEST(BinaryStreamsVariants)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
std::vector<char> bytes = { 'X', 'U', 'V' };
|
||||
|
||||
os << tl::Variant ("ABC")
|
||||
<< tl::Variant ()
|
||||
<< tl::Variant (bytes)
|
||||
<< tl::Variant ((float) 42.5)
|
||||
<< tl::Variant ((double) -17.5)
|
||||
<< tl::Variant ((char) 'x')
|
||||
<< tl::Variant ((unsigned char) 'u')
|
||||
<< tl::Variant ((signed char) 'v')
|
||||
<< tl::Variant ((short) 17)
|
||||
<< tl::Variant ((unsigned short) 42)
|
||||
<< tl::Variant ((int) 18)
|
||||
<< tl::Variant ((unsigned int) 43)
|
||||
<< tl::Variant ((long) 19)
|
||||
<< tl::Variant ((unsigned long) 44)
|
||||
<< tl::Variant ((long long) 20)
|
||||
<< tl::Variant ((unsigned long long) 45)
|
||||
<< tl::Variant ((size_t) 202, true /*id*/);
|
||||
|
||||
os.flush ();
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
tl::Variant v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17;
|
||||
|
||||
bis >> v1 >> v2 >> v3 >> v4 >> v5 >> v6 >> v7 >> v8 >> v9 >> v10 >> v11 >> v12 >> v13 >> v14 >> v15 >> v16 >> v17;
|
||||
|
||||
EXPECT_EQ (v1.to_parsable_string (), "'ABC'");
|
||||
EXPECT_EQ (v2.to_parsable_string (), "nil");
|
||||
EXPECT_EQ (v3.to_parsable_string (), "'XUV'b");
|
||||
EXPECT_EQ (v3.type_code (), tl::Variant::t_bytearray);
|
||||
EXPECT_EQ (v4.to_parsable_string (), "##42.5");
|
||||
EXPECT_EQ (v5.to_parsable_string (), "##-17.5");
|
||||
EXPECT_EQ (v6.to_parsable_string (), "'x'c");
|
||||
EXPECT_EQ (v7.to_parsable_string (), "#u117");
|
||||
EXPECT_EQ (v8.to_parsable_string (), "#118");
|
||||
EXPECT_EQ (v9.to_parsable_string (), "#17");
|
||||
EXPECT_EQ (v10.to_parsable_string (), "#u42");
|
||||
EXPECT_EQ (v11.to_parsable_string (), "#18");
|
||||
EXPECT_EQ (v12.to_parsable_string (), "#u43");
|
||||
EXPECT_EQ (v13.to_parsable_string (), "#19");
|
||||
EXPECT_EQ (v14.to_parsable_string (), "#u44");
|
||||
EXPECT_EQ (v15.to_parsable_string (), "#l20");
|
||||
EXPECT_EQ (v16.to_parsable_string (), "#lu45");
|
||||
EXPECT_EQ (v17.to_parsable_string (), "[id202]");
|
||||
}
|
||||
|
||||
TEST(BinaryStreamsVariantList)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
std::vector<tl::Variant> list = { 5.5, -17, "ABC" };
|
||||
|
||||
os << tl::Variant (list);
|
||||
|
||||
os.flush ();
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
tl::Variant v1;
|
||||
|
||||
bis >> v1;
|
||||
|
||||
EXPECT_EQ (v1.to_parsable_string (), "(##5.5,#-17,'ABC')");
|
||||
}
|
||||
|
||||
TEST(BinaryStreamsVariantArray)
|
||||
{
|
||||
tl::OutputMemoryStream osm;
|
||||
tl::BinaryOutputStream os (osm);
|
||||
|
||||
std::vector<std::pair<tl::Variant, tl::Variant> > a = { { 1, 5.5 }, { 2, -17 }, { "id", "ABC" } };
|
||||
|
||||
std::map<tl::Variant, tl::Variant> array (a.begin (), a.end ());
|
||||
os << tl::Variant (array);
|
||||
|
||||
os.flush ();
|
||||
|
||||
tl::InputMemoryStream ism (osm.data (), osm.size ());
|
||||
tl::InputStream is (ism);
|
||||
tl::BinaryInputStream bis (is);
|
||||
|
||||
tl::Variant v1;
|
||||
|
||||
bis >> v1;
|
||||
|
||||
EXPECT_EQ (v1.to_parsable_string (), "{#1=>##5.5,#2=>#-17,'id'=>'ABC'}");
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ TEST(OutputPipe1)
|
|||
{
|
||||
tl::OutputPipe pipe ("cat >" + tf);
|
||||
tl::OutputStream str (pipe);
|
||||
str << "Hello, world!";
|
||||
str.put ("Hello, world!");
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ TEST(TextOutputStream)
|
|||
|
||||
{
|
||||
tl::OutputStream os (fn, tl::OutputStream::OM_Auto, false);
|
||||
os << "Hello, world!\nWith another line\n\r\r\nseparated by a LFCR and CRLF.";
|
||||
os.put ("Hello, world!\nWith another line\n\r\r\nseparated by a LFCR and CRLF.");
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ TEST(TextInputStream)
|
|||
|
||||
{
|
||||
tl::OutputStream os (fn, tl::OutputStream::OM_Auto, false);
|
||||
os << "Hello, world!\nWith another line\n\r\r\nseparated by a LFCR and CRLF.";
|
||||
os.put ("Hello, world!\nWith another line\n\r\r\nseparated by a LFCR and CRLF.");
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -242,7 +242,7 @@ TEST(SafeOutput)
|
|||
|
||||
{
|
||||
tl::OutputStream os (tp);
|
||||
os << "blabla\n";
|
||||
os.put ("blabla\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -252,7 +252,7 @@ TEST(SafeOutput)
|
|||
tl::OutputStream os (tp);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "Hello, world!\n";
|
||||
os.put ("Hello, world!\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -268,7 +268,7 @@ TEST(SafeOutput)
|
|||
tl::OutputStream os (broken);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "Hi!\n";
|
||||
os.put ("Hi!\n");
|
||||
os.flush (); // raises the exception
|
||||
EXPECT_EQ (true, false);
|
||||
} catch (...) {
|
||||
|
|
@ -291,7 +291,7 @@ TEST(SafeOutput)
|
|||
tl::OutputStream os (broken);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "Hi!\n";
|
||||
os.put ("Hi!\n");
|
||||
os.flush (); // raises the exception
|
||||
EXPECT_EQ (true, false);
|
||||
} catch (...) {
|
||||
|
|
@ -323,7 +323,7 @@ TEST(SafeOutput2)
|
|||
|
||||
{
|
||||
tl::OutputStream os (tp);
|
||||
os << "blabla\n";
|
||||
os.put ("blabla\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -333,7 +333,7 @@ TEST(SafeOutput2)
|
|||
tl::OutputStream os (tp);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "Hello, world!\n";
|
||||
os.put ("Hello, world!\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -358,7 +358,7 @@ TEST(Backups)
|
|||
|
||||
{
|
||||
tl::OutputStream os (tp, tl::OutputStream::OM_Auto, false, 2);
|
||||
os << "1\n";
|
||||
os.put ("1\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -376,7 +376,7 @@ TEST(Backups)
|
|||
tl::OutputStream os (tp, tl::OutputStream::OM_Auto, false, 2);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "2\n";
|
||||
os.put ("2\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -399,7 +399,7 @@ TEST(Backups)
|
|||
tl::OutputStream os (tp, tl::OutputStream::OM_Auto, false, 2);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "3\n";
|
||||
os.put ("3\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -427,7 +427,7 @@ TEST(Backups)
|
|||
tl::OutputStream os (tp, tl::OutputStream::OM_Auto, false, 2);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "4\n";
|
||||
os.put ("4\n");
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), false);
|
||||
|
|
@ -456,7 +456,7 @@ TEST(Backups)
|
|||
tl::OutputStream os (broken);
|
||||
EXPECT_EQ (tl::file_exists (tp + ".~backup"), true);
|
||||
EXPECT_EQ (tl::file_exists (tp), true);
|
||||
os << "5!\n";
|
||||
os.put ("5!\n");
|
||||
os.flush (); // raises the exception
|
||||
EXPECT_EQ (true, false);
|
||||
} catch (...) {
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_ulong (), false);
|
||||
EXPECT_EQ (v.is_ulonglong (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "nil");
|
||||
EXPECT_EQ (v.to_parsable_string (), "nil");
|
||||
vv = v;
|
||||
EXPECT_EQ (vv == v, true);
|
||||
|
|
@ -109,6 +110,43 @@ TEST(1)
|
|||
EXPECT_EQ (vx == v, true);
|
||||
}
|
||||
|
||||
{
|
||||
tl::Variant v ((char) '\033');
|
||||
#if defined(HAVE_QT)
|
||||
EXPECT_EQ (tl::to_string (v.to_qvariant ().toString ()), "27");
|
||||
#endif
|
||||
EXPECT_EQ (v.is_nil (), false);
|
||||
EXPECT_EQ (v.is_list (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.is<short> (), false);
|
||||
EXPECT_EQ (v.is<unsigned short> (), false);
|
||||
EXPECT_EQ (v.is<int> (), false);
|
||||
EXPECT_EQ (v.is<unsigned int> (), false);
|
||||
EXPECT_EQ (v.is<short> (), false);
|
||||
EXPECT_EQ (v.is<unsigned short> (), false);
|
||||
EXPECT_EQ (v.is<unsigned char> (), false);
|
||||
EXPECT_EQ (v.is<signed char> (), false);
|
||||
EXPECT_EQ (v.is<long> (), false);
|
||||
EXPECT_EQ (v.is_char (), true);
|
||||
EXPECT_EQ (v.is_long (), false);
|
||||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_ulong (), false);
|
||||
EXPECT_EQ (v.is_ulonglong (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "\033");
|
||||
EXPECT_EQ (v.to_parsable_string (), "'\\033'c");
|
||||
vv = v;
|
||||
EXPECT_EQ (vv == v, true);
|
||||
EXPECT_EQ (vv != v, false);
|
||||
tl::Variant vx;
|
||||
std::string s (v.to_parsable_string ());
|
||||
tl::Extractor ex (s.c_str ());
|
||||
ex.read (vx);
|
||||
ex.expect_end ();
|
||||
EXPECT_EQ (vx == v, true);
|
||||
}
|
||||
|
||||
{
|
||||
tl::Variant v (1ul);
|
||||
#if defined(HAVE_QT)
|
||||
|
|
@ -123,6 +161,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_long (), false);
|
||||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "1");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#u1");
|
||||
EXPECT_EQ (v.to_long (), 1l);
|
||||
EXPECT_EQ (v.to_longlong (), 1l);
|
||||
|
|
@ -161,6 +200,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "2");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#u2");
|
||||
EXPECT_EQ (v.to_long (), 2l);
|
||||
EXPECT_EQ (v.to_longlong (), 2l);
|
||||
|
|
@ -196,6 +236,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is<int> (), true);
|
||||
EXPECT_EQ (v.is<unsigned int> (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "1");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#1");
|
||||
EXPECT_EQ (v.to_long (), 1l);
|
||||
EXPECT_EQ (v.to_longlong (), 1l);
|
||||
|
|
@ -236,6 +277,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is<unsigned int> (), false);
|
||||
EXPECT_EQ (v.is<unsigned char> (), false);
|
||||
EXPECT_EQ (v.is<signed char> (), false);
|
||||
EXPECT_EQ (v.to_string (), "2");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#2");
|
||||
EXPECT_EQ (v.to_long (), 2l);
|
||||
EXPECT_EQ (v.to_longlong (), 2l);
|
||||
|
|
@ -279,6 +321,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is<unsigned char> (), false);
|
||||
EXPECT_EQ (v.is<signed char> (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.to_string (), "5");
|
||||
EXPECT_EQ (v.to_parsable_string (), "##5");
|
||||
EXPECT_EQ (v.to_double (), 5.0);
|
||||
EXPECT_EQ (v.to_float (), 5.0);
|
||||
|
|
@ -327,6 +370,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is<unsigned char> (), false);
|
||||
EXPECT_EQ (v.is<signed char> (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.to_string (), "5");
|
||||
EXPECT_EQ (v.to_parsable_string (), "##5");
|
||||
EXPECT_EQ (v.to_double (), 5.0);
|
||||
EXPECT_EQ (v.to_long (), 5);
|
||||
|
|
@ -386,6 +430,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_ulonglong (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "2");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#2");
|
||||
vv = v;
|
||||
EXPECT_EQ (vv == v, true);
|
||||
|
|
@ -419,6 +464,8 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_nil (), false);
|
||||
EXPECT_EQ (v.is_list (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_bytearray (), false);
|
||||
EXPECT_EQ (v.is_a_bytearray (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.is_char (), false);
|
||||
EXPECT_EQ (v.is_long (), false);
|
||||
|
|
@ -432,6 +479,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is<signed char> (), false);
|
||||
EXPECT_EQ (v.is<long> (), false);
|
||||
EXPECT_EQ (v.is<unsigned long> (), false);
|
||||
EXPECT_EQ (v.to_string (), "2");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#u2");
|
||||
vv = v;
|
||||
EXPECT_EQ (vv == v, true);
|
||||
|
|
@ -454,6 +502,39 @@ TEST(1)
|
|||
EXPECT_EQ (*(long *)v.native_ptr(), 2);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<char> bytes = { '"', 'h', 0, '\033', 'a', 'l', 'l', 'O', '"' };
|
||||
tl::Variant v (std::move (bytes));
|
||||
#if defined(HAVE_QT)
|
||||
EXPECT_EQ (tl::Variant (v.to_qvariant ()).to_parsable_string (), "'\"h\\000\\033allO\"'b");
|
||||
#endif
|
||||
EXPECT_EQ (v.is_nil (), false);
|
||||
EXPECT_EQ (v.is_list (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_bytearray (), true);
|
||||
EXPECT_EQ (v.is_a_bytearray (), true);
|
||||
EXPECT_EQ (v.is_long (), false);
|
||||
EXPECT_EQ (v.is_ulong (), false);
|
||||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_ulonglong (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.to_parsable_string (), "'\"h\\000\\033allO\"'b");
|
||||
EXPECT_EQ (v.to_stdstring (), std::string ("\"h\000\033allO\"", 9));
|
||||
EXPECT_EQ (vv == v, false);
|
||||
EXPECT_EQ (vv != v, true);
|
||||
vv = v;
|
||||
EXPECT_EQ (vv == v, true);
|
||||
EXPECT_EQ (vv != v, false);
|
||||
tl::Variant vx;
|
||||
std::string s (v.to_parsable_string ());
|
||||
tl::Extractor ex (s.c_str ());
|
||||
ex.read (vx);
|
||||
ex.expect_end ();
|
||||
EXPECT_EQ (vx.is_bytearray (), true);
|
||||
EXPECT_EQ (vx == v, true);
|
||||
}
|
||||
|
||||
{
|
||||
tl::Variant v ("hal'l\"o");
|
||||
#if defined(HAVE_QT)
|
||||
|
|
@ -534,6 +615,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_id (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "(1,5,25)");
|
||||
EXPECT_EQ (v.to_parsable_string (), "(#1,#5,#25)");
|
||||
EXPECT_EQ (v.get_list ().size (), size_t (3));
|
||||
EXPECT_EQ (v.begin ()->is_long (), true);
|
||||
|
|
@ -571,6 +653,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_ulonglong (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "17");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#l17");
|
||||
tl::Variant vx;
|
||||
std::string s (v.to_parsable_string ());
|
||||
|
|
@ -595,6 +678,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "17");
|
||||
EXPECT_EQ (v.to_parsable_string (), "#lu17");
|
||||
tl::Variant vx;
|
||||
std::string s (v.to_parsable_string ());
|
||||
|
|
@ -619,6 +703,7 @@ TEST(1)
|
|||
EXPECT_EQ (v.is_longlong (), false);
|
||||
EXPECT_EQ (v.is_cstring (), false);
|
||||
EXPECT_EQ (v.is_double (), false);
|
||||
EXPECT_EQ (v.to_string (), "[id17]");
|
||||
EXPECT_EQ (v.to_parsable_string (), "[id17]");
|
||||
}
|
||||
|
||||
|
|
@ -642,6 +727,7 @@ TEST(1)
|
|||
v.insert (tl::Variant (1), tl::Variant ("A"));
|
||||
EXPECT_EQ (v.to_parsable_string (), "{#1=>\'A\'}");
|
||||
v.insert (tl::Variant ("B"), tl::Variant (17));
|
||||
EXPECT_EQ (v.to_string (), "{1=>A,B=>17}");
|
||||
EXPECT_EQ (v.to_parsable_string (), "{#1=>\'A\',\'B\'=>#17}");
|
||||
#if defined(HAVE_QT)
|
||||
EXPECT_EQ (tl::Variant (v.to_qvariant ()).to_parsable_string (), "{\'1\'=>\'A\',\'B\'=>#17}");
|
||||
|
|
@ -1138,7 +1224,7 @@ TEST(8)
|
|||
v = tl::Variant (QByteArray ());
|
||||
EXPECT_EQ (v.to_parsable_string (), "nil");
|
||||
v = tl::Variant (QByteArray ("abc"));
|
||||
EXPECT_EQ (v.to_parsable_string (), "'abc'");
|
||||
EXPECT_EQ (v.to_parsable_string (), "'abc'b");
|
||||
v = QByteArray ();
|
||||
EXPECT_EQ (v.to_parsable_string (), "nil");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ include($$PWD/../../lib_ut.pri)
|
|||
SOURCES = \
|
||||
tlAlgorithmTests.cc \
|
||||
tlBase64Tests.cc \
|
||||
tlBinaryStreamTests.cc \
|
||||
tlClassRegistryTests.cc \
|
||||
tlCommandLineParserTests.cc \
|
||||
tlColorTests.cc \
|
||||
|
|
|
|||
|
|
@ -147,160 +147,160 @@ class DBEdgeNeighborhoodWithNets(unittest.TestCase):
|
|||
|
||||
self.maxDiff = None
|
||||
self.assertEqual("\n" + visitor.dump(), """
|
||||
Polygon: (-14000,0;-14000,15000;-11000,15000;-11000,0) props={net=>net1}
|
||||
Edge: (-11000,0;-14000,0) props={net=>net1}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={net=>net1}
|
||||
Edge: (-11000,15000;-11000,0) props={net=>net1}
|
||||
0.0,500.0 -> 0: (0,-11;0,0;500,0;500,-11) props={net=>net1}
|
||||
0.0,500.0 -> 1: (0,1500;0,6001;500,6001;500,1500) props={net=>net1}
|
||||
0.0,500.0 -> 3: (0,-11;0,4500;500,4500;500,-11) props={net=>net1}
|
||||
500.0,2500.0 -> 0: (500,-11;500,0;2500,0;2500,-11) props={net=>net1}
|
||||
500.0,2500.0 -> 1: (500,1500;500,6001;2500,6001;2500,1500) props={net=>net1}
|
||||
500.0,2500.0 -> 2: (500,2000;500,4000;2500,4000;2500,2000) props={net=>net1}
|
||||
500.0,2500.0 -> 3: (500,-11;500,4500;2500,4500;2500,-11) props={net=>net1}
|
||||
2500.0,3000.0 -> 0: (2500,-11;2500,0;3000,0;3000,-11) props={net=>net1}
|
||||
2500.0,3000.0 -> 1: (2500,1500;2500,6001;3000,6001;3000,1500) props={net=>net1}
|
||||
2500.0,3000.0 -> 3: (2500,-11;2500,4500;3000,4500;3000,-11) props={net=>net1}
|
||||
3000.0,8500.0 -> 0: (3000,-11;3000,0;8500,0;8500,-11) props={net=>net1}
|
||||
3000.0,8500.0 -> 1: (3000,1500;3000,4500;8500,4500;8500,1500) props={net=>net1}/(3000,6000;3000,6001;8500,6001;8500,6000) props={net=>net1}
|
||||
3000.0,8500.0 -> 3: (3000,-11;3000,0;8500,0;8500,-11) props={net=>net1}
|
||||
8500.0,15000.0 -> 0: (8500,-11;8500,0;15000,0;15000,-11) props={net=>net1}
|
||||
8500.0,15000.0 -> 1: (8500,1500;8500,4500;15000,4500;15000,1500) props={net=>net1}/(8500,6000;8500,6001;15000,6001;15000,6000) props={net=>net1}
|
||||
Edge: (-14000,0;-14000,15000) props={net=>net1}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={net=>net1}
|
||||
6500.0,15000.0 -> 0: (6500,-11;6500,0;15000,0;15000,-11) props={net=>net1}
|
||||
6500.0,15000.0 -> 3: (6500,-11;6500,0;15000,0;15000,-11) props={net=>net1}
|
||||
Edge: (-14000,15000;-11000,15000) props={net=>net1}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={net=>net1}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5000;3000,5000;3000,1500) props={net=>net3}
|
||||
0.0,3000.0 -> 3: (0,-11;0,0;3000,0;3000,-11) props={net=>net1}
|
||||
3000.0,3001.0 -> 1: (3000,1500;3000,5000;3001,5000;3001,1500) props={net=>net3}
|
||||
3000.0,3001.0 -> 3: (3000,-11;3000,0;3001,0;3001,-11) props={net=>net1}
|
||||
Polygon: (-14000,16500;-14000,20000;0,20000;0,16500) props={net=>net3}
|
||||
Edge: (-14000,16500;-14000,20000) props={net=>net3}
|
||||
0.0,3500.0 -> 0: (0,-11;0,0;3500,0;3500,-11) props={net=>net3}
|
||||
Edge: (-14000,20000;0,20000) props={net=>net3}
|
||||
0.0,7000.0 -> 0: (0,-11;0,0;7000,0;7000,-11) props={net=>net3}
|
||||
7000.0,14000.0 -> 0: (7000,-11;7000,0;14000,0;14000,-11) props={net=>net3}
|
||||
7000.0,14000.0 -> 3: (7000,-11;7000,0;14000,0;14000,-11) props={net=>net2}
|
||||
14000.0,14001.0 -> 3: (14000,-11;14000,0;14001,0;14001,-11) props={net=>net2}
|
||||
Edge: (0,16500;-14000,16500) props={net=>net3}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={net=>net2}
|
||||
0.0,5000.0 -> 0: (0,-11;0,0;5000,0;5000,-11) props={net=>net3}
|
||||
0.0,5000.0 -> 1: (0,1500;0,6001;5000,6001;5000,1500) props={net=>net1}
|
||||
0.0,5000.0 -> 3: (0,-11;0,0;5000,0;5000,-11) props={net=>net2}
|
||||
5000.0,6500.0 -> 0: (5000,-11;5000,0;6500,0;6500,-11) props={net=>net3}
|
||||
5000.0,6500.0 -> 1: (5000,1500;5000,4500;6500,4500;6500,1500) props={net=>net1}
|
||||
5000.0,6500.0 -> 3: (5000,-11;5000,0;6500,0;6500,-11) props={net=>net2}
|
||||
6500.0,7000.0 -> 0: (6500,-11;6500,0;7000,0;7000,-11) props={net=>net3}
|
||||
6500.0,7000.0 -> 1: (6500,1500;6500,6001;7000,6001;7000,1500) props={net=>net1}
|
||||
6500.0,7000.0 -> 3: (6500,-11;6500,0;7000,0;7000,-11) props={net=>net2}/(6500,1500;6500,4500;7000,4500;7000,1500) props={net=>net1}
|
||||
7000.0,9000.0 -> 0: (7000,-11;7000,0;9000,0;9000,-11) props={net=>net3}
|
||||
7000.0,9000.0 -> 1: (7000,1500;7000,6001;9000,6001;9000,1500) props={net=>net1}
|
||||
7000.0,9000.0 -> 2: (7000,2000;7000,4000;9000,4000;9000,2000) props={net=>net1}
|
||||
7000.0,9000.0 -> 3: (7000,1500;7000,4500;9000,4500;9000,1500) props={net=>net1}
|
||||
9000.0,9500.0 -> 0: (9000,-11;9000,0;9500,0;9500,-11) props={net=>net3}
|
||||
9000.0,9500.0 -> 1: (9000,1500;9000,6001;9500,6001;9500,1500) props={net=>net1}
|
||||
9000.0,9500.0 -> 3: (9000,1500;9000,4500;9500,4500;9500,1500) props={net=>net1}
|
||||
9500.0,11000.0 -> 0: (9500,-11;9500,0;11000,0;11000,-11) props={net=>net3}
|
||||
9500.0,11000.0 -> 3: (9500,1500;9500,4500;11000,4500;11000,1500) props={net=>net1}
|
||||
11000.0,11500.0 -> 0: (11000,-11;11000,0;11500,0;11500,-11) props={net=>net3}
|
||||
11000.0,11500.0 -> 1: (11000,1500;11000,6001;11500,6001;11500,1500) props={net=>net1}
|
||||
11000.0,11500.0 -> 3: (11000,1500;11000,6001;11500,6001;11500,1500) props={net=>net1}
|
||||
11500.0,13500.0 -> 0: (11500,-11;11500,0;13500,0;13500,-11) props={net=>net3}
|
||||
11500.0,13500.0 -> 1: (11500,1500;11500,6001;13500,6001;13500,1500) props={net=>net1}
|
||||
11500.0,13500.0 -> 2: (11500,2000;11500,4000;13500,4000;13500,2000) props={net=>net1}
|
||||
11500.0,13500.0 -> 3: (11500,1500;11500,6001;13500,6001;13500,1500) props={net=>net1}
|
||||
13500.0,14000.0 -> 0: (13500,-11;13500,0;14000,0;14000,-11) props={net=>net3}
|
||||
13500.0,14000.0 -> 1: (13500,1500;13500,6001;14000,6001;14000,1500) props={net=>net1}
|
||||
13500.0,14000.0 -> 3: (13500,1500;13500,6001;14000,6001;14000,1500) props={net=>net1}
|
||||
Edge: (0,20000;0,16500) props={net=>net3}
|
||||
0.0,3500.0 -> 0: (0,-11;0,0;3500,0;3500,-11) props={net=>net3}
|
||||
0.0,3500.0 -> 3: (0,-11;0,4500;3500,4500;3500,-11) props={net=>net2}
|
||||
3500.0,3501.0 -> 3: (3500,1500;3500,4500;3501,4500;3501,1500) props={net=>net2}
|
||||
Polygon: (-9500,-5500;-9500,-1500;5000,-1500;5000,-5500) props={net=>net2}
|
||||
Edge: (-9500,-1500;5000,-1500) props={net=>net2}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={net=>net2}
|
||||
0.0,3000.0 -> 1: (0,1500;0,6001;3000,6001;3000,1500) props={net=>net1}
|
||||
3000.0,4500.0 -> 0: (3000,-11;3000,0;4500,0;4500,-11) props={net=>net2}
|
||||
4500.0,9500.0 -> 0: (4500,-11;4500,0;9500,0;9500,-11) props={net=>net2}
|
||||
4500.0,9500.0 -> 1: (4500,1500;4500,6001;9500,6001;9500,1500) props={net=>net1}
|
||||
9500.0,11000.0 -> 0: (9500,-11;9500,0;11000,0;11000,-11) props={net=>net2}
|
||||
11000.0,14000.0 -> 0: (11000,-11;11000,0;14000,0;14000,-11) props={net=>net2}
|
||||
11000.0,14000.0 -> 3: (11000,-11;11000,6001;14000,6001;14000,-11) props={net=>net2}
|
||||
14000.0,14500.0 -> 0: (14000,-11;14000,0;14500,0;14500,-11) props={net=>net2}
|
||||
Edge: (-9500,-5500;-9500,-1500) props={net=>net2}
|
||||
0.0,4000.0 -> 0: (0,-11;0,0;4000,0;4000,-11) props={net=>net2}
|
||||
Edge: (5000,-1500;5000,-5500) props={net=>net2}
|
||||
0.0,4000.0 -> 0: (0,-11;0,0;4000,0;4000,-11) props={net=>net2}
|
||||
Edge: (5000,-5500;-9500,-5500) props={net=>net2}
|
||||
0.0,14500.0 -> 0: (0,-11;0,0;14500,0;14500,-11) props={net=>net2}
|
||||
Polygon: (-9500,0;-9500,15000;0,15000;0,0;-5000,0;-5000,12000;-6500,12000;-6500,0) props={net=>net1}
|
||||
Edge: (-5000,0;-5000,12000) props={net=>net1}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={net=>net1}/(0,1500;0,4500;6500,4500;6500,1500) props={net=>net1}
|
||||
0.0,6500.0 -> 1: (0,6000;0,6001;6500,6001;6500,6000) props={net=>net1}
|
||||
6500.0,12000.0 -> 0: (6500,-11;6500,0;12000,0;12000,-11) props={net=>net1}/(6500,1500;6500,4500;12000,4500;12000,1500) props={net=>net1}
|
||||
6500.0,12000.0 -> 1: (6500,6000;6500,6001;12000,6001;12000,6000) props={net=>net1}
|
||||
6500.0,12000.0 -> 3: (6500,6000;6500,6001;12000,6001;12000,6000) props={net=>net1}
|
||||
12000.0,12001.0 -> 0: (12000,-11;12000,4500;12001,4500;12001,-11) props={net=>net1}
|
||||
12000.0,12001.0 -> 1: (12000,6000;12000,6001;12001,6001;12001,6000) props={net=>net1}
|
||||
12000.0,12001.0 -> 3: (12000,1500;12000,6001;12001,6001;12001,1500) props={net=>net1}
|
||||
Edge: (-5000,12000;-6500,12000) props={net=>net1}
|
||||
-1.0,0.0 -> 0: (-1,-11;-1,6001;0,6001;0,-11) props={net=>net1}
|
||||
0.0,1500.0 -> 0: (0,-11;0,0;1500,0;1500,-11) props={net=>net1}
|
||||
1500.0,1501.0 -> 0: (1500,-11;1500,6001;1501,6001;1501,-11) props={net=>net1}
|
||||
1500.0,1501.0 -> 3: (1500,-11;1500,0;1501,0;1501,-11) props={net=>net1}
|
||||
Edge: (-6500,0;-9500,0) props={net=>net1}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5500;0,5500;0,1500) props={net=>net2}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={net=>net1}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5500;3000,5500;3000,1500) props={net=>net2}
|
||||
Edge: (-6500,12000;-6500,0) props={net=>net1}
|
||||
-1.0,0.0 -> 0: (-1,-11;-1,6001;0,6001;0,-11) props={net=>net1}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={net=>net1}
|
||||
0.0,12000.0 -> 0: (0,-11;0,0;12000,0;12000,-11) props={net=>net1}/(0,1500;0,6001;12000,6001;12000,1500) props={net=>net1}
|
||||
Edge: (-9500,0;-9500,15000) props={net=>net1}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={net=>net1}
|
||||
0.0,6500.0 -> 1: (0,1500;0,4500;6500,4500;6500,1500) props={net=>net1}
|
||||
6500.0,12000.0 -> 0: (6500,-11;6500,0;12000,0;12000,-11) props={net=>net1}
|
||||
6500.0,12000.0 -> 1: (6500,1500;6500,4500;12000,4500;12000,1500) props={net=>net1}
|
||||
6500.0,12000.0 -> 3: (6500,1500;6500,4500;12000,4500;12000,1500) props={net=>net1}
|
||||
12000.0,12500.0 -> 0: (12000,-11;12000,0;12500,0;12500,-11) props={net=>net1}
|
||||
12000.0,12500.0 -> 1: (12000,1500;12000,4500;12500,4500;12500,1500) props={net=>net1}
|
||||
12000.0,12500.0 -> 3: (12000,-11;12000,4500;12500,4500;12500,-11) props={net=>net1}
|
||||
12500.0,14500.0 -> 0: (12500,-11;12500,0;14500,0;14500,-11) props={net=>net1}
|
||||
12500.0,14500.0 -> 1: (12500,1500;12500,4500;14500,4500;14500,1500) props={net=>net1}
|
||||
12500.0,14500.0 -> 2: (12500,2000;12500,4000;14500,4000;14500,2000) props={net=>net1}
|
||||
12500.0,14500.0 -> 3: (12500,-11;12500,4500;14500,4500;14500,-11) props={net=>net1}
|
||||
14500.0,15000.0 -> 0: (14500,-11;14500,0;15000,0;15000,-11) props={net=>net1}
|
||||
14500.0,15000.0 -> 1: (14500,1500;14500,4500;15000,4500;15000,1500) props={net=>net1}
|
||||
14500.0,15000.0 -> 3: (14500,-11;14500,4500;15000,4500;15000,-11) props={net=>net1}
|
||||
Edge: (-9500,15000;0,15000) props={net=>net1}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5000;0,5000;0,1500) props={net=>net3}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={net=>net1}
|
||||
0.0,2500.0 -> 0: (0,-11;0,0;2500,0;2500,-11) props={net=>net1}
|
||||
0.0,2500.0 -> 1: (0,1500;0,5000;2500,5000;2500,1500) props={net=>net3}
|
||||
0.0,2500.0 -> 3: (0,-11;0,0;2500,0;2500,-11) props={net=>net1}
|
||||
2500.0,3000.0 -> 0: (2500,-11;2500,0;3000,0;3000,-11) props={net=>net1}
|
||||
2500.0,3000.0 -> 1: (2500,1500;2500,5000;3000,5000;3000,1500) props={net=>net3}
|
||||
2500.0,3000.0 -> 3: (2500,-11;2500,0;3000,0;3000,-11) props={net=>net1}/(2500,1500;2500,5000;3000,5000;3000,1500) props={net=>net2}
|
||||
3000.0,9500.0 -> 0: (3000,-11;3000,0;9500,0;9500,-11) props={net=>net1}
|
||||
3000.0,9500.0 -> 1: (3000,1500;3000,5000;9500,5000;9500,1500) props={net=>net3}
|
||||
3000.0,9500.0 -> 3: (3000,1500;3000,5000;9500,5000;9500,1500) props={net=>net2}
|
||||
9500.0,9501.0 -> 3: (9500,1500;9500,5000;9501,5000;9501,1500) props={net=>net2}
|
||||
Edge: (0,0;-5000,0) props={net=>net1}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5500;0,5500;0,1500) props={net=>net2}
|
||||
-1.0,0.0 -> 3: (-1,2000;-1,5000;0,5000;0,2000) props={net=>net2}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={net=>net1}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5500;3000,5500;3000,1500) props={net=>net2}
|
||||
0.0,3000.0 -> 3: (0,2000;0,5000;3000,5000;3000,2000) props={net=>net2}
|
||||
3000.0,5000.0 -> 0: (3000,-11;3000,0;5000,0;5000,-11) props={net=>net1}
|
||||
3000.0,5000.0 -> 1: (3000,1500;3000,5500;5000,5500;5000,1500) props={net=>net2}
|
||||
5000.0,5001.0 -> 1: (5000,1500;5000,5500;5001,5500;5001,1500) props={net=>net2}
|
||||
Edge: (0,15000;0,0) props={net=>net1}
|
||||
-1.0,0.0 -> 3: (-1,1500;-1,4500;0,4500;0,1500) props={net=>net2}
|
||||
0.0,15000.0 -> 0: (0,-11;0,0;15000,0;15000,-11) props={net=>net1}
|
||||
0.0,15000.0 -> 3: (0,1500;0,4500;15000,4500;15000,1500) props={net=>net2}
|
||||
15000.0,15001.0 -> 3: (15000,1500;15000,4500;15001,4500;15001,1500) props={net=>net2}
|
||||
Polygon: (-14000,0;-14000,15000;-11000,15000;-11000,0) props={'net'=>'net1'}
|
||||
Edge: (-11000,0;-14000,0) props={'net'=>'net1'}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
Edge: (-11000,15000;-11000,0) props={'net'=>'net1'}
|
||||
0.0,500.0 -> 0: (0,-11;0,0;500,0;500,-11) props={'net'=>'net1'}
|
||||
0.0,500.0 -> 1: (0,1500;0,6001;500,6001;500,1500) props={'net'=>'net1'}
|
||||
0.0,500.0 -> 3: (0,-11;0,4500;500,4500;500,-11) props={'net'=>'net1'}
|
||||
500.0,2500.0 -> 0: (500,-11;500,0;2500,0;2500,-11) props={'net'=>'net1'}
|
||||
500.0,2500.0 -> 1: (500,1500;500,6001;2500,6001;2500,1500) props={'net'=>'net1'}
|
||||
500.0,2500.0 -> 2: (500,2000;500,4000;2500,4000;2500,2000) props={'net'=>'net1'}
|
||||
500.0,2500.0 -> 3: (500,-11;500,4500;2500,4500;2500,-11) props={'net'=>'net1'}
|
||||
2500.0,3000.0 -> 0: (2500,-11;2500,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
2500.0,3000.0 -> 1: (2500,1500;2500,6001;3000,6001;3000,1500) props={'net'=>'net1'}
|
||||
2500.0,3000.0 -> 3: (2500,-11;2500,4500;3000,4500;3000,-11) props={'net'=>'net1'}
|
||||
3000.0,8500.0 -> 0: (3000,-11;3000,0;8500,0;8500,-11) props={'net'=>'net1'}
|
||||
3000.0,8500.0 -> 1: (3000,1500;3000,4500;8500,4500;8500,1500) props={'net'=>'net1'}/(3000,6000;3000,6001;8500,6001;8500,6000) props={'net'=>'net1'}
|
||||
3000.0,8500.0 -> 3: (3000,-11;3000,0;8500,0;8500,-11) props={'net'=>'net1'}
|
||||
8500.0,15000.0 -> 0: (8500,-11;8500,0;15000,0;15000,-11) props={'net'=>'net1'}
|
||||
8500.0,15000.0 -> 1: (8500,1500;8500,4500;15000,4500;15000,1500) props={'net'=>'net1'}/(8500,6000;8500,6001;15000,6001;15000,6000) props={'net'=>'net1'}
|
||||
Edge: (-14000,0;-14000,15000) props={'net'=>'net1'}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={'net'=>'net1'}
|
||||
6500.0,15000.0 -> 0: (6500,-11;6500,0;15000,0;15000,-11) props={'net'=>'net1'}
|
||||
6500.0,15000.0 -> 3: (6500,-11;6500,0;15000,0;15000,-11) props={'net'=>'net1'}
|
||||
Edge: (-14000,15000;-11000,15000) props={'net'=>'net1'}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5000;3000,5000;3000,1500) props={'net'=>'net3'}
|
||||
0.0,3000.0 -> 3: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
3000.0,3001.0 -> 1: (3000,1500;3000,5000;3001,5000;3001,1500) props={'net'=>'net3'}
|
||||
3000.0,3001.0 -> 3: (3000,-11;3000,0;3001,0;3001,-11) props={'net'=>'net1'}
|
||||
Polygon: (-14000,16500;-14000,20000;0,20000;0,16500) props={'net'=>'net3'}
|
||||
Edge: (-14000,16500;-14000,20000) props={'net'=>'net3'}
|
||||
0.0,3500.0 -> 0: (0,-11;0,0;3500,0;3500,-11) props={'net'=>'net3'}
|
||||
Edge: (-14000,20000;0,20000) props={'net'=>'net3'}
|
||||
0.0,7000.0 -> 0: (0,-11;0,0;7000,0;7000,-11) props={'net'=>'net3'}
|
||||
7000.0,14000.0 -> 0: (7000,-11;7000,0;14000,0;14000,-11) props={'net'=>'net3'}
|
||||
7000.0,14000.0 -> 3: (7000,-11;7000,0;14000,0;14000,-11) props={'net'=>'net2'}
|
||||
14000.0,14001.0 -> 3: (14000,-11;14000,0;14001,0;14001,-11) props={'net'=>'net2'}
|
||||
Edge: (0,16500;-14000,16500) props={'net'=>'net3'}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={'net'=>'net2'}
|
||||
0.0,5000.0 -> 0: (0,-11;0,0;5000,0;5000,-11) props={'net'=>'net3'}
|
||||
0.0,5000.0 -> 1: (0,1500;0,6001;5000,6001;5000,1500) props={'net'=>'net1'}
|
||||
0.0,5000.0 -> 3: (0,-11;0,0;5000,0;5000,-11) props={'net'=>'net2'}
|
||||
5000.0,6500.0 -> 0: (5000,-11;5000,0;6500,0;6500,-11) props={'net'=>'net3'}
|
||||
5000.0,6500.0 -> 1: (5000,1500;5000,4500;6500,4500;6500,1500) props={'net'=>'net1'}
|
||||
5000.0,6500.0 -> 3: (5000,-11;5000,0;6500,0;6500,-11) props={'net'=>'net2'}
|
||||
6500.0,7000.0 -> 0: (6500,-11;6500,0;7000,0;7000,-11) props={'net'=>'net3'}
|
||||
6500.0,7000.0 -> 1: (6500,1500;6500,6001;7000,6001;7000,1500) props={'net'=>'net1'}
|
||||
6500.0,7000.0 -> 3: (6500,-11;6500,0;7000,0;7000,-11) props={'net'=>'net2'}/(6500,1500;6500,4500;7000,4500;7000,1500) props={'net'=>'net1'}
|
||||
7000.0,9000.0 -> 0: (7000,-11;7000,0;9000,0;9000,-11) props={'net'=>'net3'}
|
||||
7000.0,9000.0 -> 1: (7000,1500;7000,6001;9000,6001;9000,1500) props={'net'=>'net1'}
|
||||
7000.0,9000.0 -> 2: (7000,2000;7000,4000;9000,4000;9000,2000) props={'net'=>'net1'}
|
||||
7000.0,9000.0 -> 3: (7000,1500;7000,4500;9000,4500;9000,1500) props={'net'=>'net1'}
|
||||
9000.0,9500.0 -> 0: (9000,-11;9000,0;9500,0;9500,-11) props={'net'=>'net3'}
|
||||
9000.0,9500.0 -> 1: (9000,1500;9000,6001;9500,6001;9500,1500) props={'net'=>'net1'}
|
||||
9000.0,9500.0 -> 3: (9000,1500;9000,4500;9500,4500;9500,1500) props={'net'=>'net1'}
|
||||
9500.0,11000.0 -> 0: (9500,-11;9500,0;11000,0;11000,-11) props={'net'=>'net3'}
|
||||
9500.0,11000.0 -> 3: (9500,1500;9500,4500;11000,4500;11000,1500) props={'net'=>'net1'}
|
||||
11000.0,11500.0 -> 0: (11000,-11;11000,0;11500,0;11500,-11) props={'net'=>'net3'}
|
||||
11000.0,11500.0 -> 1: (11000,1500;11000,6001;11500,6001;11500,1500) props={'net'=>'net1'}
|
||||
11000.0,11500.0 -> 3: (11000,1500;11000,6001;11500,6001;11500,1500) props={'net'=>'net1'}
|
||||
11500.0,13500.0 -> 0: (11500,-11;11500,0;13500,0;13500,-11) props={'net'=>'net3'}
|
||||
11500.0,13500.0 -> 1: (11500,1500;11500,6001;13500,6001;13500,1500) props={'net'=>'net1'}
|
||||
11500.0,13500.0 -> 2: (11500,2000;11500,4000;13500,4000;13500,2000) props={'net'=>'net1'}
|
||||
11500.0,13500.0 -> 3: (11500,1500;11500,6001;13500,6001;13500,1500) props={'net'=>'net1'}
|
||||
13500.0,14000.0 -> 0: (13500,-11;13500,0;14000,0;14000,-11) props={'net'=>'net3'}
|
||||
13500.0,14000.0 -> 1: (13500,1500;13500,6001;14000,6001;14000,1500) props={'net'=>'net1'}
|
||||
13500.0,14000.0 -> 3: (13500,1500;13500,6001;14000,6001;14000,1500) props={'net'=>'net1'}
|
||||
Edge: (0,20000;0,16500) props={'net'=>'net3'}
|
||||
0.0,3500.0 -> 0: (0,-11;0,0;3500,0;3500,-11) props={'net'=>'net3'}
|
||||
0.0,3500.0 -> 3: (0,-11;0,4500;3500,4500;3500,-11) props={'net'=>'net2'}
|
||||
3500.0,3501.0 -> 3: (3500,1500;3500,4500;3501,4500;3501,1500) props={'net'=>'net2'}
|
||||
Polygon: (-9500,-5500;-9500,-1500;5000,-1500;5000,-5500) props={'net'=>'net2'}
|
||||
Edge: (-9500,-1500;5000,-1500) props={'net'=>'net2'}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net2'}
|
||||
0.0,3000.0 -> 1: (0,1500;0,6001;3000,6001;3000,1500) props={'net'=>'net1'}
|
||||
3000.0,4500.0 -> 0: (3000,-11;3000,0;4500,0;4500,-11) props={'net'=>'net2'}
|
||||
4500.0,9500.0 -> 0: (4500,-11;4500,0;9500,0;9500,-11) props={'net'=>'net2'}
|
||||
4500.0,9500.0 -> 1: (4500,1500;4500,6001;9500,6001;9500,1500) props={'net'=>'net1'}
|
||||
9500.0,11000.0 -> 0: (9500,-11;9500,0;11000,0;11000,-11) props={'net'=>'net2'}
|
||||
11000.0,14000.0 -> 0: (11000,-11;11000,0;14000,0;14000,-11) props={'net'=>'net2'}
|
||||
11000.0,14000.0 -> 3: (11000,-11;11000,6001;14000,6001;14000,-11) props={'net'=>'net2'}
|
||||
14000.0,14500.0 -> 0: (14000,-11;14000,0;14500,0;14500,-11) props={'net'=>'net2'}
|
||||
Edge: (-9500,-5500;-9500,-1500) props={'net'=>'net2'}
|
||||
0.0,4000.0 -> 0: (0,-11;0,0;4000,0;4000,-11) props={'net'=>'net2'}
|
||||
Edge: (5000,-1500;5000,-5500) props={'net'=>'net2'}
|
||||
0.0,4000.0 -> 0: (0,-11;0,0;4000,0;4000,-11) props={'net'=>'net2'}
|
||||
Edge: (5000,-5500;-9500,-5500) props={'net'=>'net2'}
|
||||
0.0,14500.0 -> 0: (0,-11;0,0;14500,0;14500,-11) props={'net'=>'net2'}
|
||||
Polygon: (-9500,0;-9500,15000;0,15000;0,0;-5000,0;-5000,12000;-6500,12000;-6500,0) props={'net'=>'net1'}
|
||||
Edge: (-5000,0;-5000,12000) props={'net'=>'net1'}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={'net'=>'net1'}/(0,1500;0,4500;6500,4500;6500,1500) props={'net'=>'net1'}
|
||||
0.0,6500.0 -> 1: (0,6000;0,6001;6500,6001;6500,6000) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 0: (6500,-11;6500,0;12000,0;12000,-11) props={'net'=>'net1'}/(6500,1500;6500,4500;12000,4500;12000,1500) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 1: (6500,6000;6500,6001;12000,6001;12000,6000) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 3: (6500,6000;6500,6001;12000,6001;12000,6000) props={'net'=>'net1'}
|
||||
12000.0,12001.0 -> 0: (12000,-11;12000,4500;12001,4500;12001,-11) props={'net'=>'net1'}
|
||||
12000.0,12001.0 -> 1: (12000,6000;12000,6001;12001,6001;12001,6000) props={'net'=>'net1'}
|
||||
12000.0,12001.0 -> 3: (12000,1500;12000,6001;12001,6001;12001,1500) props={'net'=>'net1'}
|
||||
Edge: (-5000,12000;-6500,12000) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 0: (-1,-11;-1,6001;0,6001;0,-11) props={'net'=>'net1'}
|
||||
0.0,1500.0 -> 0: (0,-11;0,0;1500,0;1500,-11) props={'net'=>'net1'}
|
||||
1500.0,1501.0 -> 0: (1500,-11;1500,6001;1501,6001;1501,-11) props={'net'=>'net1'}
|
||||
1500.0,1501.0 -> 3: (1500,-11;1500,0;1501,0;1501,-11) props={'net'=>'net1'}
|
||||
Edge: (-6500,0;-9500,0) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5500;0,5500;0,1500) props={'net'=>'net2'}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5500;3000,5500;3000,1500) props={'net'=>'net2'}
|
||||
Edge: (-6500,12000;-6500,0) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 0: (-1,-11;-1,6001;0,6001;0,-11) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={'net'=>'net1'}
|
||||
0.0,12000.0 -> 0: (0,-11;0,0;12000,0;12000,-11) props={'net'=>'net1'}/(0,1500;0,6001;12000,6001;12000,1500) props={'net'=>'net1'}
|
||||
Edge: (-9500,0;-9500,15000) props={'net'=>'net1'}
|
||||
0.0,6500.0 -> 0: (0,-11;0,0;6500,0;6500,-11) props={'net'=>'net1'}
|
||||
0.0,6500.0 -> 1: (0,1500;0,4500;6500,4500;6500,1500) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 0: (6500,-11;6500,0;12000,0;12000,-11) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 1: (6500,1500;6500,4500;12000,4500;12000,1500) props={'net'=>'net1'}
|
||||
6500.0,12000.0 -> 3: (6500,1500;6500,4500;12000,4500;12000,1500) props={'net'=>'net1'}
|
||||
12000.0,12500.0 -> 0: (12000,-11;12000,0;12500,0;12500,-11) props={'net'=>'net1'}
|
||||
12000.0,12500.0 -> 1: (12000,1500;12000,4500;12500,4500;12500,1500) props={'net'=>'net1'}
|
||||
12000.0,12500.0 -> 3: (12000,-11;12000,4500;12500,4500;12500,-11) props={'net'=>'net1'}
|
||||
12500.0,14500.0 -> 0: (12500,-11;12500,0;14500,0;14500,-11) props={'net'=>'net1'}
|
||||
12500.0,14500.0 -> 1: (12500,1500;12500,4500;14500,4500;14500,1500) props={'net'=>'net1'}
|
||||
12500.0,14500.0 -> 2: (12500,2000;12500,4000;14500,4000;14500,2000) props={'net'=>'net1'}
|
||||
12500.0,14500.0 -> 3: (12500,-11;12500,4500;14500,4500;14500,-11) props={'net'=>'net1'}
|
||||
14500.0,15000.0 -> 0: (14500,-11;14500,0;15000,0;15000,-11) props={'net'=>'net1'}
|
||||
14500.0,15000.0 -> 1: (14500,1500;14500,4500;15000,4500;15000,1500) props={'net'=>'net1'}
|
||||
14500.0,15000.0 -> 3: (14500,-11;14500,4500;15000,4500;15000,-11) props={'net'=>'net1'}
|
||||
Edge: (-9500,15000;0,15000) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5000;0,5000;0,1500) props={'net'=>'net3'}
|
||||
-1.0,0.0 -> 3: (-1,-11;-1,0;0,0;0,-11) props={'net'=>'net1'}
|
||||
0.0,2500.0 -> 0: (0,-11;0,0;2500,0;2500,-11) props={'net'=>'net1'}
|
||||
0.0,2500.0 -> 1: (0,1500;0,5000;2500,5000;2500,1500) props={'net'=>'net3'}
|
||||
0.0,2500.0 -> 3: (0,-11;0,0;2500,0;2500,-11) props={'net'=>'net1'}
|
||||
2500.0,3000.0 -> 0: (2500,-11;2500,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
2500.0,3000.0 -> 1: (2500,1500;2500,5000;3000,5000;3000,1500) props={'net'=>'net3'}
|
||||
2500.0,3000.0 -> 3: (2500,-11;2500,0;3000,0;3000,-11) props={'net'=>'net1'}/(2500,1500;2500,5000;3000,5000;3000,1500) props={'net'=>'net2'}
|
||||
3000.0,9500.0 -> 0: (3000,-11;3000,0;9500,0;9500,-11) props={'net'=>'net1'}
|
||||
3000.0,9500.0 -> 1: (3000,1500;3000,5000;9500,5000;9500,1500) props={'net'=>'net3'}
|
||||
3000.0,9500.0 -> 3: (3000,1500;3000,5000;9500,5000;9500,1500) props={'net'=>'net2'}
|
||||
9500.0,9501.0 -> 3: (9500,1500;9500,5000;9501,5000;9501,1500) props={'net'=>'net2'}
|
||||
Edge: (0,0;-5000,0) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 1: (-1,1500;-1,5500;0,5500;0,1500) props={'net'=>'net2'}
|
||||
-1.0,0.0 -> 3: (-1,2000;-1,5000;0,5000;0,2000) props={'net'=>'net2'}
|
||||
0.0,3000.0 -> 0: (0,-11;0,0;3000,0;3000,-11) props={'net'=>'net1'}
|
||||
0.0,3000.0 -> 1: (0,1500;0,5500;3000,5500;3000,1500) props={'net'=>'net2'}
|
||||
0.0,3000.0 -> 3: (0,2000;0,5000;3000,5000;3000,2000) props={'net'=>'net2'}
|
||||
3000.0,5000.0 -> 0: (3000,-11;3000,0;5000,0;5000,-11) props={'net'=>'net1'}
|
||||
3000.0,5000.0 -> 1: (3000,1500;3000,5500;5000,5500;5000,1500) props={'net'=>'net2'}
|
||||
5000.0,5001.0 -> 1: (5000,1500;5000,5500;5001,5500;5001,1500) props={'net'=>'net2'}
|
||||
Edge: (0,15000;0,0) props={'net'=>'net1'}
|
||||
-1.0,0.0 -> 3: (-1,1500;-1,4500;0,4500;0,1500) props={'net'=>'net2'}
|
||||
0.0,15000.0 -> 0: (0,-11;0,0;15000,0;15000,-11) props={'net'=>'net1'}
|
||||
0.0,15000.0 -> 3: (0,1500;0,4500;15000,4500;15000,1500) props={'net'=>'net2'}
|
||||
15000.0,15001.0 -> 3: (15000,1500;15000,4500;15001,4500;15001,1500) props={'net'=>'net2'}
|
||||
""")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class DBBox_TestClass < TestBase
|
|||
a = RBA::DBox::new( -10, 21, 11, 17 )
|
||||
assert_equal( a.to_s, "(-10,17;11,21)" )
|
||||
assert_equal( RBA::DBox::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DBox::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (a*0.5).to_s, "(-5,8.5;5.5,10.5)" )
|
||||
|
||||
b = a
|
||||
|
|
@ -263,6 +264,7 @@ class DBBox_TestClass < TestBase
|
|||
a = RBA::Box::new( -10, 21, 11, 17 )
|
||||
assert_equal( a.to_s, "(-10,17;11,21)" )
|
||||
assert_equal( RBA::Box::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Box::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (a*2).to_s, "(-20,34;22,42)" )
|
||||
|
||||
b = a
|
||||
|
|
@ -518,16 +520,16 @@ class DBBox_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -536,20 +538,40 @@ class DBBox_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
||||
# binary serialization
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::BoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::BoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DBoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DBoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
|
||||
# string serialization
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::BoxWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::BoxWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DBoxWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DBoxWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -123,15 +123,15 @@ class DBEdgeNeighborhood_TestClass < TestBase
|
|||
"edge = (-1100,0;-1100,1000) props={}\n" +
|
||||
"edge = (-1100,1000;-100,1000) props={}\n" +
|
||||
"edge = (-100,1000;-100,0) props={}\n" +
|
||||
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100) props={1=>one}\n" +
|
||||
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100) props={#1=>'one'}\n" +
|
||||
"edge = (-100,0;-1100,0) props={}\n" +
|
||||
"/Polygon\n" +
|
||||
"Polygon: (0,0;0,1000;1000,1000;1000,0) props={1=>one}\n" +
|
||||
"edge = (0,0;0,1000) props={1=>one}\n" +
|
||||
"Polygon: (0,0;0,1000;1000,1000;1000,0) props={#1=>'one'}\n" +
|
||||
"edge = (0,0;0,1000) props={#1=>'one'}\n" +
|
||||
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100) props={}\n" +
|
||||
"edge = (0,1000;1000,1000) props={1=>one}\n" +
|
||||
"edge = (1000,1000;1000,0) props={1=>one}\n" +
|
||||
"edge = (1000,0;0,0) props={1=>one}\n" +
|
||||
"edge = (0,1000;1000,1000) props={#1=>'one'}\n" +
|
||||
"edge = (1000,1000;1000,0) props={#1=>'one'}\n" +
|
||||
"edge = (1000,0;0,0) props={#1=>'one'}\n" +
|
||||
"/Polygon\n"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(ep.to_s, "(0,0;10,20)/(-10,0;-10,30)")
|
||||
assert_equal(ep.bbox.to_s, "(-10,0;10,30)")
|
||||
|
||||
assert_equal(RBA::EdgePair::from_s(ep.to_s).to_s, ep.to_s)
|
||||
assert_equal(RBA::EdgePair::from_bytes(ep.to_bytes).to_s, ep.to_s)
|
||||
|
||||
assert_equal(RBA::EdgePair::new(ep.first, ep.second).to_s, "(0,0;10,20)/(-10,0;-10,30)")
|
||||
|
||||
ep2 = RBA::EdgePair::new
|
||||
|
|
@ -91,6 +94,9 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(ep.to_s, "(0,0;10,20)/(-10,0;-10,30)")
|
||||
assert_equal(ep.bbox.to_s, "(-10,0;10,30)")
|
||||
|
||||
assert_equal(RBA::DEdgePair::from_s(ep.to_s).to_s, ep.to_s)
|
||||
assert_equal(RBA::DEdgePair::from_bytes(ep.to_bytes).to_s, ep.to_s)
|
||||
|
||||
assert_equal(RBA::DEdgePair::new(ep.first, ep.second).to_s, "(0,0;10,20)/(-10,0;-10,30)")
|
||||
|
||||
ep2 = RBA::DEdgePair::new
|
||||
|
|
@ -252,16 +258,16 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}")
|
||||
|
||||
s = RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 200), RBA::Edge::new(10, 10, 110, 210)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 200), RBA::Edge::new(10, 10, 110, 210)), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2)/(0.01,0.01;0.11,0.21) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2)/(0.01,0.01;0.11,0.21) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -270,16 +276,16 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}")
|
||||
|
||||
s = RBA::DEdgePairWithProperties::new(RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 100, 200), RBA::DEdge::new(10, 10, 110, 210)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DEdgePairWithProperties::new(RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 100, 200), RBA::DEdge::new(10, 10, 110, 210)), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500)/(25,25;275,525) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500)/(25,25;275,525) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
|
|||
|
|
@ -622,7 +622,7 @@ class DBEdgePairs_TestClass < TestBase
|
|||
|
||||
r = RBA::EdgePairs::new([ RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 100), RBA::Edge::new(200, 300, 200, 500)), { 1 => "one" }) ])
|
||||
assert_equal(r.to_s, "(0,0;100,100)/(200,300;200,500){1=>one}")
|
||||
assert_equal(r[0].to_s, "(0,0;100,100)/(200,300;200,500) props={1=>one}")
|
||||
assert_equal(r[0].to_s, "(0,0;100,100)/(200,300;200,500) props={#1=>'one'}")
|
||||
|
||||
r = RBA::EdgePairs::new([])
|
||||
assert_equal(r.to_s, "")
|
||||
|
|
@ -638,7 +638,7 @@ class DBEdgePairs_TestClass < TestBase
|
|||
r.insert(RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 100), RBA::Edge::new(200, 300, 200, 500)), { 1 => "one" }))
|
||||
r.insert(RBA::EdgePair::new(RBA::Edge::new(0, 10, 100, 110), RBA::Edge::new(220, 300, 220, 500)))
|
||||
s = r.each.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(0,10;100,110)/(220,300;220,500) props={};(0,0;100,100)/(200,300;200,500) props={1=>one}")
|
||||
assert_equal(s, "(0,10;100,110)/(220,300;220,500) props={};(0,0;100,100)/(200,300;200,500) props={#1=>'one'}")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class DBEdge_TestClass < TestBase
|
|||
a = RBA::DEdge::new( -1, 2, 15, -7 )
|
||||
assert_equal( a.to_s, "(-1,2;15,-7)" )
|
||||
assert_equal( RBA::DEdge::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DEdge::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (a*0.5).to_s, "(-0.5,1;7.5,-3.5)" )
|
||||
d = RBA::Edge::new( a )
|
||||
assert_equal( d.to_s, "(-1,2;15,-7)" )
|
||||
|
|
@ -156,6 +157,7 @@ class DBEdge_TestClass < TestBase
|
|||
a = RBA::Edge::new( RBA::Point::new( -1, 2 ), RBA::Point::new( 15, -7 ) )
|
||||
assert_equal( a.to_s, "(-1,2;15,-7)" )
|
||||
assert_equal( RBA::Edge::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Edge::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (a*2).to_s, "(-2,4;30,-14)" )
|
||||
d = RBA::DEdge::new( a )
|
||||
assert_equal( d.to_s, "(-1,2;15,-7)" )
|
||||
|
|
@ -339,31 +341,31 @@ class DBEdge_TestClass < TestBase
|
|||
assert_equal(s.to_s, "(0,0;0,0) props={}")
|
||||
|
||||
s = RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 200), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 200), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::CplxTrans::new(0.001)).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::ICplxTrans::new(2.5)).to_s, "(0,0;250,500) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::Trans::R90).to_s, "(0,0;-200,100) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::CplxTrans::new(0.001)).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::ICplxTrans::new(2.5)).to_s, "(0,0;250,500) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::Trans::R90).to_s, "(0,0;-200,100) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.transform(RBA::Trans::R90)
|
||||
assert_equal(s2.to_s, "(0,0;-200,100) props={1=>one}")
|
||||
assert_equal((s * 0.001).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.moved(10, 20).to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s.moved(RBA::Vector::new(10, 20)).to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(0,0;-200,100) props={#1=>'one'}")
|
||||
assert_equal((s * 0.001).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.moved(10, 20).to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
assert_equal(s.moved(RBA::Vector::new(10, 20)).to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.move(10, 20)
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.move(RBA::Vector::new(10, 20))
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -372,31 +374,31 @@ class DBEdge_TestClass < TestBase
|
|||
assert_equal(s.to_s, "(0,0;0,0) props={}")
|
||||
|
||||
s = RBA::DEdgeWithProperties::new(RBA::DEdge::new(0, 0, 100, 200), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DEdgeWithProperties::new(RBA::DEdge::new(0, 0, 100, 200), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::DCplxTrans::new(0.001)).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::VCplxTrans::new(2.5)).to_s, "(0,0;250,500) props={1=>one}")
|
||||
assert_equal(s.transformed(RBA::DTrans::R90).to_s, "(0,0;-200,100) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::DCplxTrans::new(0.001)).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::VCplxTrans::new(2.5)).to_s, "(0,0;250,500) props={#1=>'one'}")
|
||||
assert_equal(s.transformed(RBA::DTrans::R90).to_s, "(0,0;-200,100) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.transform(RBA::DTrans::R90)
|
||||
assert_equal(s2.to_s, "(0,0;-200,100) props={1=>one}")
|
||||
assert_equal((s * 0.001).to_s, "(0,0;0.1,0.2) props={1=>one}")
|
||||
assert_equal(s.moved(10, 20).to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s.moved(RBA::DVector::new(10, 20)).to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(0,0;-200,100) props={#1=>'one'}")
|
||||
assert_equal((s * 0.001).to_s, "(0,0;0.1,0.2) props={#1=>'one'}")
|
||||
assert_equal(s.moved(10, 20).to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
assert_equal(s.moved(RBA::DVector::new(10, 20)).to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.move(10, 20)
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
s2 = s.dup
|
||||
s2.move(RBA::DVector::new(10, 20))
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={1=>one}")
|
||||
assert_equal(s2.to_s, "(10,20;110,220) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,200) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
|
|||
|
|
@ -970,7 +970,7 @@ class DBEdges_TestClass < TestBase
|
|||
|
||||
r = RBA::Edges::new([ RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }) ])
|
||||
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
|
||||
assert_equal(r[0].to_s, "(0,0;100,100) props={1=>one}")
|
||||
assert_equal(r[0].to_s, "(0,0;100,100) props={#1=>'one'}")
|
||||
|
||||
r = RBA::Edges::new([])
|
||||
assert_equal(r.to_s, "")
|
||||
|
|
@ -1040,15 +1040,15 @@ class DBEdges_TestClass < TestBase
|
|||
r.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 0), { 1 => "one" }))
|
||||
r.insert(RBA::Edge::new(10, 0, 110, 0))
|
||||
s = r.each.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(10,0;110,0) props={};(0,0;100,0) props={1=>one}")
|
||||
assert_equal(s, "(10,0;110,0) props={};(0,0;100,0) props={#1=>'one'}")
|
||||
s = r.each_merged.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(10,0;110,0) props={};(0,0;100,0) props={1=>one}")
|
||||
assert_equal(s, "(10,0;110,0) props={};(0,0;100,0) props={#1=>'one'}")
|
||||
|
||||
r = RBA::Edges::new
|
||||
r.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 0), { 1 => "one" }))
|
||||
r.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(10, 0, 110, 0), { 1 => "one" }))
|
||||
s = r.each_merged.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(0,0;110,0) props={1=>one}")
|
||||
assert_equal(s, "(0,0;110,0) props={#1=>'one'}")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal( a.area.to_s, "0.0" )
|
||||
assert_equal( a.length.to_s, "0.0" )
|
||||
assert_equal( RBA::DPath::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPath::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
|
||||
b = a.dup
|
||||
a = RBA::DPath::new( [ RBA::DPoint::new( 0, 1 ), RBA::DPoint::new( 1, 5 ) ], 2.5 )
|
||||
|
|
@ -40,6 +41,7 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal( "%.3f" % a.area, "10.308" )
|
||||
assert_equal( "%.3f" % a.length, "4.123" )
|
||||
assert_equal( RBA::DPath::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPath::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
c = a.dup
|
||||
|
||||
assert_equal( a == b, false )
|
||||
|
|
@ -55,6 +57,7 @@ class DBPath_TestClass < TestBase
|
|||
a = RBA::DPath::new( [ RBA::DPoint::new( 0, 1 ), RBA::DPoint::new( 1, 5 ) ], 2.5, -0.5, 1.5 )
|
||||
assert_equal( a.to_s, "(0,1;1,5) w=2.5 bx=-0.5 ex=1.5 r=false" )
|
||||
assert_equal( RBA::DPath::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPath::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( "%.3f" % a.length, "5.123" )
|
||||
assert_equal( RBA::Path::new(a).to_s, "(0,1;1,5) w=3 bx=-1 ex=2 r=false" )
|
||||
|
||||
|
|
@ -122,6 +125,7 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal( a.area.to_f.to_s, "0.0" )
|
||||
assert_equal( a.length.to_s, "0" )
|
||||
assert_equal( RBA::Path::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Path::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
|
||||
b = a.dup
|
||||
a = RBA::Path::new( [ RBA::Point::new( 0, 10 ), RBA::Point::new( 10, 50 ) ], 25 )
|
||||
|
|
@ -129,6 +133,7 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal( a.area.to_f.to_s, "1025.0" )
|
||||
assert_equal( a.length.to_s, "41" )
|
||||
assert_equal( RBA::Path::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Path::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
c = a.dup
|
||||
|
||||
assert_equal( a == b, false )
|
||||
|
|
@ -144,6 +149,7 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal( a.to_s, "(0,10;10,50) w=25 bx=-5 ex=15 r=false" )
|
||||
assert_equal( a.length.to_s, "51" )
|
||||
assert_equal( RBA::Path::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Path::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( RBA::DPath::new(a).to_s, "(0,10;10,50) w=25 bx=-5 ex=15 r=false" )
|
||||
|
||||
a.bgn_ext = 5
|
||||
|
|
@ -335,16 +341,16 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() w=0 bx=0 ex=0 r=false props={}")
|
||||
|
||||
s = RBA::PathWithProperties::new(RBA::Path::new([ [0,0], [100, 0] ], 100), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::PathWithProperties::new(RBA::Path::new([ [0,0], [100, 0] ], 100), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0) w=0.1 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0) w=0.1 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -353,16 +359,16 @@ class DBPath_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() w=0 bx=0 ex=0 r=false props={}")
|
||||
|
||||
s = RBA::DPathWithProperties::new(RBA::DPath::new([ [0,0], [100, 0] ], 100), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DPathWithProperties::new(RBA::DPath::new([ [0,0], [100, 0] ], 100), pid)
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,0) w=250 bx=0 ex=0 r=false props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,0) w=250 bx=0 ex=0 r=false props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class DBPoint_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "1,-17" )
|
||||
assert_equal( RBA::DPoint::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPoint::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (-a).to_s, "-1,17" )
|
||||
assert_equal( b.to_s, "0,0" )
|
||||
assert_equal( c.to_s, "5,11" )
|
||||
|
|
@ -84,6 +85,7 @@ class DBPoint_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "1,-17" )
|
||||
assert_equal( RBA::Point::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Point::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (-a).to_s, "-1,17" )
|
||||
assert_equal( b.to_s, "0,0" )
|
||||
assert_equal( c.to_s, "5,11" )
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ class DBPolygonNeighborhood_TestClass < TestBase
|
|||
|
||||
assert_equal(visitor.log,
|
||||
"Polygon: (-1100,0;-1100,1000;-100,1000;-100,0) props={}\n" +
|
||||
" 0: (0,0;0,1000;1000,1000;1000,0) props={1=>one}\n" +
|
||||
"Polygon: (0,0;0,1000;1000,1000;1000,0) props={1=>one}\n" +
|
||||
" 0: (0,0;0,1000;1000,1000;1000,0) props={#1=>'one'}\n" +
|
||||
"Polygon: (0,0;0,1000;1000,1000;1000,0) props={#1=>'one'}\n" +
|
||||
" 0: (-1100,0;-1100,1000;-100,1000;-100,0) props={}\n"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class DBPolygon_TestClass < TestBase
|
|||
a = RBA::DPolygon::new
|
||||
assert_equal( a.to_s, "()" )
|
||||
assert_equal( RBA::DPolygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPolygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.is_box?, false )
|
||||
assert_equal( a.is_empty?, true )
|
||||
assert_equal( a.is_rectilinear?, false )
|
||||
|
|
@ -41,6 +42,7 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal( a.to_s, "(0,1;1,5;5,5)" )
|
||||
assert_equal( (a * 2).to_s, "(0,2;2,10;10,10)" )
|
||||
assert_equal( RBA::DPolygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPolygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.is_box?, false )
|
||||
assert_equal( a.num_points_hull, 3 )
|
||||
assert_equal( a.is_empty?, false )
|
||||
|
|
@ -101,6 +103,7 @@ class DBPolygon_TestClass < TestBase
|
|||
a.insert_hole( [ RBA::DPoint::new( 1, 2 ), RBA::DPoint::new( 2, 2 ), RBA::DPoint::new( 2, 6 ) ] )
|
||||
assert_equal( a.to_s, "(0,1;1,5;1,1/1,2;2,2;2,6)" )
|
||||
assert_equal( RBA::DPolygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DPolygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.area, 0 )
|
||||
assert_equal( a.num_points_hole(0), 3 )
|
||||
assert_equal( a.holes, 1 )
|
||||
|
|
@ -172,6 +175,7 @@ class DBPolygon_TestClass < TestBase
|
|||
a = RBA::Polygon::new
|
||||
assert_equal( a.to_s, "()" )
|
||||
assert_equal( RBA::Polygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Polygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.is_box?, false )
|
||||
|
||||
b = a.dup
|
||||
|
|
@ -179,6 +183,7 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal( a.to_s, "(0,1;1,5;5,5)" )
|
||||
assert_equal( (a * 2).to_s, "(0,2;2,10;10,10)" )
|
||||
assert_equal( RBA::Polygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Polygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.num_points_hull, 3 )
|
||||
c = a.dup
|
||||
|
||||
|
|
@ -226,6 +231,7 @@ class DBPolygon_TestClass < TestBase
|
|||
a.insert_hole( [ RBA::Point::new( 1, 2 ), RBA::Point::new( 2, 2 ), RBA::Point::new( 2, 6 ) ] )
|
||||
assert_equal( a.to_s, "(0,1;1,5;1,1/1,2;2,2;2,6)" )
|
||||
assert_equal( RBA::Polygon::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Polygon::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.area, 0 )
|
||||
assert_equal( a.num_points_hole(0), 3 )
|
||||
assert_equal( a.holes, 1 )
|
||||
|
|
@ -900,16 +906,16 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::PolygonWithProperties::new(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 200)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::PolygonWithProperties::new(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 200)), pid)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -922,16 +928,16 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DPolygon::new(RBA::DBox::new(0, 0, 100, 200)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DPolygon::new(RBA::DBox::new(0, 0, 100, 200)), pid)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -944,16 +950,16 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::SimplePolygon::new(RBA::Box::new(0, 0, 100, 200)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::SimplePolygon::new(RBA::Box::new(0, 0, 100, 200)), pid)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -966,16 +972,16 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal(s.to_s, "() props={}")
|
||||
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DSimplePolygon::new(RBA::DBox::new(0, 0, 100, 200)), { 1 => "one" })
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DSimplePolygon::new(RBA::DBox::new(0, 0, 100, 200)), pid)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -984,6 +990,42 @@ class DBPolygon_TestClass < TestBase
|
|||
assert_equal(s.class.to_s, "RBA::DSimplePolygonWithProperties")
|
||||
assert_equal(s.downcast.class.to_s, "RBA::DSimplePolygon")
|
||||
|
||||
# binary serialization
|
||||
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::PolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::PolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DPolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DPolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::SimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::SimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DSimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DSimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
|
||||
|
||||
# string serialization
|
||||
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::PolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::PolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DPolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DPolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::SimplePolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::SimplePolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
|
||||
assert_equal(RBA::DSimplePolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
|
||||
assert_equal(RBA::DSimplePolygonWithProperties::from_s(s.to_s).to_s, s.to_s)
|
||||
|
||||
end
|
||||
|
||||
def test_triangulation
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class DBRegion_TestClass < TestBase
|
|||
r.insert(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 10, 20), { 1 => 'value' }))
|
||||
r.insert(RBA::Box::new(1, 2, 11, 22))
|
||||
assert_equal(r[0].to_s, "(1,2;1,22;11,22;11,2) props={}")
|
||||
assert_equal(r[1].to_s, "(0,0;0,20;10,20;10,0) props={1=>value}")
|
||||
assert_equal(r[1].to_s, "(0,0;0,20;10,20;10,0) props={#1=>'value'}")
|
||||
|
||||
r = RBA::Region::new(ly.begin_shapes(c1.cell_index, l2), "*")
|
||||
assert_equal(csort(r.to_s), csort("(-11,-21;-11,-19;-9,-19;-9,-21);(9,19;9,21;11,21;11,19);(-11,79;-11,81;-9,81;-9,79);(9,119;9,121;11,121;11,119);(189,79;189,81;191,81;191,79);(209,119;209,121;211,121;211,119)"))
|
||||
|
|
@ -1635,20 +1635,20 @@ class DBRegion_TestClass < TestBase
|
|||
r.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
|
||||
r.insert(RBA::Box::new(10, 20, 110, 220))
|
||||
s = r.each.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(10,20;10,220;110,220;110,20) props={};(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s, "(10,20;10,220;110,220;110,20) props={};(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
rr = r.dup
|
||||
rr.join_properties_on_merge = true
|
||||
assert_equal(rr.join_properties_on_merge, true)
|
||||
s = rr.each_merged.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(0,0;0,200;10,200;10,220;110,220;110,20;100,20;100,0) props={1=>one}")
|
||||
assert_equal(s, "(0,0;0,200;10,200;10,220;110,220;110,20;100,20;100,0) props={#1=>'one'}")
|
||||
s = r.each_merged.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(10,20;10,220;110,220;110,20) props={};(0,0;0,200;100,200;100,0) props={1=>one}")
|
||||
assert_equal(s, "(10,20;10,220;110,220;110,20) props={};(0,0;0,200;100,200;100,0) props={#1=>'one'}")
|
||||
|
||||
r = RBA::Region::new
|
||||
r.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
|
||||
r.insert(RBA::BoxWithProperties::new(RBA::Box::new(10, 20, 110, 220), { 1 => "one" }))
|
||||
s = r.each_merged.collect(&:to_s).join(";")
|
||||
assert_equal(s, "(0,0;0,200;10,200;10,220;110,220;110,20;100,20;100,0) props={1=>one}")
|
||||
assert_equal(s, "(0,0;0,200;10,200;10,220;110,220;110,20;100,20;100,0) props={#1=>'one'}")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,12 @@ class DBText_TestClass < TestBase
|
|||
|
||||
a = RBA::DText::new( "hallo", 10.0, -15.0 )
|
||||
assert_equal( RBA::DText::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DText::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.to_s, "('hallo',r0 10,-15)" )
|
||||
|
||||
a = RBA::DText::new( RBA::Text::new( "itext", RBA::Trans::new( RBA::Trans::R270, RBA::Point::new( 100, -150 ))))
|
||||
assert_equal( RBA::DText::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DText::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.to_s, "('itext',r270 100,-150)" )
|
||||
|
||||
a = RBA::DText::new
|
||||
|
|
@ -124,6 +126,7 @@ class DBText_TestClass < TestBase
|
|||
|
||||
a = RBA::Text::new( "hallo", 10, -15 )
|
||||
assert_equal( RBA::Text::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Text::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( a.to_s, "('hallo',r0 10,-15)" )
|
||||
|
||||
a = RBA::Text::new( RBA::DText::new( "dtext", RBA::DTrans::new( RBA::DTrans::R270, RBA::DPoint::new( 100.0, -150.0 ))))
|
||||
|
|
@ -136,6 +139,7 @@ class DBText_TestClass < TestBase
|
|||
a = RBA::Text::new( "hallo", RBA::Trans::new( RBA::Trans::R90, RBA::Point::new( 10, -15 )))
|
||||
assert_equal( a.to_s, "('hallo',r90 10,-15)" )
|
||||
assert_equal( RBA::Text::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Text::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
c = a.dup
|
||||
|
||||
assert_equal( a == b, false )
|
||||
|
|
@ -260,16 +264,16 @@ class DBText_TestClass < TestBase
|
|||
assert_equal(s.to_s, "('',r0 0,0) props={}")
|
||||
|
||||
s = RBA::TextWithProperties::new(RBA::Text::new("text", RBA::Trans::R90), { 1 => "one" })
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::TextWithProperties::new(RBA::Text::new("text", RBA::Trans::R90), pid)
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
@ -278,16 +282,16 @@ class DBText_TestClass < TestBase
|
|||
assert_equal(s.to_s, "('',r0 0,0) props={}")
|
||||
|
||||
s = RBA::DTextWithProperties::new(RBA::DText::new("text", RBA::Trans::R90), { 1 => "one" })
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
|
||||
pid = RBA::Layout::properties_id({ 1 => "one" })
|
||||
s = RBA::DTextWithProperties::new(RBA::DText::new("text", RBA::Trans::R90), pid)
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "('text',r90 0,0) props={1=>one}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "('text',r90 0,0) props={#1=>'one'}")
|
||||
assert_equal(s.property(1), "one")
|
||||
assert_equal(s.properties, { 1 => "one" })
|
||||
s.set_property(1, "xxx")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={1=>xxx}")
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={#1=>'xxx'}")
|
||||
s.delete_property(1)
|
||||
assert_equal(s.to_s, "('text',r90 0,0) props={}")
|
||||
assert_equal(s.property(1), nil)
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class DBTexts_TestClass < TestBase
|
|||
|
||||
r = RBA::Texts::new
|
||||
r.insert(RBA::TextWithProperties::new(RBA::Text::new("string", RBA::Trans::new), { 1 => "value" }))
|
||||
assert_equal(r[0].to_s, "('string',r0 0,0) props={1=>value}")
|
||||
assert_equal(r[0].to_s, "('string',r0 0,0) props={#1=>'value'}")
|
||||
|
||||
dss = RBA::DeepShapeStore::new
|
||||
r = RBA::Texts::new(ly.begin_shapes(c1.cell_index, l1), dss)
|
||||
|
|
@ -477,7 +477,7 @@ class DBTexts_TestClass < TestBase
|
|||
r.insert(RBA::TextWithProperties::new(RBA::Text::new("abc", RBA::Trans::new), { 1 => "one" }))
|
||||
r.insert(RBA::Text::new("xuv", RBA::Trans::new))
|
||||
s = r.each.collect(&:to_s).join(";")
|
||||
assert_equal(s, "('xuv',r0 0,0) props={};('abc',r0 0,0) props={1=>one}")
|
||||
assert_equal(s, "('xuv',r0 0,0) props={};('abc',r0 0,0) props={#1=>'one'}")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class DBTrans_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "r0 0,0" )
|
||||
assert_equal( RBA::DTrans::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DTrans::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( b.to_s, "m135 17,5" )
|
||||
assert_equal( c.to_s, "m135 17,5" )
|
||||
assert_equal( d.to_s, "r0 17,5" )
|
||||
|
|
@ -47,6 +48,7 @@ class DBTrans_TestClass < TestBase
|
|||
assert_equal( RBA::DTrans::new( RBA::Trans::M135, RBA::DPoint::new( 1.2, 0.25 )).to_itype(0.001).to_s, "m135 1200,250" )
|
||||
assert_equal( RBA::Trans::new( RBA::Trans::M135, RBA::Point::new( 1200, 250 )).to_dtype(0.001).to_s, "m135 1.2,0.25" )
|
||||
assert_equal( RBA::DTrans::from_s(f.to_s).to_s, f.to_s )
|
||||
assert_equal( RBA::DTrans::from_bytes(f.to_bytes).to_s, f.to_s )
|
||||
|
||||
assert_equal( b.trans( RBA::DPoint::new( 1, 0 )).to_s, "17,4" )
|
||||
|
||||
|
|
@ -139,6 +141,7 @@ class DBTrans_TestClass < TestBase
|
|||
|
||||
assert_equal( i.to_s, "m135 *0.5 2.5,8.5" )
|
||||
assert_equal( RBA::DCplxTrans::from_s(i.to_s).to_s, i.to_s )
|
||||
assert_equal( RBA::DCplxTrans::from_bytes(i.to_bytes).to_s, i.to_s )
|
||||
assert_equal( i * mb == u, true )
|
||||
assert_equal( mb * i == u, true )
|
||||
|
||||
|
|
@ -244,6 +247,7 @@ class DBTrans_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "r0 0,0" )
|
||||
assert_equal( RBA::Trans::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Trans::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( b.to_s, "m135 17,5" )
|
||||
assert_equal( c.to_s, "m135 17,5" )
|
||||
assert_equal( d.to_s, "r0 17,5" )
|
||||
|
|
@ -251,6 +255,7 @@ class DBTrans_TestClass < TestBase
|
|||
assert_equal( e2.to_s, "m135 0,0" )
|
||||
assert_equal( f.to_s, "m135 17,5" )
|
||||
assert_equal( RBA::Trans::from_s(f.to_s).to_s, f.to_s )
|
||||
assert_equal( RBA::Trans::from_bytes(f.to_bytes).to_s, f.to_s )
|
||||
|
||||
assert_equal( b.trans( RBA::Point::new( 1, 0 )).to_s, "17,4" )
|
||||
|
||||
|
|
@ -340,6 +345,7 @@ class DBTrans_TestClass < TestBase
|
|||
c = RBA::CplxTrans::new( 5, -7 )
|
||||
assert_equal( c.to_s, "r0 *1 5,-7" )
|
||||
assert_equal( RBA::CplxTrans::from_s(c.to_s).to_s, c.to_s )
|
||||
assert_equal( RBA::CplxTrans::from_bytes(c.to_bytes).to_s, c.to_s )
|
||||
|
||||
c = RBA::CplxTrans::new( RBA::CplxTrans::M135 )
|
||||
assert_equal( c.to_s, "m135 *1 0,0" )
|
||||
|
|
@ -367,6 +373,7 @@ class DBTrans_TestClass < TestBase
|
|||
c = RBA::CplxTrans::new( 0.75, 45, true, 2.5, -12.5 )
|
||||
assert_equal( c.to_s, "m22.5 *0.75 2.5,-12.5" )
|
||||
assert_equal( RBA::CplxTrans::from_s(c.to_s).to_s, c.to_s )
|
||||
assert_equal( RBA::CplxTrans::from_bytes(c.to_bytes).to_s, c.to_s )
|
||||
c = RBA::CplxTrans::new( 0.75, 45, true, RBA::DPoint::new( 2.5, -12.5 ) )
|
||||
assert_equal( c.to_s, "m22.5 *0.75 2.5,-12.5" )
|
||||
assert_equal( c.is_unity?, false )
|
||||
|
|
@ -436,6 +443,7 @@ class DBTrans_TestClass < TestBase
|
|||
|
||||
assert_equal( m.to_s, "r0 *1.1 0,0" )
|
||||
assert_equal( RBA::DCplxTrans::from_s(m.to_s).to_s, m.to_s )
|
||||
assert_equal( RBA::DCplxTrans::from_bytes(m.to_bytes).to_s, m.to_s )
|
||||
assert_equal( m.trans( RBA::Point::new( 5, -7 )).to_s, "5.5,-7.7" )
|
||||
|
||||
im = RBA::ICplxTrans::new( a, 0.5 )
|
||||
|
|
@ -443,6 +451,7 @@ class DBTrans_TestClass < TestBase
|
|||
|
||||
assert_equal( im.to_s, "r0 *0.5 0,0" )
|
||||
assert_equal( RBA::ICplxTrans::from_s(im.to_s).to_s, im.to_s )
|
||||
assert_equal( RBA::ICplxTrans::from_bytes(im.to_bytes).to_s, im.to_s )
|
||||
assert_equal( im.trans( RBA::Point::new( 5, -7 )).to_s, "3,-4" )
|
||||
|
||||
im = RBA::ICplxTrans::new(m)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class DBVector_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "1,-17" )
|
||||
assert_equal( RBA::DVector::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::DVector::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (-a).to_s, "-1,17" )
|
||||
assert_equal( b.to_s, "0,0" )
|
||||
assert_equal( c.to_s, "5,11" )
|
||||
|
|
@ -88,6 +89,7 @@ class DBVector_TestClass < TestBase
|
|||
|
||||
assert_equal( a.to_s, "1,-17" )
|
||||
assert_equal( RBA::Vector::from_s(a.to_s).to_s, a.to_s )
|
||||
assert_equal( RBA::Vector::from_bytes(a.to_bytes).to_s, a.to_s )
|
||||
assert_equal( (-a).to_s, "-1,17" )
|
||||
assert_equal( b.to_s, "0,0" )
|
||||
assert_equal( c.to_s, "5,11" )
|
||||
|
|
|
|||
Loading…
Reference in New Issue