KiCad PCB EDA Suite
Loading...
Searching...
No Matches
idf_helpers.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2017 Cirilo Bernardo
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef IDF_HELPERS_H
22#define IDF_HELPERS_H
23
24#include <wx/string.h>
25#include <iostream>
26#include <string>
27#include <io/idf/idf_common.h>
28
29#define ERROR_IDF std::cerr << "* " << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << "(): "
30
31// minimum drill diameters / slot widths to be represented in the IDF output
32#define IDF_MIN_DIA_MM ( 0.001 )
33#define IDF_MIN_DIA_THOU ( 0.00039 )
34#define IDF_MIN_DIA_TNM ( 100 )
35
36// conversion from thou to mm
37#define IDF_THOU_TO_MM 0.0254
38// conversion from TNM to mm
39#define IDF_TNM_TO_MM 0.00001
40
41namespace IDF3
42{
43
57bool FetchIDFLine( std::istream& aModel, std::string& aLine, bool& isComment,
58 std::streampos& aFilePos );
59
60
71bool GetIDFString( const std::string& aLine, std::string& aIDFString, bool& hasQuotes,
72 int& aIndex );
73
81bool CompareToken( const char* aTokenString, const std::string& aInputString );
82
83
91bool ParseOwner( const std::string& aToken, IDF3::KEY_OWNER& aOwner );
92
93
101bool ParseIDFLayer( const std::string& aToken, IDF3::IDF_LAYER& aLayer );
102
103
111bool WriteLayersText( std::ostream& aBoardFile, IDF3::IDF_LAYER aLayer );
112
113
120std::string GetPlacementString( IDF3::IDF_PLACEMENT aPlacement );
121
122
129std::string GetLayerString( IDF3::IDF_LAYER aLayer );
130
131std::string GetOwnerString( IDF3::KEY_OWNER aOwner );
132}
133
134#endif // IDF_HELPERS_H
std::string GetPlacementString(IDF3::IDF_PLACEMENT aPlacement)
Return a string representing the given IDF Placement type.
bool ParseIDFLayer(const std::string &aToken, IDF3::IDF_LAYER &aLayer)
Parse an input string for a valid IDF layer specification.
IDF_PLACEMENT
The placement status of a component.
Definition idf_common.h:188
bool GetIDFString(const std::string &aLine, std::string &aIDFString, bool &hasQuotes, int &aIndex)
Parse a line retrieved via FetchIDFLine() and returns the first IDF string found from the starting po...
std::string GetOwnerString(IDF3::KEY_OWNER aOwner)
bool FetchIDFLine(std::istream &aModel, std::string &aLine, bool &isComment, std::streampos &aFilePos)
Retrieve a single line from an IDF file and performs minimal processing.
bool CompareToken(const char *aTokenString, const std::string &aInputString)
Perform a case-insensitive comparison of a token string and an input string.
IDF_LAYER
The various IDF layer classes and groupings.
Definition idf_common.h:137
KEY_OWNER
The type of CAD which has ownership an object.
Definition idf_common.h:85
bool WriteLayersText(std::ostream &aBoardFile, IDF3::IDF_LAYER aLayer)
Write out text corresponding to the given IDF Layer type.
bool ParseOwner(const std::string &aToken, IDF3::KEY_OWNER &aOwner)
Parse the input string for a valid IDF Owner type.
std::string GetLayerString(IDF3::IDF_LAYER aLayer)
Return a string representing the given IDF Layer type.