33#include <wx/translation.h>
38 constexpr double int_limit = ( std::numeric_limits<int>::max() - 10 ) / 2.54;
40 int32_t iu =
KiROUND( std::clamp( aValue, -int_limit, int_limit ) * 2.54 );
45 return KiROUND( (
double) iu / 10.0 ) * 10;
52 const std::map<wxString, wxString>::const_iterator& value = aProps.find( aKey );
53 return value == aProps.end() ? aDefault : wxAtoi( value->second );
60 const std::map<wxString, wxString>::const_iterator& value = aProps.find( aKey );
62 if( value == aProps.end() )
66 std::istringstream istr( (
const char*) value->second.mb_str() );
67 istr.imbue( std::locale::classic() );
78 const std::map<wxString, wxString>::const_iterator& value = aProps.find( aKey );
80 if( value == aProps.end() )
83 return value->second ==
"T" || value->second ==
"TRUE";
88 const wxString& aKey,
const wxString& aDefault )
90 const wxString& value =
ReadString( aProps, aKey, aDefault );
94 if( !value.EndsWith(
"mil", &prefix ) )
96 wxLogTrace(
"ALTIUM", wxT(
"Unit '%s' does not end with 'mil'." ), value );
100 prefix.StartsWith(
"+", &prefix );
104 if( !prefix.ToCDouble( &mils ) )
106 wxLogTrace(
"ALTIUM", wxT(
"Cannot convert '%s' to double." ), prefix );
115 const wxString& aKey,
const wxString& aDefault )
117 const auto& utf8Value = aProps.find( wxString(
"%UTF8%" ) + aKey );
119 if( utf8Value != aProps.end() )
120 return utf8Value->second;
122 const auto& value = aProps.find( aKey );
124 if( value != aProps.end() )
125 return value->second;
132 const wxString& aKey,
const wxString& aDefault )
134 const auto& unicodeFlag = aProps.find( wxS(
"UNICODE" ) );
136 if( unicodeFlag != aProps.end() && unicodeFlag->second.Contains( wxS(
"EXISTS" ) ) )
138 const auto& unicodeValue = aProps.find( wxString(
"UNICODE__" ) + aKey );
140 if( unicodeValue != aProps.end() )
142 wxArrayString arr = wxSplit( unicodeValue->second,
',',
'\0' );
145 for( wxString part : arr )
146 out += wxString(
wchar_t( wxAtoi( part ) ) );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
static int32_t ReadKicadUnit(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
static wxString ReadUnicodeString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static double ReadDouble(const std::map< wxString, wxString > &aProps, const wxString &aKey, double aDefault)
static int32_t ConvertToKicadUnit(const double aValue)