|
KiCad PCB EDA Suite
|
A typed sum value used to carry the before/after of any single property. More...
#include <kicad_diff_types.h>
Public Types | |
| enum class | T { NONE , BOOL , INT , INT64 , DOUBLE , STRING , KIID , VECTOR2I , BOX2I , COLOR , LAYER , ENUM , POLYGON_SET } |
| using | EnumValue = std::pair<int, std::string> |
| Enum payload: (numeric_value, label) so JSON output is human-readable while the integer is the canonical comparison key. | |
| using | PolygonSet = std::vector<std::vector<std::vector<VECTOR2I>>> |
| using | Storage |
Public Member Functions | |
| DIFF_VALUE () | |
| T | GetType () const |
| const Storage & | GetStorage () const |
| bool | AsBool () const |
| int | AsInt () const |
| int64_t | AsInt64 () const |
| double | AsDouble () const |
| wxString | AsString () const |
| KIID | AsKiid () const |
| VECTOR2I | AsVector2I () const |
| BOX2I | AsBox2I () const |
| KIGFX::COLOR4D | AsColor () const |
| PCB_LAYER_ID | AsLayer () const |
| EnumValue | AsEnum () const |
| const PolygonSet & | AsPolygonSet () const |
| DIFF_VALUE | WithDisplayHint (DISPLAY_HINT aHint) const |
Tag this value with a display hint and return a copy, so call sites can chain DIFF_VALUE::FromInt( w ).WithDisplayHint( DISPLAY_HINT::DISTANCE ). | |
| DISPLAY_HINT | GetDisplayHint () const |
| wxString | ToDisplayString () const |
| Human-readable representation with no unit context. | |
| wxString | ToDisplayString (EDA_UNITS aUnits, const EDA_IU_SCALE &aScale) const |
Human-readable representation in aUnits using aScale. | |
| bool | operator== (const DIFF_VALUE &aOther) const |
| bool | operator!= (const DIFF_VALUE &aOther) const |
| nlohmann::json | ToJson () const |
Static Public Member Functions | |
| static DIFF_VALUE | FromBool (bool aValue) |
| static DIFF_VALUE | FromInt (int aValue) |
| static DIFF_VALUE | FromInt64 (int64_t aValue) |
| static DIFF_VALUE | FromDouble (double aValue) |
| static DIFF_VALUE | FromString (const wxString &aValue) |
| static DIFF_VALUE | FromString (const std::string &aValue) |
| static DIFF_VALUE | FromKiid (const KIID &aValue) |
| static DIFF_VALUE | FromVector2I (const VECTOR2I &aValue) |
| static DIFF_VALUE | FromBox2I (const BOX2I &aValue) |
| static DIFF_VALUE | FromColor (const KIGFX::COLOR4D &aValue) |
| static DIFF_VALUE | FromLayer (PCB_LAYER_ID aLayer) |
| static DIFF_VALUE | FromEnum (int aValue, const std::string &aLabel) |
| static DIFF_VALUE | FromPolygonSet (PolygonSet aValue) |
| static DIFF_VALUE | FromJson (const nlohmann::json &aJson) |
Private Attributes | |
| T | m_type |
| Storage | m_value |
| DISPLAY_HINT | m_displayHint = DISPLAY_HINT::NONE |
| Presentation aid only; excluded from operator== and JSON (see DISPLAY_HINT). | |
A typed sum value used to carry the before/after of any single property.
Designed to round-trip through JSON deterministically so the engine output is bit-stable across runs and trivially comparable in tests. Avoids wxAny because wxAny does not serialise.
Definition at line 158 of file kicad_diff_types.h.
| using KICAD_DIFF::DIFF_VALUE::EnumValue = std::pair<int, std::string> |
Enum payload: (numeric_value, label) so JSON output is human-readable while the integer is the canonical comparison key.
Definition at line 180 of file kicad_diff_types.h.
| using KICAD_DIFF::DIFF_VALUE::PolygonSet = std::vector<std::vector<std::vector<VECTOR2I>>> |
Definition at line 182 of file kicad_diff_types.h.
Definition at line 184 of file kicad_diff_types.h.
|
strong |
| Enumerator | |
|---|---|
| NONE | |
| BOOL | |
| INT | |
| INT64 | |
| DOUBLE | |
| STRING | |
| KIID | |
| VECTOR2I | |
| BOX2I | |
| COLOR | |
| LAYER | |
| ENUM | |
| POLYGON_SET | |
Definition at line 161 of file kicad_diff_types.h.
|
inline |
Definition at line 187 of file kicad_diff_types.h.
References m_type, m_value, and NONE.
Referenced by FromBool(), FromBox2I(), FromColor(), FromDouble(), FromEnum(), FromInt(), FromInt64(), FromJson(), FromKiid(), FromLayer(), FromPolygonSet(), FromString(), FromString(), FromVector2I(), operator!=(), operator==(), and WithDisplayHint().
| bool KICAD_DIFF::DIFF_VALUE::AsBool | ( | ) | const |
Definition at line 226 of file kicad_diff_types.cpp.
References AsBool(), and m_value.
Referenced by AsBool(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| BOX2I KICAD_DIFF::DIFF_VALUE::AsBox2I | ( | ) | const |
Definition at line 268 of file kicad_diff_types.cpp.
References AsBox2I(), BOX2I, and m_value.
Referenced by AsBox2I(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| KIGFX::COLOR4D KICAD_DIFF::DIFF_VALUE::AsColor | ( | ) | const |
Definition at line 274 of file kicad_diff_types.cpp.
References AsColor(), and m_value.
Referenced by AsColor(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| double KICAD_DIFF::DIFF_VALUE::AsDouble | ( | ) | const |
Definition at line 244 of file kicad_diff_types.cpp.
References AsDouble(), and m_value.
Referenced by AsDouble(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), ToDisplayString(), and ToJson().
| DIFF_VALUE::EnumValue KICAD_DIFF::DIFF_VALUE::AsEnum | ( | ) | const |
Definition at line 286 of file kicad_diff_types.cpp.
References AsEnum(), and m_value.
Referenced by AsEnum(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| int KICAD_DIFF::DIFF_VALUE::AsInt | ( | ) | const |
Definition at line 232 of file kicad_diff_types.cpp.
References AsInt(), and m_value.
Referenced by AsInt(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), ToDisplayString(), and ToJson().
| int64_t KICAD_DIFF::DIFF_VALUE::AsInt64 | ( | ) | const |
Definition at line 238 of file kicad_diff_types.cpp.
References AsInt64(), and m_value.
Referenced by AsInt64(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), ToDisplayString(), and ToJson().
| KIID KICAD_DIFF::DIFF_VALUE::AsKiid | ( | ) | const |
Definition at line 256 of file kicad_diff_types.cpp.
References AsKiid(), KIID, and m_value.
Referenced by AsKiid(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| PCB_LAYER_ID KICAD_DIFF::DIFF_VALUE::AsLayer | ( | ) | const |
Definition at line 280 of file kicad_diff_types.cpp.
References AsLayer(), and m_value.
Referenced by AsLayer(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), and ToJson().
| const DIFF_VALUE::PolygonSet & KICAD_DIFF::DIFF_VALUE::AsPolygonSet | ( | ) | const |
Definition at line 292 of file kicad_diff_types.cpp.
References AsPolygonSet(), and m_value.
Referenced by AsPolygonSet(), BOOST_AUTO_TEST_CASE(), ToDisplayString(), and ToJson().
| wxString KICAD_DIFF::DIFF_VALUE::AsString | ( | ) | const |
Definition at line 250 of file kicad_diff_types.cpp.
References AsString(), and m_value.
Referenced by AsString(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), KICAD_DIFF::ItemProperties(), and ToDisplayString().
| VECTOR2I KICAD_DIFF::DIFF_VALUE::AsVector2I | ( | ) | const |
Definition at line 262 of file kicad_diff_types.cpp.
References AsVector2I(), m_value, and VECTOR2I.
Referenced by AsVector2I(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffValueToWxAny(), ToDisplayString(), ToDisplayString(), and ToJson().
|
static |
Definition at line 112 of file kicad_diff_types.cpp.
References BOOL, DIFF_VALUE(), FromBool(), m_type, and m_value.
Referenced by KICAD_DIFF::AppendPaperDeltas(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromBool(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 181 of file kicad_diff_types.cpp.
References BOX2I, DIFF_VALUE(), FromBox2I(), m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromBox2I(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 190 of file kicad_diff_types.cpp.
References COLOR, DIFF_VALUE(), FromColor(), m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromColor(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 139 of file kicad_diff_types.cpp.
References DIFF_VALUE(), DOUBLE, FromDouble(), m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromDouble(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 208 of file kicad_diff_types.cpp.
References DIFF_VALUE(), ENUM, FromEnum(), m_type, and m_value.
Referenced by KICAD_DIFF::AppendPaperDeltas(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromEnum(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 121 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromInt(), INT, m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::Diff(), FromInt(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 130 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromInt64(), INT64, m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromInt64(), FromJson(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 528 of file kicad_diff_types.cpp.
References BOOL, BOX2I, COLOR, DIFF_VALUE(), DOUBLE, ENUM, FromBool(), FromBox2I(), FromColor(), FromDouble(), FromEnum(), FromInt(), FromInt64(), FromJson(), FromKiid(), FromLayer(), FromPolygonSet(), FromString(), FromVector2I(), INT, INT64, KIID, LAYER, NONE, POLYGON_SET, STRING, and VECTOR2I.
Referenced by BOOST_AUTO_TEST_CASE(), FromJson(), KICAD_DIFF::PROPERTY_DELTA::FromJson(), KICAD_DIFF::PROPERTY_RESOLUTION::FromJson(), and roundTrip().
|
static |
Definition at line 163 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromKiid(), KIID, m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromJson(), FromKiid(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 199 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromLayer(), LAYER, m_type, and m_value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromJson(), FromLayer(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 217 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromPolygonSet(), m_type, m_value, and POLYGON_SET.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::diffProperties(), FromJson(), FromPolygonSet(), and RectPolygonSet().
|
static |
Definition at line 154 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromString(), m_type, m_value, and STRING.
|
static |
Definition at line 148 of file kicad_diff_types.cpp.
References DIFF_VALUE(), and FromString().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::Diff(), KICAD_DIFF::SCH_DIFFER::Diff(), FromJson(), FromString(), FromString(), and KICAD_DIFF::WxAnyToDiffValue().
|
static |
Definition at line 172 of file kicad_diff_types.cpp.
References DIFF_VALUE(), FromVector2I(), m_type, m_value, and VECTOR2I.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FromJson(), FromVector2I(), and KICAD_DIFF::WxAnyToDiffValue().
|
inline |
Definition at line 228 of file kicad_diff_types.h.
References m_displayHint.
|
inline |
Definition at line 204 of file kicad_diff_types.h.
References m_value.
|
inline |
Definition at line 203 of file kicad_diff_types.h.
References m_type.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::DiffItemProperties(), KICAD_DIFF::DiffValueToWxAny(), and KICAD_DIFF::ItemProperties().
|
inline |
Definition at line 242 of file kicad_diff_types.h.
References DIFF_VALUE().
| bool KICAD_DIFF::DIFF_VALUE::operator== | ( | const DIFF_VALUE & | aOther | ) | const |
Definition at line 424 of file kicad_diff_types.cpp.
References DIFF_VALUE(), m_type, m_value, and operator==().
Referenced by operator==().
| wxString KICAD_DIFF::DIFF_VALUE::ToDisplayString | ( | ) | const |
Human-readable representation with no unit context.
Distance/coord/angle hints fall back to raw internal units here; use the unit-aware overload for user-facing output.
Definition at line 298 of file kicad_diff_types.cpp.
References AsBool(), AsBox2I(), AsColor(), AsDouble(), AsEnum(), AsInt(), AsInt64(), AsKiid(), AsLayer(), AsPolygonSet(), AsString(), AsVector2I(), BOOL, BOX2I, COLOR, DOUBLE, ENUM, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), INT, INT64, KIID, LAYER, LayerName(), m_type, NONE, POLYGON_SET, STRING, ToDisplayString(), VECTOR2I, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::FormatDiffAsText(), ToDisplayString(), and ToDisplayString().
| wxString KICAD_DIFF::DIFF_VALUE::ToDisplayString | ( | EDA_UNITS | aUnits, |
| const EDA_IU_SCALE & | aScale ) const |
Human-readable representation in aUnits using aScale.
Distance and coordinate values carrying a DISTANCE/COORD hint are converted from internal units; ANGLE-hinted values are formatted in degrees. All other values render identically to the no-arg overload.
Definition at line 380 of file kicad_diff_types.cpp.
References KICAD_DIFF::ANGLE, AsDouble(), AsInt(), AsInt64(), AsVector2I(), DEGREES_T, DOUBLE, INT, INT64, m_displayHint, m_type, EDA_UNIT_UTILS::UI::MessageTextFromValue(), KICAD_DIFF::NONE, EDA_UNIT_UTILS::UI::StringFromValue(), ToDisplayString(), VECTOR2I, VECTOR2< T >::x, and VECTOR2< T >::y.
| nlohmann::json KICAD_DIFF::DIFF_VALUE::ToJson | ( | ) | const |
Definition at line 430 of file kicad_diff_types.cpp.
References KIGFX::COLOR4D::a, AsBool(), AsBox2I(), AsColor(), AsDouble(), AsEnum(), AsInt(), AsInt64(), AsKiid(), AsLayer(), AsPolygonSet(), AsVector2I(), KIGFX::COLOR4D::b, BOOL, BOX2I, COLOR, DOUBLE, ENUM, KIGFX::COLOR4D::g, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), INT, INT64, KIID, LAYER, m_type, m_value, NONE, POLYGON_SET, KIGFX::COLOR4D::r, STRING, ToJson(), VECTOR2I, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), roundTrip(), and ToJson().
|
inline |
Tag this value with a display hint and return a copy, so call sites can chain DIFF_VALUE::FromInt( w ).WithDisplayHint( DISPLAY_HINT::DISTANCE ).
Definition at line 221 of file kicad_diff_types.h.
References DIFF_VALUE(), and m_displayHint.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::WxAnyToDiffValue().
|
private |
Presentation aid only; excluded from operator== and JSON (see DISPLAY_HINT).
Not serialized, so a value reconstructed via FromJson carries DISPLAY_HINT::NONE and only freshly-converted values render with units.
Definition at line 254 of file kicad_diff_types.h.
Referenced by GetDisplayHint(), ToDisplayString(), and WithDisplayHint().
|
private |
Definition at line 248 of file kicad_diff_types.h.
Referenced by DIFF_VALUE(), FromBool(), FromBox2I(), FromColor(), FromDouble(), FromEnum(), FromInt(), FromInt64(), FromKiid(), FromLayer(), FromPolygonSet(), FromString(), FromVector2I(), GetType(), operator==(), ToDisplayString(), ToDisplayString(), and ToJson().
|
private |
Definition at line 249 of file kicad_diff_types.h.
Referenced by AsBool(), AsBox2I(), AsColor(), AsDouble(), AsEnum(), AsInt(), AsInt64(), AsKiid(), AsLayer(), AsPolygonSet(), AsString(), AsVector2I(), DIFF_VALUE(), FromBool(), FromBox2I(), FromColor(), FromDouble(), FromEnum(), FromInt(), FromInt64(), FromKiid(), FromLayer(), FromPolygonSet(), FromString(), FromVector2I(), GetStorage(), operator==(), and ToJson().