25#include <wx/chartype.h>
28#include "idf_helpers.h"
39 for(
size_t ii = 0; ii < aStr.Len(); ++ii )
42 wxUniChar ch = aStr[ii];
44 if( ch > 126 || !std::isgraph(
static_cast<unsigned char>( ch ) ) )
59 std::string str = aStr.ToStdString();
61 out.reserve( str.size() );
65 if( ( c >= 33 && c <= 126 ) && c !=
';' )
84 std::string str = aStr.ToStdString();
86 out.reserve( str.size() );
92 else if( isdigit( c ) || c ==
'-' || c ==
'_' || c ==
'+' || c ==
'.' )
100 if( out.length() > 64 )
105 while( !out.IsEmpty() && ( out[0] ==
'.' || out[0] ==
'-' || out[0] ==
'+' ) )
110 while( !out.IsEmpty() && out.Last() ==
'.' )
121 aStr.Trim().Trim(
false );
122 wxRegEx spaces(
"\\s" );
123 spaces.Replace( &aStr,
"_" );
136 while( str.EndsWith( wxT(
"00" ) ) )
149 wxString str = wxString::FromCDouble( aVal, aDigits );
151 return str.ToStdString();
170 std::pair<wxString, wxString> xy =
185 case SHAPE_T::RECTANGLE:
190 case SHAPE_T::CIRCLE:
193 case SHAPE_T::BEZIER:
194 case SHAPE_T::SEGMENT:
196 case SHAPE_T::UNDEFINED:
207 const wxString& aSubDir )
209 wxFileName
path = wxFileName::DirName( aPareDir );
211 wxArrayString subDirs = wxFileName::DirName( aSubDir.Lower() ).GetDirs();
213 for(
size_t i = 0; i < subDirs.GetCount(); i++ )
214 path.AppendDir( subDirs[i] );
216 if( !
path.DirExists() )
218 if( !
path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
220 throw( std::runtime_error(
"Could not create directory" +
path.GetPath() ) );
229 m_treeWriter( aTreeWriter )
242 fn.SetFullName( aFileName );
244 wxString dirPath = fn.GetPath();
246 if( !wxDir::Exists( dirPath ) )
248 if( !wxDir::Make( dirPath ) )
249 throw( std::runtime_error(
"Could not create directory" + dirPath ) );
252 if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
259 std::ios_base::out | std::ios_base::trunc | std::ios_base::binary );
261 m_ostream.imbue( std::locale::classic() );
264 throw std::runtime_error(
"Failed to open file: " + fn.GetFullPath() );
276 throw std::runtime_error(
"close file failed" );
288 m_ostream << var <<
"=" << value << std::endl;
295 m_ostream << var <<
"=" << value << std::endl;
309 throw std::runtime_error(
"already in array" );
318 throw std::runtime_error(
"not in array" );
320 m_ostream <<
"}" << std::endl << std::endl;
338 const wxString& aUserParams ) :
339 m_units( aUnits ), m_thickness( aThickness ), m_userParams( aUserParams )
352 for(
const auto& tool :
m_tools )
int GetRectangleWidth() const
int GetRectangleHeight() const
void CreateFile(const wxString &aFileName)
ODB_TREE_WRITER & m_treeWriter
ODB_FILE_WRITER(ODB_TREE_WRITER &aTreeWriter, const wxString &aFileName)
ARRAY_PROXY(ODB_TEXT_WRITER &aWriter, const std::string &aStr)
ODB_TEXT_WRITER & m_writer
void WriteEquationLine(const std::string &var, int value)
ARRAY_PROXY MakeArrayProxy(const std::string &aStr)
void BeginArray(const std::string &a)
void CreateEntityDirectory(const wxString &aPareDir, const wxString &aSubDir=wxEmptyString)
const wxString GetCurrentPath() const
static double m_symbolScale
VECTOR2I GetPosition() const override
wxString Data2String(double aVal)
void RemoveWhitespace(wxString &aStr)
wxString GenODBString(const wxString &aStr)
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
wxString GenLegalEntityName(const wxString &aStr)
wxString GenLegalNetName(const wxString &aStr)
wxString Double2String(double aVal)
wxString SymDouble2String(double aVal)
VECTOR2I GetShapePosition(const PCB_SHAPE &aShape)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
VECTOR2< int32_t > VECTOR2I