KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_DIFF::DIFF_VALUE Class Reference

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 StorageGetStorage () 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 PolygonSetAsPolygonSet () 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).
 

Detailed Description

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.

Member Typedef Documentation

◆ EnumValue

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.

◆ PolygonSet

using KICAD_DIFF::DIFF_VALUE::PolygonSet = std::vector<std::vector<std::vector<VECTOR2I>>>

Definition at line 182 of file kicad_diff_types.h.

◆ Storage

Initial value:
std::variant<std::monostate, bool, int, int64_t, double, std::string, KIID, VECTOR2I, BOX2I,
std::pair< int, std::string > EnumValue
Enum payload: (numeric_value, label) so JSON output is human-readable while the integer is the canoni...
std::vector< std::vector< std::vector< VECTOR2I > > > PolygonSet
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56

Definition at line 184 of file kicad_diff_types.h.

Member Enumeration Documentation

◆ T

enum class KICAD_DIFF::DIFF_VALUE::T
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.

Constructor & Destructor Documentation

◆ DIFF_VALUE()

Member Function Documentation

◆ AsBool()

bool KICAD_DIFF::DIFF_VALUE::AsBool ( ) const

◆ AsBox2I()

BOX2I KICAD_DIFF::DIFF_VALUE::AsBox2I ( ) const

◆ AsColor()

KIGFX::COLOR4D KICAD_DIFF::DIFF_VALUE::AsColor ( ) const

◆ AsDouble()

◆ AsEnum()

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().

◆ AsInt()

int KICAD_DIFF::DIFF_VALUE::AsInt ( ) const

◆ AsInt64()

int64_t KICAD_DIFF::DIFF_VALUE::AsInt64 ( ) const

◆ AsKiid()

KIID KICAD_DIFF::DIFF_VALUE::AsKiid ( ) const

◆ AsLayer()

PCB_LAYER_ID KICAD_DIFF::DIFF_VALUE::AsLayer ( ) const

◆ AsPolygonSet()

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().

◆ AsString()

wxString KICAD_DIFF::DIFF_VALUE::AsString ( ) const

◆ AsVector2I()

VECTOR2I KICAD_DIFF::DIFF_VALUE::AsVector2I ( ) const

◆ FromBool()

◆ FromBox2I()

DIFF_VALUE KICAD_DIFF::DIFF_VALUE::FromBox2I ( const BOX2I & aValue)
static

◆ FromColor()

◆ FromDouble()

◆ FromEnum()

DIFF_VALUE KICAD_DIFF::DIFF_VALUE::FromEnum ( int aValue,
const std::string & aLabel )
static

◆ FromInt()

◆ FromInt64()

◆ FromJson()

◆ FromKiid()

DIFF_VALUE KICAD_DIFF::DIFF_VALUE::FromKiid ( const KIID & aValue)
static

◆ FromLayer()

◆ FromPolygonSet()

◆ FromString() [1/2]

DIFF_VALUE KICAD_DIFF::DIFF_VALUE::FromString ( const std::string & aValue)
static

Definition at line 154 of file kicad_diff_types.cpp.

References DIFF_VALUE(), FromString(), m_type, m_value, and STRING.

◆ FromString() [2/2]

◆ FromVector2I()

◆ GetDisplayHint()

DISPLAY_HINT KICAD_DIFF::DIFF_VALUE::GetDisplayHint ( ) const
inline

Definition at line 228 of file kicad_diff_types.h.

References m_displayHint.

◆ GetStorage()

const Storage & KICAD_DIFF::DIFF_VALUE::GetStorage ( ) const
inline

Definition at line 204 of file kicad_diff_types.h.

References m_value.

◆ GetType()

◆ operator!=()

bool KICAD_DIFF::DIFF_VALUE::operator!= ( const DIFF_VALUE & aOther) const
inline

Definition at line 242 of file kicad_diff_types.h.

References DIFF_VALUE().

◆ operator==()

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==().

◆ ToDisplayString() [1/2]

wxString KICAD_DIFF::DIFF_VALUE::ToDisplayString ( ) const

◆ ToDisplayString() [2/2]

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.

◆ ToJson()

◆ WithDisplayHint()

DIFF_VALUE KICAD_DIFF::DIFF_VALUE::WithDisplayHint ( DISPLAY_HINT aHint) const
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().

Member Data Documentation

◆ m_displayHint

DISPLAY_HINT KICAD_DIFF::DIFF_VALUE::m_displayHint = DISPLAY_HINT::NONE
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().

◆ m_type

◆ m_value


The documentation for this class was generated from the following files: