Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
82c8fb24
Commit
82c8fb24
authored
Jun 22, 2018
by
Hugo Beauzée-Luyssen
Browse files
Metadata: Provide an unset method
parent
1ebc9b48
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Metadata.cpp
View file @
82c8fb24
...
...
@@ -63,6 +63,12 @@ const std::string& Metadata::Record::str() const
return
m_value
;
}
void
Metadata
::
Record
::
unset
()
{
m_isSet
=
false
;
m_value
.
clear
();
}
Metadata
::
Metadata
(
MediaLibraryPtr
ml
,
IMetadata
::
EntityType
entityType
)
:
m_ml
(
ml
)
,
m_entityType
(
entityType
)
...
...
@@ -151,6 +157,23 @@ bool Metadata::set( uint32_t type, int64_t value )
return
set
(
type
,
str
);
}
bool
Metadata
::
unset
(
uint32_t
type
)
{
assert
(
isReady
()
==
true
);
auto
it
=
std
::
find_if
(
begin
(
m_records
),
end
(
m_records
),
[
type
](
const
Record
&
r
)
{
return
r
.
m_type
==
type
;
});
if
(
it
!=
end
(
m_records
)
)
{
static
const
std
::
string
req
=
"DELETE FROM "
+
policy
::
MetadataTable
::
Name
+
" WHERE id_media = ? AND entity_type = ? AND type = ?"
;
(
*
it
).
unset
();
return
sqlite
::
Tools
::
executeDelete
(
m_ml
->
getConn
(),
req
,
m_entityId
,
m_entityType
,
type
);
}
return
true
;
}
void
Metadata
::
unset
(
sqlite
::
Connection
*
dbConn
,
IMetadata
::
EntityType
entityType
,
uint32_t
type
)
{
static
const
std
::
string
req
=
"DELETE FROM "
+
policy
::
MetadataTable
::
Name
+
...
...
src/Metadata.h
View file @
82c8fb24
...
...
@@ -56,6 +56,7 @@ public:
IMetadata
&
get
(
uint32_t
type
)
const
;
bool
set
(
uint32_t
type
,
const
std
::
string
&
value
);
bool
set
(
uint32_t
type
,
int64_t
value
);
bool
unset
(
uint32_t
type
);
static
void
unset
(
sqlite
::
Connection
*
dbConn
,
IMetadata
::
EntityType
entityType
,
uint32_t
type
);
...
...
@@ -71,6 +72,7 @@ private:
virtual
bool
isSet
()
const
override
;
virtual
int64_t
integer
()
const
override
;
virtual
const
std
::
string
&
str
()
const
override
;
void
unset
();
void
set
(
const
std
::
string
&
value
);
private:
...
...
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