35 std::streampos& aFilePos )
38 aFilePos = aModel.tellg();
43 std::getline( aModel, aLine );
52 aLine.erase( aLine.begin() );
56 while( !aLine.empty() && isspace( *aLine.begin() ) )
57 aLine.erase( aLine.begin() );
59 while( !aLine.empty() && isspace( *aLine.rbegin() ) )
60 aLine.erase( --aLine.end() );
63 if( aLine.empty() && !isComment )
77 std::ostringstream ostr;
79 int len = aLine.length();
82 if( idx < 0 || idx >= len )
85 while( idx < len && isspace( aLine[idx] ) )
94 if( aLine[idx] ==
'"' )
99 while( idx < len && aLine[idx] !=
'"' )
100 ostr << aLine[idx++];
104 ERROR_IDF <<
"unterminated quote mark in line:\n";
115 while( idx < len && !isspace( aLine[idx] ) )
116 ostr << aLine[idx++];
120 aIDFString = hasQuotes ?
UnescapeString( ostr.str() ) : ostr.str();
133 std::string::size_type i, j;
134 std::string bigToken = aInputString;
135 j = aInputString.length();
137 for( i = 0; i < j; ++i )
138 bigToken[i] = std::toupper( bigToken[i] );
140 if( !bigToken.compare( aTokenString ) )
165 ERROR_IDF <<
"unrecognized IDF OWNER: '" << aToken <<
"'\n";
199 ERROR_IDF <<
"unrecognized IDF LAYER: '" << aToken <<
"'\n";
215 aBoardFile <<
"BOTTOM";
219 aBoardFile <<
"BOTH";
223 aBoardFile <<
"INNER";
233 std::ostringstream ostr;
234 ostr <<
"invalid IDF layer: " <<
static_cast<int>( aLayer );
236 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
242 return !aBoardFile.fail();
266 std::ostringstream ostr;
267 ostr <<
"[INVALID PLACEMENT VALUE]:" <<
static_cast<int>( aPlacement );
296 std::ostringstream ostr;
297 ostr <<
"[INVALID LAYER VALUE]:" <<
static_cast<int>( aLayer );
321 ostr <<
"UNKNOWN: " <<
static_cast<int>( aOwner );
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.
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.
KEY_OWNER
The type of CAD which has ownership an object.
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.
wxString UnescapeString(const wxString &aSource)