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 !=
';' )
82 out.reserve( aStr.length() );
84 for(
size_t ii = 0; ii < aStr.Len(); ++ii )
86 wxUniChar ch = aStr[ii];
89 if( ch >= 33 && ch <= 126 && ch !=
';' )
91 out.append( 1,
static_cast<char>( ch.IsAscii() ? ch.GetValue() :
'_' ) );
108 std::string str = aStr.ToStdString();
110 out.reserve( str.size() );
116 else if( isdigit( c ) || c ==
'-' || c ==
'_' || c ==
'+' || c ==
'.' )
124 if( out.length() > 64 )
129 while( !out.IsEmpty() && ( out[0] ==
'.' || out[0] ==
'-' || out[0] ==
'+' ) )
134 while( !out.IsEmpty() && out.Last() ==
'.' )
145 aStr.Trim().Trim(
false );
146 wxRegEx spaces(
"\\s" );
147 spaces.Replace( &aStr,
"_" );
160 while( str.EndsWith( wxT(
"00" ) ) )
173 wxString str = wxString::FromCDouble( aVal, aDigits );
175 return str.ToStdString();
194 std::pair<wxString, wxString> xy =
231 const wxString& aSubDir )
233 wxFileName
path = wxFileName::DirName( aPareDir );
235 wxArrayString subDirs = wxFileName::DirName( aSubDir.Lower() ).GetDirs();
237 for(
size_t i = 0; i < subDirs.GetCount(); i++ )
238 path.AppendDir( subDirs[i] );
240 if( !
path.DirExists() )
242 if( !
path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
244 throw( std::runtime_error(
"Could not create directory" +
path.GetPath() ) );
261 if( aFileName.IsEmpty() ||
m_treeWriter.GetCurrentPath().IsEmpty() )
266 fn.SetFullName( aFileName );
268 wxString dirPath = fn.GetPath();
270 if( !wxDir::Exists( dirPath ) )
272 if( !wxDir::Make( dirPath ) )
273 throw( std::runtime_error(
"Could not create directory" + dirPath ) );
276 if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
283 std::ios_base::out | std::ios_base::trunc | std::ios_base::binary );
285 m_ostream.imbue( std::locale::classic() );
288 throw std::runtime_error(
"Failed to open file: " + fn.GetFullPath() );
300 throw std::runtime_error(
"close file failed" );
312 m_ostream << var <<
"=" << value << std::endl;
319 m_ostream << var <<
"=" << value << std::endl;
333 throw std::runtime_error(
"already in array" );
342 throw std::runtime_error(
"not in array" );
344 m_ostream <<
"}" << std::endl << std::endl;
362 const wxString& aUserParams ) :
376 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)
static double m_symbolScale
VECTOR2I GetPosition() const override
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
wxString GenLegalComponentName(const wxString &aStr)
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
VECTOR2< double > VECTOR2D