![]() |
KiCad PCB EDA Suite
|
< Helper class to handle Spice way of expressing values (e.g. 10.5 Meg) Helper class to recognize Spice formatted values More...
#include <spice_value.h>
Public Types | |
enum | UNIT_PREFIX { PFX_FEMTO = -15, PFX_PICO = -12, PFX_NANO = -9, PFX_MICRO = -6, PFX_MILI = -3, PFX_NONE = 0, PFX_KILO = 3, PFX_MEGA = 6, PFX_GIGA = 9, PFX_TERA = 12 } |
Public Member Functions | |
SPICE_VALUE () | |
Parses the string to create a Spice value (e.g. 100n) More... | |
SPICE_VALUE (const wxString &aString) | |
SPICE_VALUE (int aInt, UNIT_PREFIX aPrefix=PFX_NONE) | |
SPICE_VALUE (double aDouble, UNIT_PREFIX aPrefix=PFX_NONE) | |
void | Normalize () |
Normalize the value. More... | |
double | ToDouble () const |
wxString | ToString () const |
Return string value as when converting double to string (e.g. More... | |
wxString | ToSpiceString () const |
Return string value in Spice format (e.g. More... | |
wxString | ToOrigString () const |
Return either a normal string or Spice format string, depending on the original value format. More... | |
bool | IsSpiceString () const |
Return true if the object was initiated with a Spice formatted string value. More... | |
bool | operator== (const SPICE_VALUE &aOther) const |
bool | operator> (const SPICE_VALUE &aOther) const |
bool | operator< (const SPICE_VALUE &aOther) const |
bool | operator>= (const SPICE_VALUE &aOther) const |
bool | operator<= (const SPICE_VALUE &aOther) const |
SPICE_VALUE | operator- (const SPICE_VALUE &aOther) const |
SPICE_VALUE | operator+ (const SPICE_VALUE &aOther) const |
SPICE_VALUE | operator * (const SPICE_VALUE &aOther) const |
SPICE_VALUE | operator/ (const SPICE_VALUE &aOther) const |
Static Private Member Functions | |
static void | stripZeros (wxString &aString) |
< Remove redundant zeros from the end of a string. More... | |
Private Attributes | |
double | m_base |
UNIT_PREFIX | m_prefix |
Was the value defined using the Spice notation? More... | |
bool | m_spiceStr |
< Helper class to handle Spice way of expressing values (e.g. 10.5 Meg) Helper class to recognize Spice formatted values
Definition at line 34 of file spice_value.h.
Enumerator | |
---|---|
PFX_FEMTO | |
PFX_PICO | |
PFX_NANO | |
PFX_MICRO | |
PFX_MILI | |
PFX_NONE | |
PFX_KILO | |
PFX_MEGA | |
PFX_GIGA | |
PFX_TERA |
Definition at line 37 of file spice_value.h.
|
inline |
Parses the string to create a Spice value (e.g. 100n)
Definition at line 51 of file spice_value.h.
SPICE_VALUE::SPICE_VALUE | ( | const wxString & | aString | ) |
Definition at line 37 of file spice_value.cpp.
References _, dummy(), m_base, m_prefix, m_spiceStr, Normalize(), PFX_FEMTO, PFX_GIGA, PFX_KILO, PFX_MEGA, PFX_MICRO, PFX_MILI, PFX_NANO, PFX_NONE, PFX_PICO, and PFX_TERA.
|
inline |
Definition at line 59 of file spice_value.h.
References Normalize().
|
inline |
Definition at line 65 of file spice_value.h.
References Normalize().
|
inline |
Return true if the object was initiated with a Spice formatted string value.
Definition at line 100 of file spice_value.h.
References m_spiceStr.
Referenced by TUNER_SLIDER::updateValueText().
void SPICE_VALUE::Normalize | ( | ) |
Normalize the value.
The unit prefix is picked so the base is (0.001 <= base < 1000).
Definition at line 88 of file spice_value.cpp.
References m_base, m_prefix, PFX_FEMTO, and PFX_TERA.
Referenced by operator *(), operator+(), operator-(), operator/(), and SPICE_VALUE().
SPICE_VALUE SPICE_VALUE::operator * | ( | const SPICE_VALUE & | aOther | ) | const |
Definition at line 214 of file spice_value.cpp.
References m_base, m_prefix, m_spiceStr, and Normalize().
SPICE_VALUE SPICE_VALUE::operator+ | ( | const SPICE_VALUE & | aOther | ) | const |
Definition at line 152 of file spice_value.cpp.
References m_base, m_prefix, m_spiceStr, and Normalize().
SPICE_VALUE SPICE_VALUE::operator- | ( | const SPICE_VALUE & | aOther | ) | const |
Definition at line 183 of file spice_value.cpp.
References m_base, m_prefix, m_spiceStr, and Normalize().
SPICE_VALUE SPICE_VALUE::operator/ | ( | const SPICE_VALUE & | aOther | ) | const |
Definition at line 224 of file spice_value.cpp.
References m_base, m_prefix, m_spiceStr, and Normalize().
|
inline |
|
inline |
Definition at line 125 of file spice_value.h.
|
inline |
Definition at line 105 of file spice_value.h.
|
inline |
|
inline |
Definition at line 120 of file spice_value.h.
|
staticprivate |
< Remove redundant zeros from the end of a string.
Definition at line 234 of file spice_value.cpp.
Referenced by ToSpiceString(), and ToString().
double SPICE_VALUE::ToDouble | ( | ) | const |
Definition at line 110 of file spice_value.cpp.
References m_base, m_prefix, and PFX_NONE.
Referenced by operator<(), operator>(), DIALOG_SIM_SETTINGS::parseCommand(), and ToString().
|
inline |
Return either a normal string or Spice format string, depending on the original value format.
Definition at line 92 of file spice_value.h.
References m_spiceStr, ToSpiceString(), and ToString().
Referenced by TUNER_SLIDER::onSave(), TUNER_SLIDER::SetMax(), TUNER_SLIDER::SetMin(), TUNER_SLIDER::TUNER_SLIDER(), TUNER_SLIDER::updateMax(), TUNER_SLIDER::updateMin(), and TUNER_SLIDER::updateValue().
wxString SPICE_VALUE::ToSpiceString | ( | ) | const |
Return string value in Spice format (e.g.
123.3456789k).
Definition at line 129 of file spice_value.cpp.
References m_base, m_prefix, PFX_FEMTO, PFX_GIGA, PFX_KILO, PFX_MEGA, PFX_MICRO, PFX_MILI, PFX_NANO, PFX_NONE, PFX_PICO, PFX_TERA, and stripZeros().
Referenced by SIM_PLOT_FRAME::onCursorUpdate(), DIALOG_SIM_SETTINGS::parseCommand(), DIALOG_SPICE_MODEL::parsePowerSource(), ToOrigString(), and TUNER_SLIDER::updateValueText().
wxString SPICE_VALUE::ToString | ( | ) | const |
Return string value as when converting double to string (e.g.
123456.789).
Definition at line 120 of file spice_value.cpp.
References Format(), stripZeros(), and ToDouble().
Referenced by ToOrigString(), SIM_PLOT_FRAME::updatePlot(), and TUNER_SLIDER::updateValueText().
|
private |
Definition at line 139 of file spice_value.h.
Referenced by Normalize(), operator *(), operator+(), operator-(), operator/(), operator==(), SPICE_VALUE(), ToDouble(), and ToSpiceString().
|
private |
Was the value defined using the Spice notation?
Definition at line 140 of file spice_value.h.
Referenced by Normalize(), operator *(), operator+(), operator-(), operator/(), operator==(), SPICE_VALUE(), ToDouble(), and ToSpiceString().
|
private |
Definition at line 143 of file spice_value.h.
Referenced by IsSpiceString(), operator *(), operator+(), operator-(), operator/(), SPICE_VALUE(), and ToOrigString().