33 std::streampos& aFilePos )
36 aFilePos = aModel.tellg();
41 std::getline( aModel, aLine );
50 aLine.erase( aLine.begin() );
54 while( !aLine.empty() && isspace( *aLine.begin() ) )
55 aLine.erase( aLine.begin() );
57 while( !aLine.empty() && isspace( *aLine.rbegin() ) )
58 aLine.erase( --aLine.end() );
61 if( aLine.empty() && !isComment )
75 std::ostringstream ostr;
77 int len = aLine.length();
80 if( idx < 0 || idx >= len )
83 while( idx < len && isspace( aLine[idx] ) )
92 if( aLine[idx] ==
'"' )
97 while( idx < len && aLine[idx] !=
'"' )
102 ERROR_IDF <<
"unterminated quote mark in line:\n";
113 while( idx < len && !isspace( aLine[idx] ) )
114 ostr << aLine[idx++];
118 aIDFString = ostr.str();
131 std::string::size_type i, j;
132 std::string bigToken = aInputString;
133 j = aInputString.length();
135 for( i = 0; i < j; ++i )
136 bigToken[i] = std::toupper( bigToken[i] );
138 if( !bigToken.compare( aTokenString ) )
163 ERROR_IDF <<
"unrecognized IDF OWNER: '" << aToken <<
"'\n";
197 ERROR_IDF <<
"unrecognized IDF LAYER: '" << aToken <<
"'\n";
213 aBoardFile <<
"BOTTOM";
217 aBoardFile <<
"BOTH";
221 aBoardFile <<
"INNER";
231 std::ostringstream ostr;
232 ostr <<
"invalid IDF layer: " <<
static_cast<int>( aLayer );
234 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
240 return !aBoardFile.fail();
264 std::ostringstream ostr;
265 ostr <<
"[INVALID PLACEMENT VALUE]:" <<
static_cast<int>( aPlacement );
294 std::ostringstream ostr;
295 ostr <<
"[INVALID LAYER VALUE]:" <<
static_cast<int>( aLayer );
319 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.