Skip to content

Commit 23b0446

Browse files
author
Clement Champetier
committed
MediaMetadatasStructures: switch MetadatasMap from map to vector<pair>
* Use the typedef as ofter as possible. * This structure will enable us to give the data with the order we want (which is not the alphabetic order).
1 parent 2d226d7 commit 23b0446

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/AvTranscoder/Metadatas/MediaMetadatasStructures.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "MediaMetadatasStructures.hpp"
22

33
#include <sstream>
4+
#include <utility>
45

56
namespace avtranscoder
67
{
@@ -13,19 +14,20 @@ void add( MetadatasMap& dataMap, const std::string& key, const T& value )
1314
{
1415
std::stringstream ss;
1516
ss << value;
16-
dataMap[key]= ss.str();
17+
add( dataMap, key, ss.str() );
1718
}
1819

1920
template<>
2021
void add( MetadatasMap& dataMap, const std::string& key, const std::string& value )
2122
{
22-
dataMap[key]= value;
23+
dataMap.push_back( std::pair<std::string, std::string>( key, value ) );
2324
}
2425

2526
template<>
2627
void add( MetadatasMap& dataMap, const std::string& key, const bool& value )
2728
{
28-
dataMap[key]= ( value ? "True" : "False" );
29+
add( dataMap, key, value ? "True" : "False" );
30+
}
2931
}
3032

3133
}

src/AvTranscoder/Metadatas/MediaMetadatasStructures.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace avtranscoder
1313
/**
1414
* @brief Can get all data of Properties structures by getDataMap(), which return a MetadatasMap.
1515
*/
16-
typedef std::map<std::string, std::string> MetadatasMap;
16+
typedef std::vector< std::pair<std::string, std::string> > MetadatasMap;
1717

1818
struct Channel
1919
{
@@ -150,7 +150,7 @@ struct Properties
150150
std::vector< AttachementProperties > attachementStreams;
151151
std::vector< UnknownProperties > unknownStreams;
152152

153-
std::vector< std::pair< std::string, std::string > > metadatas; // ( key, value )
153+
MetadatasMap metadatas;
154154

155155
public:
156156
MetadatasMap getDataMap() const;

src/AvTranscoder/Metadatas/Print.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ std::ostream& operator<<( std::ostream& flux, const Properties& properties )
1919
flux << std::left;
2020
flux << separator << " Wrapper " << separator << std::endl;
2121

22-
std::map<std::string, std::string> dataMap = properties.getDataMap();
23-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
22+
MetadatasMap dataMap = properties.getDataMap();
23+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
2424
{
2525
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
2626
}
@@ -33,8 +33,8 @@ std::ostream& operator<<( std::ostream& flux, const VideoProperties& videoProper
3333
flux << std::left;
3434
flux << separator << " Video stream " << separator << std::endl;
3535

36-
std::map<std::string, std::string> dataMap = videoProperties.getDataMap();
37-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
36+
MetadatasMap dataMap = videoProperties.getDataMap();
37+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
3838
{
3939
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
4040
}
@@ -47,8 +47,8 @@ std::ostream& operator<<( std::ostream& flux, const AudioProperties& audioProper
4747
flux << std::left;
4848
flux << separator << " Audio stream " << separator << std::endl;
4949

50-
std::map<std::string, std::string> dataMap = audioProperties.getDataMap();
51-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
50+
MetadatasMap dataMap = audioProperties.getDataMap();
51+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
5252
{
5353
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
5454
}
@@ -60,8 +60,8 @@ std::ostream& operator<<( std::ostream& flux, const DataProperties& dataProperti
6060
{
6161
flux << separator << " Data stream " << separator << std::endl;
6262

63-
std::map<std::string, std::string> dataMap = dataProperties.getDataMap();
64-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
63+
MetadatasMap dataMap = dataProperties.getDataMap();
64+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
6565
{
6666
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
6767
}
@@ -73,8 +73,8 @@ std::ostream& operator<<( std::ostream& flux, const SubtitleProperties& subtitle
7373
{
7474
flux << separator << " Subtitle stream " << separator << std::endl;
7575

76-
std::map<std::string, std::string> dataMap = subtitleProperties.getDataMap();
77-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
76+
MetadatasMap dataMap = subtitleProperties.getDataMap();
77+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
7878
{
7979
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
8080
}
@@ -86,8 +86,8 @@ std::ostream& operator<<( std::ostream& flux, const AttachementProperties& attac
8686
{
8787
flux << separator << " Attachement stream " << separator << std::endl;
8888

89-
std::map<std::string, std::string> dataMap = attachementProperties.getDataMap();
90-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
89+
MetadatasMap dataMap = attachementProperties.getDataMap();
90+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
9191
{
9292
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
9393
}
@@ -99,8 +99,8 @@ std::ostream& operator<<( std::ostream& flux, const UnknownProperties& unknownPr
9999
{
100100
flux << separator << " Unknown stream " << separator << std::endl;
101101

102-
std::map<std::string, std::string> dataMap = unknownProperties.getDataMap();
103-
for( std::map<std::string, std::string>::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
102+
MetadatasMap dataMap = unknownProperties.getDataMap();
103+
for( MetadatasMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it )
104104
{
105105
flux << std::setw( keyWidth ) << it->first << ": " << it->second << std::endl;
106106
}

0 commit comments

Comments
 (0)