Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
f46d7956
Commit
f46d7956
authored
Nov 06, 2018
by
Simon Spannagel
Browse files
Clipboard: simplify, remove redundant information, make safer
parent
f337ce26
Pipeline
#573856
passed with stages
in 15 minutes and 46 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/core/clipboard/Clipboard.cpp
View file @
f46d7956
...
...
@@ -5,13 +5,11 @@
using
namespace
corryvreckan
;
void
Clipboard
::
put
(
std
::
string
name
,
Objects
*
objects
)
{
m_dataID
.
push_back
(
name
);
m_data
[
name
]
=
objects
;
m_data
.
insert
(
ClipboardData
::
value_type
(
name
,
objects
));
}
void
Clipboard
::
put
(
std
::
string
name
,
std
::
string
type
,
Objects
*
objects
)
{
m_dataID
.
push_back
(
name
+
type
);
m_data
[
name
+
type
]
=
objects
;
m_data
.
insert
(
ClipboardData
::
value_type
(
name
+
type
,
objects
));
}
void
Clipboard
::
put_persistent
(
std
::
string
name
,
double
value
)
{
...
...
@@ -38,20 +36,20 @@ bool Clipboard::has_persistent(std::string name) {
}
void
Clipboard
::
clear
()
{
for
(
auto
&
id
:
m_dataID
)
{
Objects
*
collection
=
m_data
[
id
]
;
for
(
Objects
::
iterator
it
=
collection
->
begin
();
it
!=
collection
->
end
();
++
it
)
for
(
auto
set
=
m_data
.
cbegin
();
set
!=
m_data
.
cend
();
)
{
Objects
*
collection
=
set
->
second
;
for
(
Objects
::
iterator
it
=
collection
->
begin
();
it
!=
collection
->
end
();
++
it
)
{
delete
(
*
it
);
delete
m_data
[
id
];
m_data
.
erase
(
id
);
}
delete
collection
;
set
=
m_data
.
erase
(
set
);
}
m_dataID
.
clear
();
}
std
::
vector
<
std
::
string
>
Clipboard
::
listCollections
()
{
std
::
vector
<
std
::
string
>
collections
;
for
(
auto
&
name
:
m_data
ID
)
{
collections
.
push_back
(
name
);
for
(
auto
&
dataset
:
m_data
)
{
collections
.
push_back
(
dataset
.
first
);
}
return
collections
;
}
src/core/clipboard/Clipboard.hpp
View file @
f46d7956
...
...
@@ -98,11 +98,10 @@ namespace corryvreckan {
std
::
vector
<
std
::
string
>
listCollections
();
private:
// Container for data, list of all data held
std
::
map
<
std
::
string
,
Objects
*>
m_data
;
typedef
std
::
map
<
std
::
string
,
Objects
*>
ClipboardData
;
//
List of available data collections
std
::
vector
<
std
::
string
>
m_data
ID
;
//
Container for data, list of all data held
ClipboardData
m_data
;
// Persistent clipboard storage
std
::
unordered_map
<
std
::
string
,
double
>
m_persistent_data
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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