Added const T& to Eagle PCB import plugin methods
This commit is contained in:
parent
9cf934ef17
commit
99f65f4dbf
|
@ -43,14 +43,14 @@ using std::string;
|
|||
|
||||
|
||||
template<>
|
||||
string Convert<string>( wxString aValue )
|
||||
string Convert<string>( const wxString& aValue )
|
||||
{
|
||||
return aValue.ToStdString();
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
double Convert<double>( wxString aValue )
|
||||
double Convert<double>( const wxString& aValue )
|
||||
{
|
||||
double value;
|
||||
|
||||
|
@ -63,7 +63,7 @@ double Convert<double>( wxString aValue )
|
|||
|
||||
|
||||
template <>
|
||||
int Convert<int>( wxString aValue )
|
||||
int Convert<int>( const wxString& aValue )
|
||||
{
|
||||
if( aValue.IsEmpty() )
|
||||
throw XML_PARSER_ERROR( "Conversion to int failed. Original value is empty." );
|
||||
|
@ -73,7 +73,7 @@ int Convert<int>( wxString aValue )
|
|||
|
||||
|
||||
template <>
|
||||
bool Convert<bool>( wxString aValue )
|
||||
bool Convert<bool>( const wxString& aValue )
|
||||
{
|
||||
if( aValue != "yes" && aValue != "no" )
|
||||
throw XML_PARSER_ERROR( "Conversion to bool failed. Original value, '" +
|
||||
|
@ -83,10 +83,11 @@ bool Convert<bool>( wxString aValue )
|
|||
return aValue == "yes";
|
||||
}
|
||||
|
||||
|
||||
/// parse an Eagle XML "rot" field. Unfortunately the DTD seems not to explain
|
||||
/// this format very well. [S][M]R<degrees>. Examples: "R90", "MR180", "SR180"
|
||||
template<>
|
||||
EROT Convert<EROT>( wxString aRot )
|
||||
EROT Convert<EROT>( const wxString& aRot )
|
||||
{
|
||||
EROT value;
|
||||
|
||||
|
@ -630,15 +631,15 @@ unsigned long timeStamp( wxXmlNode* aTree )
|
|||
}
|
||||
|
||||
|
||||
wxPoint kicad_arc_center( wxPoint start, wxPoint end, double angle )
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle )
|
||||
{
|
||||
// Eagle give us start and end.
|
||||
// S_ARC wants start to give the center, and end to give the start.
|
||||
double dx = end.x - start.x, dy = end.y - start.y;
|
||||
wxPoint mid = (start + end) / 2;
|
||||
double dx = aEnd.x - aStart.x, dy = aEnd.y - aStart.y;
|
||||
wxPoint mid = ( aStart + aEnd ) / 2;
|
||||
|
||||
double dlen = sqrt( dx*dx + dy*dy );
|
||||
double dist = dlen / ( 2 * tan( DEG2RAD( angle ) / 2 ) );
|
||||
double dlen = sqrt( dx * dx + dy * dy );
|
||||
double dist = dlen / ( 2 * tan( DEG2RAD( aAngle ) / 2 ) );
|
||||
|
||||
wxPoint center(
|
||||
mid.x + dist * ( dy / dlen ),
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
* type T is unknown.
|
||||
*/
|
||||
template<typename T>
|
||||
T Convert( wxString aValue )
|
||||
T Convert( const wxString& aValue )
|
||||
{
|
||||
throw XML_PARSER_ERROR( "Conversion failed. Unknown type." );
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
* aData is empty, the attribute is understood as unavailable; otherwise, the
|
||||
* conversion to T is tried.
|
||||
*/
|
||||
OPTIONAL_XML_ATTRIBUTE( wxString aData )
|
||||
OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
|
||||
{
|
||||
m_isAvailable = !aData.IsEmpty();
|
||||
|
||||
|
@ -229,7 +229,7 @@ public:
|
|||
* @param aData is a wxString that should be converted to T. If the string is empty, the
|
||||
* attribute is set to unavailable.
|
||||
*/
|
||||
OPTIONAL_XML_ATTRIBUTE<T>& operator =( wxString aData )
|
||||
OPTIONAL_XML_ATTRIBUTE<T>& operator =( const wxString& aData )
|
||||
{
|
||||
m_isAvailable = !aData.IsEmpty();
|
||||
|
||||
|
@ -268,7 +268,7 @@ public:
|
|||
* tries to convert a string to the base type.
|
||||
* @param aString is the string that will be converted to the base type.
|
||||
*/
|
||||
void Set( wxString aString )
|
||||
void Set( const wxString& aString )
|
||||
{
|
||||
m_data = Convert<T>( aString );
|
||||
}
|
||||
|
@ -685,6 +685,6 @@ string makeKey( const string& aFirst, const string& aSecond );
|
|||
unsigned long timeStamp( wxXmlNode* aTree );
|
||||
|
||||
/// Convert an Eagle curve end to a KiCad center for S_ARC
|
||||
wxPoint kicad_arc_center( wxPoint start, wxPoint end, double angle );
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
||||
|
||||
#endif // _EAGLE_PARSER_H_
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue