Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
02ba568c
Commit
02ba568c
authored
Dec 20, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move to std::set, no longer cache the sweet strings
parent
8384d7e0
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
161 additions
and
96 deletions
+161
-96
CMakeLists.txt
new/CMakeLists.txt
+1
-1
sch_dir_lib_source.cpp
new/sch_dir_lib_source.cpp
+120
-82
sch_dir_lib_source.h
new/sch_dir_lib_source.h
+40
-13
No files found.
new/CMakeLists.txt
View file @
02ba568c
...
...
@@ -58,7 +58,7 @@ endif()
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
)
add_executable
(
test_dir_lib_source sch_dir_lib_source.cpp
${
PROJECT_SOURCE_DIR
}
/common/richio.cpp
)
add_executable
(
test_dir_lib_source sch_dir_lib_source.cpp
)
#add_executable( test_dir_lib_source EXCLUDE_FROM_ALL sch_dir_lib_source.cpp )
target_link_libraries
(
test_dir_lib_source
${
wxWidgets_LIBRARIES
}
)
...
...
new/sch_dir_lib_source.cpp
View file @
02ba568c
This diff is collapsed.
Click to expand it.
new/sch_dir_lib_source.h
View file @
02ba568c
...
...
@@ -28,17 +28,35 @@
#include <sch_lib.h>
#include <
map
>
#include <
set
>
#include <vector>
/**
*
Type DIR_CACHE
* is
a tuple, where the key is partname (prefixed with the category if any),
*
and value is pointer to Sweet string which is loaded lazily, so can be NULL
*
until loaded
.
*
struct BY_REV
* is
here to provide a custom way to compare STRINGs. Namely, the revN[N..]
*
string if present, is collated according to a 'higher revision first', but
*
any part string without a revision, is even 'before' that
.
*/
typedef
std
::
map
<
STRING
,
STRING
*
>
DIR_CACHE
;
struct
BY_REV
{
bool
operator
()
(
const
STRING
&
s1
,
const
STRING
&
s2
)
const
;
};
/**
* Type PART_CACHE
* holds a set of part names in sorted order, according to the sort
* order given by struct BY_REV.
*/
typedef
std
::
set
<
STRING
,
BY_REV
>
PART_CACHE
;
/**
* Type NAME_CACHE
* holds a set of categories in sorted order.
*/
typedef
std
::
set
<
STRING
>
NAME_CACHE
;
namespace
SCH
{
...
...
@@ -55,11 +73,20 @@ class DIR_LIB_SOURCE : public LIB_SOURCE
bool
useVersioning
;
///< use files with extension ".revNNN..", else not
DIR_CACHE
sweets
;
///< @todo, don't really need to cache the sweets, only the partnames.
/// normal partnames, some of which may be prefixed with a category,
/// and some of which may have legal "revN[N..]" type strings.
PART_CACHE
partnames
;
/// categories which we expect to find in the set of @a partnames
NAME_CACHE
categories
;
STRINGS
categories
;
std
::
vector
<
char
>
readBuffer
;
///< used by readSExpression()
/**
* Function cache
* [re-]loads the directory cache(s).
*/
void
cache
()
throw
(
IO_ERROR
);
/**
* Function isPartFileName
...
...
@@ -87,14 +114,14 @@ class DIR_LIB_SOURCE : public LIB_SOURCE
/**
* Function
do
OneDir
* Function
cache
OneDir
* loads part names [and categories] from a directory given by
* "sourceURI + '/' + category"
* Categories are only loaded if processing the top most directory because
* only one level of categories are supported. We know we are in the
* top most directory if aCategory is empty.
*/
void
do
OneDir
(
const
STRING
&
aCategory
)
throw
(
IO_ERROR
);
void
cache
OneDir
(
const
STRING
&
aCategory
)
throw
(
IO_ERROR
);
//protected:
public
:
...
...
@@ -112,14 +139,14 @@ public:
* @param doUseVersioning if true means support versioning in the directory tree, otherwise
* only a single version of each part is recognized.
*/
DIR_LIB_SOURCE
(
const
STRING
&
aDirectoryPath
,
bool
doUseVersioning
=
false
)
DIR_LIB_SOURCE
(
const
STRING
&
aDirectoryPath
,
const
STRING
&
aOptions
=
StrEmpty
)
throw
(
IO_ERROR
);
~
DIR_LIB_SOURCE
();
//-----<LIB_SOURCE implementation functions >------------------------------
void
ReadPart
(
STRING
*
aResult
,
const
STRING
&
aPartName
,
const
STRING
&
aRev
=
StrEmpty
)
void
ReadPart
(
STRING
*
aResult
,
const
STRING
&
aPartName
,
const
STRING
&
aRev
=
StrEmpty
)
throw
(
IO_ERROR
);
void
ReadParts
(
STRINGS
*
aResults
,
const
STRINGS
&
aPartNames
)
...
...
@@ -127,7 +154,7 @@ public:
void
GetCategories
(
STRINGS
*
aResults
)
throw
(
IO_ERROR
);
void
GetCategoricalPartNames
(
STRINGS
*
aResults
,
const
STRING
&
aCategory
=
StrEmpty
)
void
GetCategoricalPartNames
(
STRINGS
*
aResults
,
const
STRING
&
aCategory
=
StrEmpty
)
throw
(
IO_ERROR
);
void
GetRevisions
(
STRINGS
*
aResults
,
const
STRING
&
aPartName
)
throw
(
IO_ERROR
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment