diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp
index 39791d0b03..f5703d2855 100644
--- a/common/dsnlexer.cpp
+++ b/common/dsnlexer.cpp
@@ -65,7 +65,7 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
keywords( aKeywordTable ),
keywordCount( aKeywordCount )
{
- FILE_LINE_READER* fileReader = new FILE_LINE_READER( aFile, aFilename, 4096 );
+ FILE_LINE_READER* fileReader = new FILE_LINE_READER( aFile, aFilename );
PushReader( fileReader );
init();
}
diff --git a/common/richio.cpp b/common/richio.cpp
index c918f13c6c..ccbcc5d0e1 100644
--- a/common/richio.cpp
+++ b/common/richio.cpp
@@ -82,11 +82,23 @@ void LINE_READER::expandCapacity( unsigned newsize )
}
-FILE_LINE_READER::FILE_LINE_READER( FILE* aFile, const wxString& aFileName, unsigned aMaxLineLength ) :
+FILE_LINE_READER::FILE_LINE_READER( FILE* aFile, const wxString& aFileName,
+ bool doOwn,
+ unsigned aStartingLineNumber,
+ unsigned aMaxLineLength ) :
LINE_READER( aMaxLineLength ),
+ iOwn( doOwn ),
fp( aFile )
{
- source = aFileName;
+ source = aFileName;
+ lineNum = aStartingLineNumber;
+}
+
+
+FILE_LINE_READER::~FILE_LINE_READER()
+{
+ if( iOwn && fp )
+ fclose( fp );
}
@@ -117,6 +129,29 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
}
+STRING_LINE_READER::STRING_LINE_READER( const std::string& aString, const wxString& aSource ) :
+ LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
+ lines( aString ),
+ ndx( 0 )
+{
+ // Clipboard text should be nice and _use multiple lines_ so that
+ // we can report _line number_ oriented error messages when parsing.
+ source = aSource;
+}
+
+
+STRING_LINE_READER::STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint ) :
+ LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
+ lines( aStartingPoint.lines ),
+ ndx( aStartingPoint.ndx )
+{
+ // since we are keeping the same "source" name, for error reporting purposes
+ // we need to have the same notion of line number and offset.
+
+ source = aStartingPoint.source;
+ lineNum = aStartingPoint.lineNum;
+}
+
unsigned STRING_LINE_READER::ReadLine() throw( IO_ERROR )
{
size_t nlOffset = lines.find( '\n', ndx );
diff --git a/include/richio.h b/include/richio.h
index 8892a2bc8a..e6c32fa5da 100644
--- a/include/richio.h
+++ b/include/richio.h
@@ -53,7 +53,7 @@ class LINE_READER
{
protected:
unsigned length; ///< no. bytes in line before trailing nul.
- int lineNum;
+ unsigned lineNum;
char* line; ///< the read line of UTF8 text
unsigned capacity; ///< no. bytes allocated for line.
@@ -115,7 +115,7 @@ public:
* returns the line number of the last line read from this LINE_READER. Lines
* start from 1.
*/
- int LineNumber() const
+ unsigned LineNumber() const
{
return lineNum;
}
@@ -140,7 +140,8 @@ class FILE_LINE_READER : public LINE_READER
{
protected:
- FILE* fp; ///< I own this file
+ bool iOwn; ///< if I own the file, I'll promise to close it, else not.
+ FILE* fp; ///< I may own this file, but might not.
public:
@@ -151,15 +152,23 @@ public:
*
* @param aFile is an open file.
* @param aFileName is the name of the file for error reporting purposes.
+ * @param doOwn if true, means I should close the open file, else not.
+ * @param aStartingLineNumber is the initial line number to report on error, and is
+ * accessible here for the case where multiple DSNLEXERs are reading from the
+ * same file in sequence, all from the same open file (with @a doOwn = false).
+ * Internally it is incremented by one after each ReadLine(), so the first
+ * reported line number will always be one greater than what is provided here.
* @param aMaxLineLength is the number of bytes to use in the line buffer.
*/
- FILE_LINE_READER( FILE* aFile, const wxString& aFileName, unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
+ FILE_LINE_READER( FILE* aFile, const wxString& aFileName, bool doOwn = true,
+ unsigned aStartingLineNumber = 0,
+ unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
- ~FILE_LINE_READER()
- {
- if( fp )
- fclose( fp );
- }
+ /**
+ * Destructor
+ * may or may not close the open file, depending on @a doOwn in constructor.
+ */
+ ~FILE_LINE_READER();
unsigned ReadLine() throw( IO_ERROR ); // see LINE_READER::ReadLine() description
@@ -198,17 +207,17 @@ public:
* @param aSource describes the source of aString for error reporting purposes
* can be anything meaninful, such as wxT( "clipboard" ).
*/
- STRING_LINE_READER( const std::string& aString, const wxString& aSource ) :
- LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
- lines( aString ),
- ndx( 0 )
- {
- // Clipboard text should be nice and _use multiple lines_ so that
- // we can report _line number_ oriented error messages when parsing.
- source = aSource;
- }
+ STRING_LINE_READER( const std::string& aString, const wxString& aSource );
- unsigned ReadLine() throw( IO_ERROR ); // see LINE_READER::ReadLine() description
+ /**
+ * Constructor STRING_LINE_READER( const STRING_LINE_READER& )
+ * allows for a continuation of the reading of a stream started by another
+ * STRING_LINE_READER. Any stream offset and source name are used from
+ * @a aStartingPoint.
+ */
+ STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint );
+
+ unsigned ReadLine() throw( IO_ERROR ); // see LINE_READER::ReadLine() description
};
diff --git a/new/design.h b/new/design.h
index b4bf5704a1..9ccfc28ced 100644
--- a/new/design.h
+++ b/new/design.h
@@ -371,158 +371,6 @@ const STRING StrEmpty = "";
/** @} exception_types Exception Types */
-
-/**
- * Class LPID (aka GUID)
- * is a Logical Part ID and consists of various portions much like a URI. It
- * relies heavily on a logical library name to hide where actual physical library
- * sources reside. Its static functions serve as managers of the "library table" to
- * map logical library names to actual library sources.
- *
- * Example LPID string:
- * "kicad:passives/R/rev6".
- *
- *
- * - "kicad" is the logical library name.
- *
- "passives" is the category.
- *
- "passives/R" is the partname.
- *
- "rev6" is the revision number, which is optional. If missing then its
- * delimiter should also not be present.
- *
- *
- * This class owns the library table, which is like fstab in concept and maps logical
- * library name to library URI, type, and options. It has the following columns:
- *
- * - Logical Library Name
- *
- Library Type
- *
- Library URI. The full URI to the library source, form dependent on Type.
- *
- Options, used for access, such as password
- *
- *
- * For now, the Library Type can be one of:
- *
- * - "dir"
- *
- "schematic" i.e. a parts list from another schematic.
- *
- "subversion"
- *
- "bazaar"
- *
- "http"
- *
- *
- * For now, the Library URI types needed to support the various types can be one of those
- * shown below, which are typical of each type:
- *
- * - "file://C:/mylibdir"
- *
- "file://home/user/kicadwork/jtagboard.sch"
- *
- "svn://kicad.org/partlib/trunk"
- *
- "http://kicad.org/partlib"
- *
- *
- * The applicable library table is built up from several additive rows (table fragments),
- * and the final table is a merging of the table fragments. Two anticipated sources of
- * the rows are a personal table, and a schematic resident table. The schematic
- * resident table rows are considered a higher priority in the final dynamically
- * assembled library table. A row in the schematic contribution to the library table
- * will take precedence over the personal table if there is a collision on logical
- * library name, otherwise the rows simply combine without issue to make up the
- * applicable library table.
- */
-class LPID // aka GUID
-{
-public:
- /**
- * Constructor LPID
- * takes aLPID string and parses it. A typical LPID string uses a logical
- * library name followed by a part name.
- * e.g.: "kicad:passives/R/rev2", or
- * e.g.: "mylib:R33"
- */
- LPID( const STRING& aLPID ) throw( PARSE_ERROR );
-
- /**
- * Function GetLogLib
- * returns the logical library portion of a LPID. There is not Set accessor
- * for this portion since it comes from the library table and is considered
- * read only here.
- */
- STRING GetLogLib() const;
-
- /**
- * Function GetCategory
- * returns the category of this part id, "passives" in the example at the
- * top of the class description.
- */
- STRING GetCategory() const;
-
- /**
- * Function SetCategory
- * overrides the category portion of the LPID to @a aCategory and is typically
- * either the empty string or a single word like "passives".
- */
- void SetCategory( const STRING& aCategory );
-
- /**
- * Function GetRevision
- * returns the revision portion of the LPID or StrEmpty if none.
- */
- STRING GetRevision() const;
-
- /**
- * Function SetRevision
- * overrides the revision portion of the LPID to @a aRevision and must
- * be in the form "rev" where "" is "1", "2", etc.
- */
- void SetRevision( const STRING& aRevision );
-
- /**
- * Function GetFullText
- * returns the full text of the LPID.
- */
- STRING GetFullText() const;
-
-
- //----------------------------------------------------------
-
- /**
- * Function GetLogicalLibraries
- * returns the logical library names, all of them that are in the
- * library table.
- * @param aSchematic provides access to the full library table inclusive
- * of the schematic contribution, or may be NULL to exclude the schematic rows.
- */
- static STRINGS GetLogicalLibraries( SCHEMATIC* aSchematic=NULL );
-
- /**
- * Function GetLibraryURI
- * returns the full library path from a logical library name.
- * @param aLogicalLibraryName is the short name for the library of interest.
- * @param aSchematic provides access to the full library table inclusive
- * of the schematic contribution, or may be NULL to exclude the schematic rows.
- */
- static STRING GetLibraryURI( const STRING& aLogicalLibraryName,
- SCHEMATIC* aSchematic=NULL ) const;
-
- /**
- * Function GetLibraryType
- * returns the type of a logical library.
- * @param aLogicalLibraryName is the short name for the library of interest.
- * @param aSchematic provides access to the full library table inclusive
- * of the schematic contribution, or may be NULL to exclude the schematic rows.
- */
- static STRING GetLibraryType( const STRING& aLogicalLibraryName,
- SCHEMATIC* aSchematic=NULL ) const;
-
- /**
- * Function GetOptions
- * returns the options string for \a aLogicalLibraryName.
- * @param aLogicalLibraryName is the short name for the library of interest.
- * @param aSchematic provides access to the full library table inclusive
- * of the schematic contribution, or may be NULL to exclude the schematic rows.
- */
- static STRING GetPassword( const STRING& aLogicalLibraryName,
- SCHEMATIC* aSchematic=NULL ) const;
-};
-
-
/**
* Class SVN_LIB_SOURCE
* implements a LIB_SOURCE in a subversion repository.
diff --git a/new/sch_lib_table.cpp b/new/sch_lib_table.cpp
index f0d34d536c..f926d85d89 100644
--- a/new/sch_lib_table.cpp
+++ b/new/sch_lib_table.cpp
@@ -30,8 +30,10 @@ using namespace std;
using namespace SCH;
-LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable )
+LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ) :
+ fallBack( aFallBackTable )
{
+ /* not copying fall back, simply search it separately if "logicalName not found".
if( aFallBackTable )
{
const ROWS& t = aFallBackTable->rows;
@@ -39,12 +41,12 @@ LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable )
for( ROWS_CITER it = t.begin(); it != t.end(); ++it )
{
// our rows are empty, expect no collisions here
- auto_ptr row( new ROW( *it ) );
-
+ auto_ptr row( new ROW( *it->second ) );
row->owner = this;
- rows.insert( row.release() );
+ insert( row );
}
}
+ */
}
@@ -126,18 +128,89 @@ void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR )
in->NeedRIGHT();
in->NeedRIGHT(); // teriminate the (lib..)
- rows.insert( row.release() );
+ // all logicalNames within this table fragment must be unique, so we do not
+ // replace. However a fallBack table can have a conflicting logicalName
+ // and ours will supercede that one since in findLib() we search this table
+ // before any fall back.
+ if( !InsertLib( row ) )
+ {
+ char buf[300];
+
+ snprintf( buf, sizeof(buf),
+ "'%s' is a duplicate logical lib name",
+ row->logicalName.c_str() );
+ throw IO_ERROR( buf );
+ }
}
return;
}
-#if 1
+void LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const
+ throw( IO_ERROR )
+{
+ out->Print( nestLevel, "(lib_table\n" );
+ for( ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
+ it->second->Format( out, nestLevel+1 );
+ out->Print( nestLevel, ")\n" );
+}
-int main( int argc, char** argv )
+void LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
+ throw( IO_ERROR )
+{
+ out->Print( nestLevel, "(lib (logical \"%s\")(type \"%s\")(full_uri \"%s\")(options \"%s\"))\n",
+ logicalName.c_str(), libType.c_str(), fullURI.c_str(), options.c_str() );
+}
+
+
+const LIB_TABLE::ROW* LIB_TABLE::FindLib( const STRING& aLogicalName )
+{
+ // this function must be *super* fast, so therefore should not instantiate
+ // anything which would require using the heap. This function is the reason
+ // ptr_map<> was used instead of ptr_set<>, which would have required
+ // instantiating a ROW just to find a ROW.
+
+ ROWS_CITER it = rows.find( aLogicalName );
+
+ if( it != rows.end() )
+ {
+ // reference: http://myitcorner.com/blog/?p=361
+ return (const LIB_TABLE::ROW*) it->second; // found
+ }
+
+ // not found, search fall back table
+ if( fallBack )
+ return fallBack->FindLib( aLogicalName );
+
+ return 0; // not found
+}
+
+
+bool LIB_TABLE::InsertLib( auto_ptr& aRow, bool doReplace )
+{
+ ROWS_ITER it = rows.find( aRow->logicalName );
+
+ if( doReplace || it == rows.end() )
+ {
+ // be careful here, key is needed because aRow can be
+ // release()ed before logicalName is captured.
+ const STRING& key = aRow->logicalName;
+ rows.insert( key, aRow );
+ return true;
+ }
+
+ return false;
+}
+
+
+#if 1 && defined(DEBUG)
+
+// build this with a Debug CMAKE_BUILD_TYPE
+
+void LIB_TABLE::Test()
{
// the null string is not really a legal DSN token since any double quotes
- // as assumed to be a single quote. To pass an empty string, we pass " "
+ // are assumed to be a single quote. To pass an empty string, we pass " "
// to (options " ")
SCH_LIB_TABLE_LEXER slr(
"(lib_table \n"
@@ -148,16 +221,14 @@ int main( int argc, char** argv )
wxT( "inline text" ) // source
);
- LIB_TABLE lib_table;
-
- // read the "( lib_table" pair of tokens
-
try
{
+ // read the "( lib_table" pair of tokens
slr.NextTok();
slr.NextTok();
- lib_table.Parse( &slr );
+ // parse the rest of input to slr
+ Parse( &slr );
}
catch( std::exception& ex )
@@ -167,11 +238,36 @@ int main( int argc, char** argv )
catch( IO_ERROR ioe )
{
- printf( "caught\n" );
printf( "exception: %s\n", (const char*) wxConvertWX2MB( ioe.errorText ) );
}
- lib_table.Show();
+ STRING_FORMATTER sf;
+
+ Format( &sf, 0 );
+
+ printf( "test 'Parse() <-> Format()' round tripping:\n" );
+ printf( "%s", sf.GetString().c_str() );
+
+ printf( "\ntest a lookup of 'www':\n" );
+ sf.Clear();
+
+ const LIB_TABLE::ROW* www = FindLib( "www" );
+ if( www )
+ {
+ // found, print it just to prove it.
+ www->Format( &sf, 1 );
+ printf( "%s", sf.GetString().c_str() );
+ }
+ else
+ printf( "not found\n" );
+}
+
+
+int main( int argc, char** argv )
+{
+ LIB_TABLE lib_table;
+
+ lib_table.Test();
return 0;
}
diff --git a/new/sch_lib_table.h b/new/sch_lib_table.h
index f2bc59fed8..01d4a30135 100644
--- a/new/sch_lib_table.h
+++ b/new/sch_lib_table.h
@@ -26,13 +26,17 @@
#define SCH_LIB_TABLE_H_
#include
-#include
+#include
#include
class SCH_LIB_TABLE_LEXER; // outside namespace SCH, since make_lexer() Functions.cmake can't do namespace
+class OUTPUTFORMATTER;
namespace SCH {
+class LPID;
+class PART;
+
/**
* Class LIB_TABLE
* holds LIB_TABLE::ROW records, and can be searched in a very high speed
@@ -54,10 +58,12 @@ public:
public:
+ /* was needed for ptr_set<> but not ptr_map<>
bool operator<( const ROW& other ) const
{
return logicalName < other.logicalName;
}
+ */
/**
* Function GetLogicalName
@@ -101,13 +107,16 @@ public:
delete lib;
}
-#if defined(DEBUG)
- void Show() const
- {
- printf( "(lib (logical \"%s\")(type \"%s\")(full_uri \"%s\")(options \"%s\"))\n",
- logicalName.c_str(), libType.c_str(), fullURI.c_str(), options.c_str() );
- }
-#endif
+ /**
+ * Function Format
+ * serializes this object as utf8 text to an OUTPUTFORMATTER, and tries to
+ * make it look good using multiple lines and indentation.
+ * @param out is an OUTPUTFORMATTER
+ * @param nestLevel is the indentation level to base all lines of the output.
+ * Actual indentation will be 2 spaces for each nestLevel.
+ */
+ void Format( OUTPUTFORMATTER* out, int nestLevel ) const
+ throw( IO_ERROR );
protected:
@@ -195,23 +204,100 @@ public:
*/
void Parse( SCH_LIB_TABLE_LEXER* aLexer ) throw( IO_ERROR );
-#if defined(DEBUG)
- void Show() const
- {
- printf("(lib_table\n" );
- for( ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
- it->Show();
- printf(")\n" );
- }
+ /**
+ * Function Format
+ * serializes this object as utf8 text to an OUTPUTFORMATTER, and tries to
+ * make it look good using multiple lines and indentation.
+ * @param out is an OUTPUTFORMATTER
+ * @param nestLevel is the indentation level to base all lines of the output.
+ * Actual indentation will be 2 spaces for each nestLevel.
+ */
+ void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR );
+
+ /**
+ * Function GetPart
+ * finds and loads a PART, and parses it. As long as the part is
+ * accessible in any LIB_SOURCE, opened or not opened, this function
+ * will find it and load it into its containing LIB, even if that means
+ * having to open a LIB in this table that was not previously opened.
+ */
+ PART* GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR );
+
+
+#if 0 // moved here from LPID
+ /**
+ * Function GetLogicalLibraries
+ * returns the logical library names, all of them that are in the
+ * library table.
+ */
+ STRINGS GetLogicalLibraries();
+
+ /**
+ * Function GetLibraryURI
+ * returns the full library path from a logical library name.
+ * @param aLogicalLibraryName is the short name for the library of interest.
+ * @param aSchematic provides access to the full library table inclusive
+ * of the schematic contribution, or may be NULL to exclude the schematic rows.
+ */
+ STRING GetLibraryURI( const STRING& aLogicalLibraryName,
+ SCHEMATIC* aSchematic=NULL ) const;
+
+ /**
+ * Function GetLibraryType
+ * returns the type of a logical library.
+ * @param aLogicalLibraryName is the short name for the library of interest.
+ * @param aSchematic provides access to the full library table inclusive
+ * of the schematic contribution, or may be NULL to exclude the schematic rows.
+ */
+ STRING GetLibraryType( const STRING& aLogicalLibraryName,
+ SCHEMATIC* aSchematic=NULL ) const;
+
+ /**
+ * Function GetOptions
+ * returns the options string for \a aLogicalLibraryName.
+ * @param aLogicalLibraryName is the short name for the library of interest.
+ * @param aSchematic provides access to the full library table inclusive
+ * of the schematic contribution, or may be NULL to exclude the schematic rows.
+ */
+ STRING GetOptions( const STRING& aLogicalLibraryName,
+ SCHEMATIC* aSchematic=NULL ) const;
#endif
- typedef boost::ptr_set ROWS;
- typedef ROWS::iterator ROWS_ITER;
- typedef ROWS::const_iterator ROWS_CITER;
+
+#if defined(DEBUG)
+ /// implement the tests in here so we can honor the priviledge levels of the
+ /// accessors, something difficult to do from int main(int, char**)
+ void Test();
+#endif
+
+protected: // only a table editor can use these
+
+ /**
+ * Function InsertLib
+ * adds aRow if it does not already exist or if doReplace is true. If doReplace
+ * is not true and the key for aRow already exists, the function fails and returns false.
+ * @param aRow is the new row to insert, or to forcibly add if doReplace is true.
+ * @param doReplace if true, means insert regardless if aRow's key already exists. If false, then fail
+ * if the key already exists.
+ * @return bool - true if the operation succeeded.
+ */
+ bool InsertLib( std::auto_ptr& aRow, bool doReplace = false );
+
+ /**
+ * Function FindLib
+ * returns a ROW* if aLogicalName is found in this table or in fallBack.
+ */
+ const ROW* FindLib( const STRING& aLogicalName );
private:
- ROWS rows;
+ typedef boost::ptr_map ROWS;
+ typedef ROWS::iterator ROWS_ITER;
+ typedef ROWS::const_iterator ROWS_CITER;
+// typedef std::pair ROW_PAIR;
+
+ ROWS rows;
+ LIB_TABLE* fallBack;
};
} // namespace SCH
diff --git a/new/sch_lpid.cpp b/new/sch_lpid.cpp
new file mode 100644
index 0000000000..fc27025468
--- /dev/null
+++ b/new/sch_lpid.cpp
@@ -0,0 +1,36 @@
+/*
+ * This program source code file is part of KICAD, a free EDA CAD application.
+ *
+ * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck
+ * Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include
+
+
+using namespace SCH;
+
+
+LPID::LPID( const STRING& aLPID ) throw( PARSE_ERROR )
+{
+}
+
+
+
diff --git a/new/sch_lpid.h b/new/sch_lpid.h
new file mode 100644
index 0000000000..e5554c0b10
--- /dev/null
+++ b/new/sch_lpid.h
@@ -0,0 +1,139 @@
+/*
+ * This program source code file is part of KICAD, a free EDA CAD application.
+ *
+ * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck
+ * Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef SCH_LPID_H_
+#define SCH_LPID_H_
+
+//#include
+
+
+/**
+ * Class LPID
+ * (aka GUID) is a Logical Part ID and consists of various portions much like a URI.
+ * It relies heavily on a logical library name to hide where actual physical library
+ * sources reside. Its static functions serve as managers of the "library table" to
+ * map logical library names to actual library sources.
+ *
+ * Example LPID string:
+ * "kicad:passives/R/rev6".
+ *
+ *
+ * - "kicad" is the logical library name.
+ *
- "passives" is the category.
+ *
- "passives/R" is the partname.
+ *
- "rev6" is the revision number, which is optional. If missing then its
+ * delimiter should also not be present.
+ *
+ *
+ * This class owns the library table, which is like fstab in concept and maps logical
+ * library name to library URI, type, and options. It has the following columns:
+ *
+ * - Logical Library Name
+ *
- Library Type
+ *
- Library URI. The full URI to the library source, form dependent on Type.
+ *
- Options, used for access, such as password
+ *
+ *
+ * For now, the Library Type can be one of:
+ *
+ * - "dir"
+ *
- "schematic" i.e. a parts list from another schematic.
+ *
- "subversion"
+ *
- "bazaar"
+ *
- "http"
+ *
+ *
+ * For now, the Library URI types needed to support the various types can be one of those
+ * shown below, which are typical of each type:
+ *
+ * - "file://C:/mylibdir"
+ *
- "file://home/user/kicadwork/jtagboard.sch"
+ *
- "svn://kicad.org/partlib/trunk"
+ *
- "http://kicad.org/partlib"
+ *
+ *
+ * The applicable library table is built up from several additive rows (table fragments),
+ * and the final table is a merging of the table fragments. Two anticipated sources of
+ * the rows are a personal table, and a schematic resident table. The schematic
+ * resident table rows are considered a higher priority in the final dynamically
+ * assembled library table. A row in the schematic contribution to the library table
+ * will take precedence over the personal table if there is a collision on logical
+ * library name, otherwise the rows simply combine without issue to make up the
+ * applicable library table.
+ */
+class LPID // aka GUID
+{
+public:
+ /**
+ * Constructor LPID
+ * takes aLPID string and parses it. A typical LPID string uses a logical
+ * library name followed by a part name.
+ * e.g.: "kicad:passives/R/rev2", or
+ * e.g.: "mylib:R33"
+ */
+ LPID( const STRING& aLPID ) throw( PARSE_ERROR );
+
+ /**
+ * Function GetLogLib
+ * returns the logical library portion of a LPID. There is not Set accessor
+ * for this portion since it comes from the library table and is considered
+ * read only here.
+ */
+ STRING GetLogLib() const;
+
+ /**
+ * Function GetCategory
+ * returns the category of this part id, "passives" in the example at the
+ * top of the class description.
+ */
+ STRING GetCategory() const;
+
+ /**
+ * Function SetCategory
+ * overrides the category portion of the LPID to @a aCategory and is typically
+ * either the empty string or a single word like "passives".
+ */
+ void SetCategory( const STRING& aCategory );
+
+ /**
+ * Function GetRevision
+ * returns the revision portion of the LPID or StrEmpty if none.
+ */
+ STRING GetRevision() const;
+
+ /**
+ * Function SetRevision
+ * overrides the revision portion of the LPID to @a aRevision and must
+ * be in the form "rev" where "" is "1", "2", etc.
+ */
+ void SetRevision( const STRING& aRevision );
+
+ /**
+ * Function GetFullText
+ * returns the full text of the LPID.
+ */
+ STRING GetFullText() const;
+};
+
+#endif // SCH_LPID_H_
diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp
index f40e140884..322e1621a9 100644
--- a/pcbnew/netlist.cpp
+++ b/pcbnew/netlist.cpp
@@ -174,7 +174,7 @@ bool WinEDA_PcbFrame::ReadPcbNetlist( const wxString& aNetlistFullFilename,
if( !netfile )
return false;
- FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename, BUFFER_CHAR_SIZE );
+ FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename );
char* Line = netlistReader;
SetLastNetListRead( aNetlistFullFilename );
@@ -798,7 +798,7 @@ int BuildFootprintsListFromNetlistFile( const wxString& aNetlistFullFilename,
if( !netfile )
return -1;
- FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename, BUFFER_CHAR_SIZE );
+ FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename );
char* Line = netlistReader;
State = 0; Comment = 0;
@@ -901,7 +901,7 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp,
return 0;
}
- FILE_LINE_READER netlistReader( FichCmp, CmpFullFileName, BUFFER_CHAR_SIZE );
+ FILE_LINE_READER netlistReader( FichCmp, CmpFullFileName );
char* Line = netlistReader;
while( netlistReader.ReadLine() )